1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/***************************************************************************
* Copyright (C) 2003 by David Saxton *
* david@bluehaze.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "writeport.h"
#include "libraryitem.h"
#include "flowcode.h"
#include <klocale.h>
Item* WritePort::construct( ItemDocument *itemDocument, bool newItem, const char *id )
{
return new WritePort( (ICNDocument*)itemDocument, newItem, id );
}
LibraryItem* WritePort::libraryItem()
{
return new LibraryItem(
TQString("flow/writeport"),
i18n("Write to Port"),
i18n("I\\/O"),
"portwrite.png",
LibraryItem::lit_flowpart,
WritePort::construct );
}
WritePort::WritePort( ICNDocument *icnDocument, bool newItem, const char *id )
: FlowPart( icnDocument, newItem, (id) ? id : "writeport" )
{
m_name = i18n("Write to Port");
m_desc = i18n("Sets the port's pins state to high/low from the given value. Only pins that have been configured as output pins will take on the value assigned to them.");
initIOSymbol();
createStdInput();
createStdOutput();
createProperty( "0-var", Variant::Type::Combo );
property("0-var")->setToolbarCaption( i18n("Write") );
property("0-var")->setEditorCaption( i18n("Variable") );
property("0-var")->setValue("x");
createProperty( "1-port", Variant::Type::Port );
property("1-port")->setToolbarCaption( "to" );
property("1-port")->setEditorCaption( i18n("Port") );
property("1-port")->setValue("PORTA");
}
WritePort::~WritePort()
{
}
void WritePort::dataChanged()
{
setCaption( i18n("Write %1 to %2").arg(dataString("0-var")).arg(dataString("1-port")) );
}
void WritePort::generateMicrobe( FlowCode *code )
{
code->addCode( dataString("1-port")+" = "+dataString("0-var") );
code->addCodeBranch( outputPart("stdoutput") );
#if 0
TQString var = dataString("var");
TQString port = dataString("port");
// WTF? I don't want to do this!
// TQString newCode = "bsf STATUS,5 ; Move to bank 1\n";
TQString newCode;
if ( FlowCode::isLiteral(var) ) newCode += "movlw " + var + " ; Move " + var + " to working register w\n";
else
{
code->addVariable(var);
newCode += "movf " + var + ",0 ; Move " + var + " to working register w\n";
}
newCode += "movwf " + port + " ; Move register w to port\n";
// Same for below as for above
// newCode += "bcf STATUS,5 ; Come back to bank 0\n";
newCode += gotoCode("stdoutput") + "\n";
code->addCodeBlock( id(), newCode );
#endif
}
|