├── .gitattributes
├── .gitignore
├── README.md
├── ldmicro-rel2.2
├── OpenPLC Ladder.sdf
├── OpenPLC Ladder.sln
├── OpenPLC Ladder.suo
├── OpenPLC Ladder.vcxproj
├── OpenPLC Ladder.vcxproj.filters
├── OpenPLC Ladder.vcxproj.user
├── common
│ └── win32
│ │ ├── freeze.cpp
│ │ └── freeze.h
└── ldmicro
│ ├── CHANGES.txt
│ ├── COPYING.txt
│ ├── INTERNALS.txt
│ ├── Makefile
│ ├── README.txt
│ ├── addPath.bat
│ ├── ansic.cpp
│ ├── avr.cpp
│ ├── circuit.cpp
│ ├── coildialog.cpp
│ ├── commentdialog.cpp
│ ├── compilecommon.cpp
│ ├── confdialog.cpp
│ ├── contactsdialog.cpp
│ ├── draw.cpp
│ ├── draw_outputdev.cpp
│ ├── helpdialog.cpp
│ ├── intcode.cpp
│ ├── intcode.h
│ ├── interpreted.cpp
│ ├── iolist.cpp
│ ├── lang-de.txt
│ ├── lang-es.txt
│ ├── lang-fr.txt
│ ├── lang-it.txt
│ ├── lang-make.pl
│ ├── lang-pt.txt
│ ├── lang-tables.pl
│ ├── lang-tr.txt
│ ├── lang.cpp
│ ├── ldinterpret.c
│ ├── ldinterpret.exe
│ ├── ldinterpret.obj
│ ├── ldmicro.cpp
│ ├── ldmicro.exe
│ ├── ldmicro.exe.manifest
│ ├── ldmicro.h
│ ├── ldmicro.ico
│ ├── ldmicro.rc
│ ├── loadsave.cpp
│ ├── lutdialog.cpp
│ ├── maincontrols.cpp
│ ├── make.bat
│ ├── makeall.pl
│ ├── manual-de.txt
│ ├── manual-fr.txt
│ ├── manual-tr.txt
│ ├── manual.txt
│ ├── mcutable.h
│ ├── miscutil.cpp
│ ├── obj
│ ├── ansic.obj
│ ├── avr.obj
│ ├── circuit.obj
│ ├── coildialog.obj
│ ├── commentdialog.obj
│ ├── compilecommon.obj
│ ├── confdialog.obj
│ ├── contactsdialog.obj
│ ├── draw.obj
│ ├── draw_outputdev.obj
│ ├── freeze.obj
│ ├── helpdialog.obj
│ ├── helptext.cpp
│ ├── helptext.obj
│ ├── intcode.obj
│ ├── interpreted.obj
│ ├── iolist.obj
│ ├── lang-tables.h
│ ├── lang.obj
│ ├── ldinterpret.exe
│ ├── ldmicro.exe
│ ├── ldmicro.ilk
│ ├── ldmicro.obj
│ ├── ldmicro.pdb
│ ├── ldmicro.res
│ ├── loadsave.obj
│ ├── lutdialog.obj
│ ├── maincontrols.obj
│ ├── miscutil.obj
│ ├── pic16.obj
│ ├── resetdialog.obj
│ ├── schematic.obj
│ ├── simpledialog.obj
│ ├── simulate.obj
│ └── undoredo.obj
│ ├── pic16.cpp
│ ├── reg
│ ├── Ladder.cpp
│ ├── TesteLadder.cpp
│ ├── expected
│ │ ├── avr-hw.hex
│ │ ├── contacts.hex
│ │ ├── integers.hex
│ │ ├── misc-ops.hex
│ │ ├── pic16-hw.hex
│ │ └── timers-counters.hex
│ ├── go.bat
│ ├── run-tests.pl
│ └── tests
│ │ ├── avr-hw.ld
│ │ ├── contacts.ld
│ │ ├── integers.ld
│ │ ├── misc-ops.ld
│ │ ├── pic16-hw.ld
│ │ └── timers-counters.ld
│ ├── resetdialog.cpp
│ ├── sample
│ ├── 7seg-display.ld
│ ├── blink.ld
│ ├── pic-adc.ld
│ ├── serial.ld
│ ├── traffic.ld
│ └── var-timer.ld
│ ├── schematic.cpp
│ ├── simpledialog.cpp
│ ├── simulate.cpp
│ ├── txt2c.pl
│ ├── undoredo.cpp
│ └── vc100.pdb
└── license.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # =========================
18 | # Operating System Files
19 | # =========================
20 |
21 | # OSX
22 | # =========================
23 |
24 | .DS_Store
25 | .AppleDouble
26 | .LSOverride
27 |
28 | # Icon must ends with two \r.
29 | Icon
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear on external disk
35 | .Spotlight-V100
36 | .Trashes
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OpenPLC-Ladder-Editor
2 | =====================
3 |
4 | Ladder programming language for the OpenPLC and Arduino
5 |
6 | For more information, go to http://www.openplcproject.com
7 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/OpenPLC Ladder.sdf
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual C++ Express 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenPLC Ladder", "OpenPLC Ladder.vcxproj", "{C0AFE9E4-6360-780F-4F27-8A4716EA841F}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Debug|Win32.Build.0 = Debug|Win32
14 | {C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Release|Win32.ActiveCfg = Release|Win32
15 | {C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/OpenPLC Ladder.suo
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | Win32Proj
15 |
16 |
17 |
18 | Application
19 | true
20 |
21 |
22 | Application
23 | false
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | true
37 |
38 |
39 | true
40 |
41 |
42 |
43 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
44 | MultiThreadedDebugDLL
45 | Level3
46 | ProgramDatabase
47 | Disabled
48 |
49 |
50 | MachineX86
51 | true
52 | Windows
53 |
54 |
55 |
56 |
57 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
58 | MultiThreadedDLL
59 | Level3
60 | ProgramDatabase
61 |
62 |
63 | MachineX86
64 | true
65 | Windows
66 | true
67 | true
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 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 | Source Files
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files
53 |
54 |
55 | Source Files
56 |
57 |
58 | Source Files
59 |
60 |
61 | Source Files
62 |
63 |
64 | Source Files
65 |
66 |
67 | Source Files
68 |
69 |
70 | Source Files
71 |
72 |
73 | Source Files
74 |
75 |
76 | Source Files
77 |
78 |
79 | Source Files
80 |
81 |
82 | Source Files
83 |
84 |
85 | Source Files
86 |
87 |
88 | Source Files
89 |
90 |
91 | Source Files
92 |
93 |
94 | Source Files
95 |
96 |
97 | Source Files
98 |
99 |
100 | Source Files
101 |
102 |
103 | Source Files
104 |
105 |
106 |
107 |
108 | Header Files
109 |
110 |
111 | Header Files
112 |
113 |
114 | Header Files
115 |
116 |
117 | Header Files
118 |
119 |
120 | Header Files
121 |
122 |
123 |
124 |
125 | Resource Files
126 |
127 |
128 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/OpenPLC Ladder.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/common/win32/freeze.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * A library for storing parameters in the registry.
3 | *
4 | * Jonathan Westhues, 2002
5 | */
6 | #include
7 | #include
8 | #include
9 |
10 | /*
11 | * store a window's position in the registry, or fail silently if the registry calls don't work
12 | */
13 | void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
14 | {
15 | RECT r;
16 | GetWindowRect(hwnd, &r);
17 |
18 | HKEY software;
19 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
20 | return;
21 |
22 | char *keyName = (char *)malloc(strlen(name) + 30);
23 | if(!keyName)
24 | return;
25 |
26 | HKEY sub;
27 | if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
28 | return;
29 |
30 | sprintf(keyName, "%s_left", name);
31 | if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.left), sizeof(DWORD)) != ERROR_SUCCESS)
32 | return;
33 |
34 | sprintf(keyName, "%s_right", name);
35 | if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.right), sizeof(DWORD)) != ERROR_SUCCESS)
36 | return;
37 |
38 | sprintf(keyName, "%s_top", name);
39 | if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.top), sizeof(DWORD)) != ERROR_SUCCESS)
40 | return;
41 |
42 | sprintf(keyName, "%s_bottom", name);
43 | if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.bottom), sizeof(DWORD)) != ERROR_SUCCESS)
44 | return;
45 |
46 | sprintf(keyName, "%s_maximized", name);
47 | DWORD v = IsZoomed(hwnd);
48 | if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(v), sizeof(DWORD)) != ERROR_SUCCESS)
49 | return;
50 |
51 | free(keyName);
52 | }
53 |
54 | static void Clamp(LONG *v, LONG min, LONG max)
55 | {
56 | if(*v < min) *v = min;
57 | if(*v > max) *v = max;
58 | }
59 |
60 | /*
61 | * retrieve a window's position from the registry, or do nothing if there is no info saved
62 | */
63 | void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
64 | {
65 | HKEY software;
66 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
67 | return;
68 |
69 | HKEY sub;
70 | if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
71 | return;
72 |
73 | char *keyName = (char *)malloc(strlen(name) + 30);
74 | if(!keyName)
75 | return;
76 |
77 | DWORD l;
78 | RECT r;
79 |
80 | sprintf(keyName, "%s_left", name);
81 | l = sizeof(DWORD);
82 | if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.left), &l) != ERROR_SUCCESS)
83 | return;
84 |
85 | sprintf(keyName, "%s_right", name);
86 | l = sizeof(DWORD);
87 | if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.right), &l) != ERROR_SUCCESS)
88 | return;
89 |
90 | sprintf(keyName, "%s_top", name);
91 | l = sizeof(DWORD);
92 | if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.top), &l) != ERROR_SUCCESS)
93 | return;
94 |
95 | sprintf(keyName, "%s_bottom", name);
96 | l = sizeof(DWORD);
97 | if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.bottom), &l) != ERROR_SUCCESS)
98 | return;
99 |
100 | sprintf(keyName, "%s_maximized", name);
101 | DWORD v;
102 | l = sizeof(DWORD);
103 | if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
104 | return;
105 | if(v)
106 | ShowWindow(hwnd, SW_MAXIMIZE);
107 |
108 | RECT dr;
109 | GetWindowRect(GetDesktopWindow(), &dr);
110 |
111 | // If it somehow ended up off-screen, then put it back.
112 | Clamp(&(r.left), dr.left, dr.right);
113 | Clamp(&(r.right), dr.left, dr.right);
114 | Clamp(&(r.top), dr.top, dr.bottom);
115 | Clamp(&(r.bottom), dr.top, dr.bottom);
116 | if(r.right - r.left < 100) {
117 | r.left -= 300; r.right += 300;
118 | }
119 | if(r.bottom - r.top < 100) {
120 | r.top -= 300; r.bottom += 300;
121 | }
122 | Clamp(&(r.left), dr.left, dr.right);
123 | Clamp(&(r.right), dr.left, dr.right);
124 | Clamp(&(r.top), dr.top, dr.bottom);
125 | Clamp(&(r.bottom), dr.top, dr.bottom);
126 |
127 | MoveWindow(hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE);
128 |
129 | free(keyName);
130 | }
131 |
132 | /*
133 | * store a DWORD setting in the registry
134 | */
135 | void FreezeDWORDF(DWORD val, char *subKey, char *name)
136 | {
137 | HKEY software;
138 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
139 | return;
140 |
141 | HKEY sub;
142 | if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
143 | return;
144 |
145 | if(RegSetValueEx(sub, name, 0, REG_DWORD, (BYTE *)&val, sizeof(DWORD)) != ERROR_SUCCESS)
146 | return;
147 | }
148 |
149 | /*
150 | * retrieve a DWORD setting, or return the default if that setting is unavailable
151 | */
152 | DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
153 | {
154 | HKEY software;
155 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
156 | return val;
157 |
158 | HKEY sub;
159 | if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
160 | return val;
161 |
162 | DWORD l = sizeof(DWORD);
163 | DWORD v;
164 | if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
165 | return val;
166 |
167 | return v;
168 | }
169 |
170 | /*
171 | * store a string setting in the registry
172 | */
173 | void FreezeStringF(char *val, char *subKey, char *name)
174 | {
175 | HKEY software;
176 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
177 | return;
178 |
179 | HKEY sub;
180 | if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
181 | return;
182 |
183 | if(RegSetValueEx(sub, name, 0, REG_SZ, (BYTE *)val, strlen(val)+1) != ERROR_SUCCESS)
184 | return;
185 | }
186 |
187 | /*
188 | * retrieve a string setting, or return the default if that setting is unavailable
189 | */
190 | void ThawStringF(char *val, int max, char *subKey, char *name)
191 | {
192 | HKEY software;
193 | if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
194 | return;
195 |
196 | HKEY sub;
197 | if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
198 | return;
199 |
200 | DWORD l = max;
201 | if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)val, &l) != ERROR_SUCCESS)
202 | return;
203 | if(l >= (DWORD)max) return;
204 |
205 | val[l] = '\0';
206 | return;
207 | }
208 |
209 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/common/win32/freeze.h:
--------------------------------------------------------------------------------
1 | /*
2 | * A library for storing parameters in the registry.
3 | *
4 | * Jonathan Westhues, 2002
5 | */
6 |
7 | #ifndef __FREEZE_H
8 | #define __FREEZE_H
9 |
10 | #ifndef FREEZE_SUBKEY
11 | #error must define FREEZE_SUBKEY to a string uniquely identifying the app
12 | #endif
13 |
14 | #define FreezeWindowPos(hwnd) FreezeWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
15 | void FreezeWindowPosF(HWND hWnd, char *subKey, char *name);
16 |
17 | #define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
18 | void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
19 |
20 | #define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
21 | void FreezeDWORDF(DWORD val, char *subKey, char *name);
22 |
23 | #define ThawDWORD(val) val = ThawDWORDF(val, FREEZE_SUBKEY, #val)
24 | DWORD ThawDWORDF(DWORD val, char *subKey, char *name);
25 |
26 | #define FreezeString(val) FreezeStringF(val, FREEZE_SUBKEY, #val)
27 | void FreezeStringF(char *val, char *subKey, char *name);
28 |
29 | #define ThawString(val, max) ThawStringF(val, max, FREEZE_SUBKEY, #val)
30 | void ThawStringF(char *val, int max, char *subKey, char *name);
31 |
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/CHANGES.txt:
--------------------------------------------------------------------------------
1 |
2 | == Release 2.2
3 |
4 | * Fix a problem with the ANSI C target when the program had bit and
5 | integer variables with the same name. Note that this changes the
6 | names of the symbols in the generated C program; so a system that
7 | uses "magic variables" with this target for I/O must be updated
8 | to use the new names.
9 |
10 | * Fix a subtle bug in the PIC16 add and subtract routines, where
11 | operations of the form B = A - B could fail.
12 |
13 | * The piecewise linear tables were broken for the AVRs; fix that.
14 |
15 | == Release 2.1
16 |
17 | * For the AVR UARTs, poll UDRE instead of TXC. The formatted string op
18 | was broken on some targets, should now be fixed.
19 |
20 | * Don't draw selected op in bold font; that looks ugly under Vista.
21 |
22 | == Release 2.0
23 |
24 | * Add PIC16F886 and PIC16F887 targets.
25 |
26 | * Fix display bug in the list to select an I/O pin.
27 |
28 | * Fix bug where PIC16 UART locks up forever after a framing error when
29 | the cycle time is faster than one byte time.
30 |
31 | * Fix bug where PIC16 outputs could briefly glitch high at startup.
32 |
33 | * Clear PCLATH in PIC16 boot vector, since some bootloaders expect that.
34 |
35 | == Release 1.9
36 |
37 | * Modify PIC16 boot vectors to work with many bootloaders.
38 |
39 | == Release 1.8
40 |
41 | * Fix modification of a constant string that blew up in new MSVC++
42 | compiler.
43 |
44 | * Add Italian, Turkish, Portuguese.
45 |
46 | == Release 1.7
47 |
48 | * Make the source compile with latest version of MSVC++; overloaded
49 | functions behave a bit differently.
50 |
51 | * Recover from (and ignore) UART errors on the PIC16 target, instead
52 | of getting stuck forever.
53 |
54 | * Whenever contacts bound to an output pin (Yfoo) were edited, they
55 | reverted to an input pin (Xfoo); now fixed.
56 |
57 | * Don't abort on too-wide program; instead display nice message.
58 |
59 | * It was possible (by adding and deleting contacts/coils with the
60 | same name) to end up with two bit variables bound to the same
61 | physical I/O pin; now fixed.
62 |
63 | * File -> Open was correct, but Ctrl+O failed to ask about unsaved
64 | changes before opening requested file; now both are correct.
65 |
66 | * Add Spanish user interface strings.
67 |
68 | == Release 1.6
69 |
70 | * Internationalize the user interface strings; we now have versions
71 | in English, French, and German.
72 |
73 | * First source release, under the GPLv3.
74 |
75 | == Release 1.5
76 |
77 | * Add untested support for ATmega32.
78 |
79 | * Remove annoying lag in user interface when editing large (hundreds
80 | of ops) programs
81 |
82 | == Release 1.4
83 |
84 | * Fix a terrible bug in the target for the ATmega8; because there is
85 | no PORTA/DDRA/PINA, I broke an assumption in my code and failed
86 | to set up the port directions.
87 |
88 | == Release 1.3
89 |
90 | * Timer delays are represented as a signed 32-bit integer count
91 | of microseconds. If the user provides a delay >= 2**31 us, then
92 | show an error instead of just letting things wrap.
93 |
94 | * Change the start-up behaviour of TOF timers. Previously they would
95 | start from a count of zero, so they would be on (independent of
96 | rung-in) until they counted themselves off. Now they start out
97 | at full count (as if rung-in has been low for a very long time),
98 | so rung-out is low until rung-in goes high.
99 |
100 | == Release 1.2
101 |
102 | * Add an untested target for the ATmega8
103 |
104 | * Add a special instruction to simplify piecewise linear tables
105 |
106 | * Fix some user interface bugs: it was possible to drag the top of the
107 | I/O list so high that you couldn't grab it again, and there were
108 | some cases in which the pin number associated with UART and PWM
109 | variables was not displayed
110 |
111 | == Release 1.1
112 |
113 | * Fix persistent variables, which were broken for the PIC16F628
114 |
115 | == Release 1.0
116 |
117 | * Fix bug in which the filename that appears in the title bar of the
118 | main window failed to get updated when opening/saving a file using
119 | the keyboard shortcuts (Ctrl+O/+S)
120 |
121 | * Fix simulation crash when the ladder logic program divides by zero
122 |
123 | * Fix jumpy scrolling on programs with many rungs of logic when the
124 | cursor is off-screen
125 |
126 | == Release 0.9
127 |
128 | * Fix bug with formatted string op on the AVR
129 | * Fix previously-untested ATmega16 and ATmega162 targets, which were
130 | completely broken
131 |
132 | === Release 0.8
133 |
134 | * Fix PORTA on the PIC16F819 (came up assigned to ADCs, of course)
135 |
136 | === Release 0.7
137 |
138 | * Support arbitrary character (\xAB) escapes in formatted string op
139 | * Fix a bug in which the title bar of the main window was not updated
140 |
141 | === Release 0.6
142 |
143 | * Add formatted text output over serial (e.g. to an LCD or a PC)
144 | * Add ability to make variables persistent (i.e. auto-saved in EEPROM)
145 | * Add look-up table instructions
146 | * Fix a bug with the PORTE pins on some AVRs
147 | * Fix miscellaneous user interface bugs
148 |
149 | === Release 0.5
150 |
151 | * Interpretable byte code target
152 | * Shift register and master control relay instructions
153 |
154 | === Release 0.4
155 |
156 | * Make ADCs work on the AVRs
157 |
158 | === Release 0.3
159 |
160 | * Support serial for AVR
161 | * Support PWM for PIC16 and AVR
162 | * Show program filename in title bar of main window
163 | * Untested support for PIC16F88, F819, F876
164 | * Generate ANSI C code from ladder diagram
165 |
166 | === Release 0.2
167 |
168 | * Support serial communications (using UART), PIC16 only
169 | * Support ADC reads, PIC16 only
170 | * Simulation environment for ADC and serial
171 | * Support ASCII character constant ('a') literals
172 | * Fix PORTA pins in PIC16F628 (should assign as GPIO, not to comparator)
173 | * Make file open/save dialogs work under Win98
174 | * Fix PORTA/PORTE pins in PIC16F877 (should assign as GPIO, not to ADC)
175 | * Add ability to comment your program
176 | * Fix bug when a relative filename is given on the command line and
177 | the `Compile As' dialog is later used to specify a destination in
178 | a different directory
179 |
180 | === Release 0.1
181 |
182 | Initial release
183 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/INTERNALS.txt:
--------------------------------------------------------------------------------
1 |
2 | LDMICRO INTERNALS
3 | =================
4 |
5 | This document describes LDmicro's internal structure. I intend it as a
6 | quick reference for my own use.
7 |
8 |
9 | ADDING A NEW ELEM_XXX LADDER INSTRUCTION
10 | ========================================
11 |
12 | It is necessary to make changes in the following places:
13 |
14 | * ldmicro.h -- add the new ELEM_XXX #define
15 | -- add the new MNU_XXX for the menu to add it
16 | -- add any necessary data structures to ElemLeaf
17 | -- add prototypes for newly created extern functions
18 | -- if it is a leaf (it almost certainly is), to
19 | CASE_LEAF
20 |
21 | * maincontrols. -- add the code to create the menu
22 | cpp -- add the code to enable/disable the menu when we
23 | go from `edit' to `simulate' mode
24 |
25 | * iolist.cpp -- add to routines that build the I/O list; even if
26 | it does not affect the I/O list, it must be added
27 | to the case statement in ExtractNamesFromCircuit,
28 | so that it explicitly does nothing
29 |
30 | * draw.cpp -- routines to draw the element on the ladder diagram
31 |
32 | * loadsave.cpp -- routines to load and save the element to the
33 | xxx.ld file
34 |
35 | * intcode.cpp -- routines to generate intermediate code from the
36 | instruction
37 |
38 | * schematic.cpp -- WhatCanWeDoFromCursorAndTopology, update the
39 | enabled state of the menus (what can be inserted
40 | above/below/left/right, etc.) based on selection
41 | -- EditSelectedElement, self-explanatory
42 |
43 | * ldmicro.cpp -- typically menu/keyboard handlers to call the
44 | AddXXX function to insert the element
45 |
46 | * circuit.cpp -- the new AddXXX function, to add the element at the
47 | cursor point
48 |
49 | * simulate.cpp -- CheckVariableNamesCircuit, the design rules check
50 | to ensure that e.g. same Tname isn't used with
51 | two timers
52 |
53 | * xxxdialog.cpp -- an `edit element' dialog if necessary, somewhere
54 | (most likely to be simpledialog.cpp, using that)
55 |
56 |
57 | REPRESENTATION OF THE PROGRAM
58 | =============================
59 |
60 | (adapted from an email message, so the tone's a little odd, sorry)
61 |
62 | A ladder program can be thought of as a series-parallel network. Each
63 | rung is a series circuit; this circuit contains either leaf elements
64 | (like contacts, coils, etc.), or parallel circuits. The parallel circuits
65 | contain either leaf elements or series subcircuits. If you look at a
66 | .ld file in a text editor then you can see that I chose to represent
67 | the program in this way.
68 |
69 | This representation makes the compiler a relatively simple problem.
70 | Imagine that you wish to write a routine to evaluate a circuit. This
71 | routine will take as an input the circuit's rung-in condition, and
72 | provide as an output its rung-out. For a circuit consisting of a single
73 | leaf element this is straightforward; if you look at the Allen Bradley
74 | documentation then you will see that this is actually how they specify
75 | their instructions. For example, the rung-out condition of a set of
76 | contacts is false if either its rung-in condition is false or the input
77 | corresponding to the set of contacts is false. Let us say that for a
78 | leaf element L, the output
79 |
80 | Rout = L(Rin).
81 |
82 | If that element is a set of contacts named `Xin,' then
83 |
84 | L(Rin) := Rin && (Xin is HIGH).
85 |
86 | (I will use && for AND, and || for OR.)
87 |
88 | Next we must figure out how to compile a series circuit, for example (left
89 | to right), sub-circuits A, B, and C in series. In that case, the rung-in
90 | condition for A is the rung-in condition for the circuit. Then the rung-in
91 | condition for B is the rung-out condition for B, the rung-in condition for C
92 | is the rung-out condition for B, and the rung-out condition for the whole
93 | circuit is the rung-out condition for C. So if the whole series circuit is
94 | X, then
95 |
96 | X(Rin) := C(B(A(Rin))).
97 |
98 | Notice that the series circuit is not defined in terms of a boolean AND.
99 | That would work if you just had contacts, but for ops like TOF, whose
100 | rung-out can be true when their rung-ins are false, it breaks down.
101 |
102 | For a parallel circuit, for example sub-circuits A, B, and C in parallel,
103 | the rung-in condition for each of the sub-circuits is the rung-in
104 | condition for the whole circuit, and the rung-out condition is true if
105 | at least one of the rung-out conditions of the subcircuits is true. So
106 | if the whole parallel circuit is Y, then
107 |
108 | Y(Rin) := A(Rin) || B(Rin) || C(Rin).
109 |
110 | For the series or parallel circuits, the sub-circuits A, B, or C need not
111 | be leaf elements; they could be parallel or series circuits themselves. In
112 | that case you would have to apply the appropriate definition, maybe
113 | recursively (you could have a series circuit that contains a parallel
114 | circuit that contains another parallel circuit). Once you have written
115 | the program in that form, as cascaded and OR'd simple functions, any
116 | textbook in compilers can tell you what to do with it, if it is not
117 | obvious already.
118 |
119 | As I said, though, there are many implementation details. For example,
120 | I currently support five different targets: PIC16, AVR, ANSI C code,
121 | interpretable byte code, and the simulator. To reduce the amount of work
122 | that I must do, I have a simple intermediate representation, with only
123 | a couple dozen ops. The ladder logic is compiled to intermediate code,
124 | and the intermediate code is then compiled to whatever I need by the
125 | appropriate back end. This intermediate code is designed to be as simple
126 | and as easy to compile as possible, to minimize the time required for me
127 | to maintain five back ends. That is one of the major reasons why LDmicro
128 | generates poor code; a more expressive intcode would make it possible
129 | to write better back ends, but at the cost of implementation time.
130 |
131 | If you would like to see how I compile ladder logic to a procedural
132 | language, then I would suggest that you look at the code generated by the
133 | ANSI C back end.
134 |
135 |
136 | Jonathan Westhues, Mar 2006, Oct 2007
137 |
138 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/Makefile:
--------------------------------------------------------------------------------
1 | DEFINES = /D_WIN32_WINNT=0x400 /DISOLATION_AWARE_ENABLED /D_WIN32_IE=0x400 /DWIN32_LEAN_AND_MEAN /DWIN32 /D$(D)
2 | CFLAGS = /W3 /nologo -I..\common\win32 /O2 /D_CRT_SECURE_NO_WARNINGS /D_DEBUG /Zi
3 |
4 | HEADERS = ..\common\win32\freeze.h ldmicro.h mcutable.h intcode.h
5 |
6 | OBJDIR = obj
7 |
8 | FREEZE = $(OBJDIR)\freeze.obj
9 |
10 | LDOBJS = $(OBJDIR)\ldmicro.obj \
11 | $(OBJDIR)\maincontrols.obj \
12 | $(OBJDIR)\helpdialog.obj \
13 | $(OBJDIR)\schematic.obj \
14 | $(OBJDIR)\draw.obj \
15 | $(OBJDIR)\draw_outputdev.obj \
16 | $(OBJDIR)\circuit.obj \
17 | $(OBJDIR)\undoredo.obj \
18 | $(OBJDIR)\loadsave.obj \
19 | $(OBJDIR)\simulate.obj \
20 | $(OBJDIR)\commentdialog.obj \
21 | $(OBJDIR)\contactsdialog.obj \
22 | $(OBJDIR)\coildialog.obj \
23 | $(OBJDIR)\simpledialog.obj \
24 | $(OBJDIR)\resetdialog.obj \
25 | $(OBJDIR)\lutdialog.obj \
26 | $(OBJDIR)\confdialog.obj \
27 | $(OBJDIR)\iolist.obj \
28 | $(OBJDIR)\miscutil.obj \
29 | $(OBJDIR)\lang.obj \
30 | $(OBJDIR)\intcode.obj \
31 | $(OBJDIR)\compilecommon.obj \
32 | $(OBJDIR)\ansic.obj \
33 | $(OBJDIR)\interpreted.obj \
34 | $(OBJDIR)\pic16.obj \
35 | $(OBJDIR)\avr.obj
36 |
37 | HELPOBJ = $(OBJDIR)\helptext.obj
38 |
39 | LIBS = user32.lib gdi32.lib comctl32.lib advapi32.lib
40 |
41 | all: $(OBJDIR)/ldmicro.exe $(OBJDIR)/ldinterpret.exe
42 | @cp $(OBJDIR)/ldmicro.exe .
43 | @cp $(OBJDIR)/ldinterpret.exe .
44 | @cd reg
45 | @go.bat
46 | @cd ..
47 |
48 | clean:
49 | rm -f obj/*
50 |
51 | lang.cpp: $(OBJDIR)/lang-tables.h
52 |
53 | $(OBJDIR)/lang-tables.h: lang*.txt
54 | perl lang-tables.pl > $(OBJDIR)/lang-tables.h
55 |
56 | $(OBJDIR)/ldinterpret.exe: ldinterpret.c
57 | @$(CC) -Fe$(OBJDIR)/ldinterpret.exe $(LIBS) ldinterpret.c
58 |
59 | $(OBJDIR)/ldmicro.exe: $(LDOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res
60 | @$(CC) $(DEFINES) $(CFLAGS) -Fe$(OBJDIR)/ldmicro.exe $(LDOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res $(LIBS)
61 |
62 | $(OBJDIR)/ldmicro.res: ldmicro.rc ldmicro.ico
63 | @rc ldmicro.rc
64 | @mv ldmicro.res $(OBJDIR)
65 |
66 | $(LDOBJS): $(@B).cpp $(HEADERS)
67 | @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj $(@B).cpp
68 |
69 | $(FREEZE): ..\common\win32\$(@B).cpp $(HEADERS)
70 | @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj ..\common\win32\$(@B).cpp
71 |
72 | $(HELPOBJ): $(OBJDIR)/helptext.cpp
73 | @$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/helptext.obj $(OBJDIR)/helptext.cpp
74 |
75 | $(OBJDIR)/helptext.cpp: manual.txt manual-*.txt
76 | perl txt2c.pl > $(OBJDIR)/helptext.cpp
77 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/README.txt:
--------------------------------------------------------------------------------
1 |
2 | LDmicro is a ladder logic editor, simulator and compiler for 8-bit
3 | microcontrollers. It can generate native code for Atmel AVR and Microchip
4 | PIC16 CPUs from a ladder diagram.
5 |
6 | This program is free software; see COPYING.txt.
7 |
8 | I started work on LDmicro in October 2004.
9 |
10 | At present, I receive a steady stream of questions and feature requests,
11 | that I do not have time to address. I hope that others who find this
12 | program interesting or useful may be able to complete this work.
13 |
14 |
15 | BUILDING LDMICRO
16 | ================
17 |
18 | LDmicro is built using the Microsoft Visual C++ compiler. If that is
19 | installed correctly, then you should be able to just run
20 |
21 | make.bat
22 |
23 | and see everything build. The regression tests (however inadequate;
24 | see below) will run automatically after the program is built.
25 |
26 | Various source and header files are generated automatically. The perl
27 | scripts to do this are included with this distribution, but it's necessary
28 | to have a perl.exe in your path somewhere.
29 |
30 | The makefile accepts an argument, D=LANG_XX, where XX is the language
31 | code. make.bat supplies that argument automatically, as LANG_EN (English).
32 |
33 |
34 | HIGH-LEVEL ARCHITECTURE
35 | =======================
36 |
37 | LDmicro is a compiler. Unlike typical compilers, it does not accept a text
38 | file as its input; instead, the program is edited graphically, within
39 | LDmicro itself. The editor represents the program as a tree structure,
40 | where each node represents either an instruction (like relays contacts
41 | or a coil) or a series or parallel subcircuit.
42 |
43 | Based on this tree structure, intcode.cpp generates an intermediate
44 | `instruction list' representation of the program. This intermediate code
45 | is then passed to a processor-specific back-end, which generates code
46 | for the target.
47 |
48 | The program may also be simulated; in that case, rather than compiling
49 | the intermediate code to a .hex file, we interpret the intermediate code
50 | and display the results in real time.
51 |
52 | The intermediate code is useful, because there are fewer intermediate
53 | code ops than high-level ladder logic instructions.
54 |
55 | See INTERNALS.txt for some discussion of LDmicro's internals.
56 |
57 |
58 | POSSIBLE ENHANCEMENTS
59 | =====================
60 |
61 | If you are interested in contributing to LDmicro, then I believe that
62 | the following work would be useful. The list is in ascending order
63 | of difficulty.
64 |
65 | * Better regression tests. There is a mechanism for this now (see the
66 | reg/... directory), but very few tests. A regression test is just
67 | an LDmicro program; I verify that the same input .ld file generates
68 | the same output .hex file. The code generators are stupid enough
69 | that these don't break all that often (no fancy optimizers that
70 | reorder everything based on a small change to the input).
71 |
72 | * Thorough tests of the existing microcontroller targets. This
73 | requires appropriate hardware to test against. When I don't have
74 | the hardware myself, I will sometimes test against a simulator,
75 | but this is not as good as the real thing. The simulation of
76 | peripherals is often approximate.
77 |
78 | Even if no bugs are found, the test programs can become regression
79 | tests, and we can mark those targets that have been tested as
80 | `known good'.
81 |
82 | * More targets for PIC16 and AVR architectures. In general, this
83 | should be very easy; just add the appropriate entries in
84 | mcutable.h. Some small changes to pic16.cpp or avr.cpp may be
85 | required, if the peripheral registers move around.
86 |
87 | I am not interested in new targets that have not been tested
88 | against real hardware.
89 |
90 | * The code generator has regression tests now. It would be nice to
91 | also have regression tests for the display code. We could do this
92 | using the "Export As Text" logic, since that calls the exact same
93 | code that's used to display the program on-screen.
94 |
95 | * Bitwise instructions that work on integers (e.g., let internal
96 | relay Rfoo equal the seventh bit of integer variable x, set c =
97 | a bitwise-and b, etc).
98 |
99 | This would require new intermediate code ops, and thus changes to
100 | both the PIC and AVR back ends, and thus testing of those changes.
101 | Aside from that, it's very straightforward.
102 |
103 | These new intcode ops could then be used by higher-level ELEM_XXX
104 | ops, for example to do bit-banged synchronous serial protocols
105 | (I2C, SPI), or to talk to an HD44780-type LCD.
106 |
107 | * Intermediate code ops for look-up tables. At present, these are
108 | implemented stupidly, as a chain of if-then statements. This would
109 | require changes to all the code generators.
110 |
111 | Look-up tables are important, not just for the `look-up table'
112 | instruction, but also for the `formatted string over serial'
113 | instruction, where the string is stored in a look-up table.
114 |
115 | * New architecture targets. An architecture target translates from
116 | LDmicro's intermediate code (intcode) to a binary for that
117 | architecture. This means that it includes a code generator and
118 | an assembler. The PIC16 and AVR targets are about 1500 lines of
119 | code each.
120 |
121 | A PIC18 target would be nice. I am not interested in a PIC18
122 | back-end that does not exploit the additional addressing modes
123 | and instructions (like rjmps); it would be easy to hack up the
124 | PIC16 back end to generate something that would run on a PIC18,
125 | but not useful.
126 |
127 | An 8051 target is the other obvious choice, maybe also for the
128 | MSP430.
129 |
130 | * A Linux port. I am told that the current version runs perfectly
131 | under WINE, but a native GTK port would be nice. That would be
132 | a lot of work.
133 |
134 | I am not interested in porting to a cross-platform GUI toolkit, and
135 | thus abandoning the native Win32 user interface. In general, I think
136 | that those toolkits end up looking equally wrong on all platforms.
137 |
138 | If I were to undertake this myself, then I would probably end up
139 | writing a miniature compatibility layer for the widgets that I
140 | actually use, that mapped on to GTK under Linux and Win32 under
141 | Windows, and so on. I've seen attempts at general-purpose libraries
142 | to do that, but they look extremely complex for what they do.
143 |
144 | In general, I am not interested in changes that involve linking against
145 | non-standard libraries. (By non-standard, I mean anything that's not
146 | distributed with the operating system.)
147 |
148 |
149 | FOREIGN-LANGUAGE TRANSLATIONS
150 | =============================
151 |
152 | Foreign-language translations of the documentation and user interface
153 | are always useful. At present, we have English, German, and French.
154 |
155 | These do not require changes to the source code; a lookup table of
156 | translated strings is automatically generated from lang-*.txt during
157 | the build process. If you are interested in preparing a translation,
158 | but do not wish to set up tools to build LDmicro, then just mail me the
159 | lang-xx.txt, and I can build ldmicro-xx.exe for you.
160 |
161 | At present, LDmicro does not use Unicode. This means that translations
162 | into languages not written in the Latin alphabet are tricky. This could
163 | be changed, of course.
164 |
165 |
166 | FINAL
167 | =====
168 |
169 | I will always respond to bug reports. If LDmicro is behaving incorrectly
170 | on some target, then please attach the simplest example of a program
171 | that's misbehaving, and a description of the incorrect behavior.
172 |
173 | Please contact me if you have any questions.
174 |
175 |
176 | Jonathan Westhues
177 | user jwesthues, at host cq.cx
178 |
179 | near Seattle, Oct 21, 2007
180 |
181 |
182 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/addPath.bat:
--------------------------------------------------------------------------------
1 | path=%path%;c:\strawberry\c\bin;c:\strawberry\perl\site\bin;c:\strawberry\perl\bin;C:\Program Files\GnuWin32\bin
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/coildialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Dialog for setting the properties of a relay coils: negated or not,
21 | // plus the name, plus set-only or reset-only
22 | // Jonathan Westhues, Oct 2004
23 | //-----------------------------------------------------------------------------
24 | #include
25 | #include
26 | #include
27 |
28 | #include "ldmicro.h"
29 |
30 | static HWND CoilDialog;
31 |
32 | static HWND SourceInternalRelayRadio;
33 | static HWND SourceMcuPinRadio;
34 | static HWND NegatedRadio;
35 | static HWND NormalRadio;
36 | static HWND SetOnlyRadio;
37 | static HWND ResetOnlyRadio;
38 | static HWND NameTextbox;
39 |
40 | static LONG_PTR PrevNameProc;
41 |
42 | //-----------------------------------------------------------------------------
43 | // Don't allow any characters other than A-Za-z0-9_ in the name.
44 | //-----------------------------------------------------------------------------
45 | static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam,
46 | LPARAM lParam)
47 | {
48 | if(msg == WM_CHAR) {
49 | if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
50 | wParam == '\b'))
51 | {
52 | return 0;
53 | }
54 | }
55 |
56 | return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
57 | }
58 |
59 | static void MakeControls(void)
60 | {
61 | HWND grouper = CreateWindowEx(0, WC_BUTTON, _("Type"),
62 | WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP,
63 | 7, 3, 120, 105, CoilDialog, NULL, Instance, NULL);
64 | NiceFont(grouper);
65 |
66 | NormalRadio = CreateWindowEx(0, WC_BUTTON, _("( ) Normal"),
67 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP,
68 | 16, 21, 100, 20, CoilDialog, NULL, Instance, NULL);
69 | NiceFont(NormalRadio);
70 |
71 | NegatedRadio = CreateWindowEx(0, WC_BUTTON, _("(/) Negated"),
72 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
73 | 16, 41, 100, 20, CoilDialog, NULL, Instance, NULL);
74 | NiceFont(NegatedRadio);
75 |
76 | SetOnlyRadio = CreateWindowEx(0, WC_BUTTON, _("(S) Set-Only"),
77 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
78 | 16, 61, 100, 20, CoilDialog, NULL, Instance, NULL);
79 | NiceFont(SetOnlyRadio);
80 |
81 | ResetOnlyRadio = CreateWindowEx(0, WC_BUTTON, _("(R) Reset-Only"),
82 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
83 | 16, 81, 105, 20, CoilDialog, NULL, Instance, NULL);
84 | NiceFont(ResetOnlyRadio);
85 |
86 | HWND grouper2 = CreateWindowEx(0, WC_BUTTON, _("Source"),
87 | WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
88 | 140, 3, 120, 65, CoilDialog, NULL, Instance, NULL);
89 | NiceFont(grouper2);
90 |
91 | SourceInternalRelayRadio = CreateWindowEx(0, WC_BUTTON, _("Internal Relay"),
92 | WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
93 | 149, 21, 100, 20, CoilDialog, NULL, Instance, NULL);
94 | NiceFont(SourceInternalRelayRadio);
95 |
96 | SourceMcuPinRadio = CreateWindowEx(0, WC_BUTTON, _("Pin on MCU"),
97 | WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_TABSTOP,
98 | 149, 41, 100, 20, CoilDialog, NULL, Instance, NULL);
99 | NiceFont(SourceMcuPinRadio);
100 |
101 | HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Name:"),
102 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
103 | 135, 80, 50, 21, CoilDialog, NULL, Instance, NULL);
104 | NiceFont(textLabel);
105 |
106 | NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
107 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
108 | 190, 80, 155, 21, CoilDialog, NULL, Instance, NULL);
109 | FixedFont(NameTextbox);
110 |
111 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
112 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
113 | 276, 10, 70, 23, CoilDialog, NULL, Instance, NULL);
114 | NiceFont(OkButton);
115 |
116 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
117 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
118 | 276, 40, 70, 23, CoilDialog, NULL, Instance, NULL);
119 | NiceFont(CancelButton);
120 |
121 | PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
122 | (LONG_PTR)MyNameProc);
123 | }
124 |
125 | void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name)
126 | {
127 | CoilDialog = CreateWindowClient(0, "LDmicroDialog",
128 | _("Coil"), WS_OVERLAPPED | WS_SYSMENU,
129 | 100, 100, 359, 115, NULL, NULL, Instance, NULL);
130 | RECT r;
131 | GetClientRect(CoilDialog, &r);
132 |
133 | MakeControls();
134 |
135 | if(name[0] == 'R') {
136 | SendMessage(SourceInternalRelayRadio, BM_SETCHECK, BST_CHECKED, 0);
137 | } else {
138 | SendMessage(SourceMcuPinRadio, BM_SETCHECK, BST_CHECKED, 0);
139 | }
140 | SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1));
141 | if(*negated) {
142 | SendMessage(NegatedRadio, BM_SETCHECK, BST_CHECKED, 0);
143 | } else if(*setOnly) {
144 | SendMessage(SetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0);
145 | } else if(*resetOnly) {
146 | SendMessage(ResetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0);
147 | } else {
148 | SendMessage(NormalRadio, BM_SETCHECK, BST_CHECKED, 0);
149 | }
150 |
151 | EnableWindow(MainWindow, FALSE);
152 | ShowWindow(CoilDialog, TRUE);
153 | SetFocus(NameTextbox);
154 | SendMessage(NameTextbox, EM_SETSEL, 0, -1);
155 |
156 | MSG msg;
157 | DWORD ret;
158 | DialogDone = FALSE;
159 | DialogCancel = FALSE;
160 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
161 | if(msg.message == WM_KEYDOWN) {
162 | if(msg.wParam == VK_RETURN) {
163 | DialogDone = TRUE;
164 | break;
165 | } else if(msg.wParam == VK_ESCAPE) {
166 | DialogDone = TRUE;
167 | DialogCancel = TRUE;
168 | break;
169 | }
170 | }
171 |
172 | if(IsDialogMessage(CoilDialog, &msg)) continue;
173 | TranslateMessage(&msg);
174 | DispatchMessage(&msg);
175 | }
176 |
177 | if(!DialogCancel) {
178 | if(SendMessage(SourceInternalRelayRadio, BM_GETSTATE, 0, 0)
179 | & BST_CHECKED)
180 | {
181 | name[0] = 'R';
182 | } else {
183 | name[0] = 'Y';
184 | }
185 | SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(name+1));
186 |
187 | if(SendMessage(NormalRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
188 | *negated = FALSE;
189 | *setOnly = FALSE;
190 | *resetOnly = FALSE;
191 | } else if(SendMessage(NegatedRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
192 | *negated = TRUE;
193 | *setOnly = FALSE;
194 | *resetOnly = FALSE;
195 | } else if(SendMessage(SetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
196 | *negated = FALSE;
197 | *setOnly = TRUE;
198 | *resetOnly = FALSE;
199 | } else if(SendMessage(ResetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED)
200 | {
201 | *negated = FALSE;
202 | *setOnly = FALSE;
203 | *resetOnly = TRUE;
204 | }
205 | }
206 |
207 | EnableWindow(MainWindow, TRUE);
208 | DestroyWindow(CoilDialog);
209 | return;
210 | }
211 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/commentdialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Dialog to enter the text of a comment; make it long and skinny to
21 | // encourage people to write it the way it will look on the diagram.
22 | // Jonathan Westhues, Jun 2005
23 | //-----------------------------------------------------------------------------
24 | #include
25 | #include
26 | #include
27 |
28 | #include "ldmicro.h"
29 |
30 | static HWND CommentDialog;
31 |
32 | static HWND CommentTextbox;
33 |
34 | static void MakeControls(void)
35 | {
36 | CommentTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
37 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE |
38 | ES_MULTILINE | ES_WANTRETURN,
39 | 7, 10, 600, 38, CommentDialog, NULL, Instance, NULL);
40 | FixedFont(CommentTextbox);
41 |
42 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
43 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
44 | 620, 6, 70, 23, CommentDialog, NULL, Instance, NULL);
45 | NiceFont(OkButton);
46 |
47 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
48 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
49 | 620, 36, 70, 23, CommentDialog, NULL, Instance, NULL);
50 | NiceFont(CancelButton);
51 | }
52 |
53 | void ShowCommentDialog(char *comment)
54 | {
55 | CommentDialog = CreateWindowClient(0, "LDmicroDialog",
56 | _("Comment"), WS_OVERLAPPED | WS_SYSMENU,
57 | 100, 100, 700, 65, NULL, NULL, Instance, NULL);
58 |
59 | MakeControls();
60 |
61 | SendMessage(CommentTextbox, WM_SETTEXT, 0, (LPARAM)comment);
62 |
63 | EnableWindow(MainWindow, FALSE);
64 | ShowWindow(CommentDialog, TRUE);
65 | SetFocus(CommentTextbox);
66 | SendMessage(CommentTextbox, EM_SETSEL, 0, -1);
67 |
68 | MSG msg;
69 | DWORD ret;
70 | DialogDone = FALSE;
71 | DialogCancel = FALSE;
72 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
73 | if(msg.message == WM_KEYDOWN) {
74 | if(msg.wParam == VK_TAB && GetFocus() == CommentTextbox) {
75 | SetFocus(OkButton);
76 | continue;
77 | } else if(msg.wParam == VK_ESCAPE) {
78 | DialogDone = TRUE;
79 | DialogCancel = TRUE;
80 | break;
81 | }
82 | }
83 |
84 | if(IsDialogMessage(CommentDialog, &msg)) continue;
85 | TranslateMessage(&msg);
86 | DispatchMessage(&msg);
87 | }
88 |
89 | if(!DialogCancel) {
90 | SendMessage(CommentTextbox, WM_GETTEXT, (WPARAM)(MAX_COMMENT_LEN-1),
91 | (LPARAM)comment);
92 | }
93 |
94 | EnableWindow(MainWindow, TRUE);
95 | DestroyWindow(CommentDialog);
96 | return;
97 | }
98 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/confdialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Dialog for setting the overall PLC parameters. Mostly this relates to
21 | // timing; to set up the timers we need to know the desired cycle time,
22 | // which is configurable, plus the MCU clock (i.e. crystal frequency).
23 | // Jonathan Westhues, Nov 2004
24 | //-----------------------------------------------------------------------------
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include "ldmicro.h"
31 |
32 | static HWND ConfDialog;
33 |
34 | static HWND CrystalTextbox;
35 | static HWND CycleTextbox;
36 | static HWND BaudTextbox;
37 |
38 | static LONG_PTR PrevCrystalProc;
39 | static LONG_PTR PrevCycleProc;
40 | static LONG_PTR PrevBaudProc;
41 |
42 | //-----------------------------------------------------------------------------
43 | // Don't allow any characters other than 0-9. in the text boxes.
44 | //-----------------------------------------------------------------------------
45 | static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam,
46 | LPARAM lParam)
47 | {
48 | if(msg == WM_CHAR) {
49 | if(!(isdigit(wParam) || wParam == '.' || wParam == '\b')) {
50 | return 0;
51 | }
52 | }
53 |
54 | LONG_PTR t;
55 | if(hwnd == CrystalTextbox)
56 | t = PrevCrystalProc;
57 | else if(hwnd == CycleTextbox)
58 | t = PrevCycleProc;
59 | else if(hwnd == BaudTextbox)
60 | t = PrevBaudProc;
61 | else
62 | oops();
63 |
64 | return CallWindowProc((WNDPROC)t, hwnd, msg, wParam, lParam);
65 | }
66 |
67 | static void MakeControls(void)
68 | {
69 | HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Cycle Time (ms):"),
70 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
71 | 5, 13, 145, 21, ConfDialog, NULL, Instance, NULL);
72 | NiceFont(textLabel);
73 |
74 | CycleTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
75 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
76 | 155, 12, 85, 21, ConfDialog, NULL, Instance, NULL);
77 | NiceFont(CycleTextbox);
78 |
79 | HWND textLabel2 = CreateWindowEx(0, WC_STATIC,
80 | _("Crystal Frequency (MHz):"),
81 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
82 | 0, 43, 150, 21, ConfDialog, NULL, Instance, NULL);
83 | NiceFont(textLabel2);
84 |
85 | CrystalTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
86 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
87 | 155, 42, 85, 21, ConfDialog, NULL, Instance, NULL);
88 | NiceFont(CrystalTextbox);
89 |
90 | HWND textLabel3 = CreateWindowEx(0, WC_STATIC, _("UART Baud Rate (bps):"),
91 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
92 | 5, 73, 145, 21, ConfDialog, NULL, Instance, NULL);
93 | NiceFont(textLabel3);
94 |
95 | BaudTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
96 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
97 | 155, 72, 85, 21, ConfDialog, NULL, Instance, NULL);
98 | NiceFont(BaudTextbox);
99 |
100 | if(!UartFunctionUsed()) {
101 | EnableWindow(BaudTextbox, FALSE);
102 | EnableWindow(textLabel3, FALSE);
103 | }
104 |
105 | if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC ||
106 | Prog.mcu->whichIsa == ISA_INTERPRETED))
107 | {
108 | EnableWindow(CrystalTextbox, FALSE);
109 | EnableWindow(textLabel2, FALSE);
110 | }
111 |
112 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
113 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
114 | 258, 11, 70, 23, ConfDialog, NULL, Instance, NULL);
115 | NiceFont(OkButton);
116 |
117 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
118 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
119 | 258, 41, 70, 23, ConfDialog, NULL, Instance, NULL);
120 | NiceFont(CancelButton);
121 |
122 | char explanation[1024] = "";
123 |
124 | if(UartFunctionUsed()) {
125 | if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) {
126 | sprintf(explanation,
127 | _("Serial (UART) will use pins %d and %d.\r\n\r\n"),
128 | Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin);
129 | } else {
130 | strcpy(explanation,
131 | _("Please select a micro with a UART.\r\n\r\n"));
132 | }
133 | } else {
134 | strcpy(explanation, _("No serial instructions (UART Send/UART Receive) "
135 | "are in use; add one to program before setting baud rate.\r\n\r\n")
136 | );
137 | }
138 |
139 | strcat(explanation,
140 | _("The cycle time for the 'PLC' runtime generated by LDmicro is user-"
141 | "configurable. Very short cycle times may not be achievable due "
142 | "to processor speed constraints, and very long cycle times may not "
143 | "be achievable due to hardware overflows. Cycle times between 10 ms "
144 | "and 100 ms will usually be practical.\r\n\r\n"
145 | "The compiler must know what speed crystal you are using with the "
146 | "micro to convert between timing in clock cycles and timing in "
147 | "seconds. A 4 MHz to 20 MHz crystal is typical; check the speed "
148 | "grade of the part you are using to determine the maximum allowable "
149 | "clock speed before choosing a crystal."));
150 |
151 | HWND textLabel4 = CreateWindowEx(0, WC_STATIC, explanation,
152 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
153 | 11, 104, 310, 400, ConfDialog, NULL, Instance, NULL);
154 | NiceFont(textLabel4);
155 |
156 | // Measure the explanation string, so that we know how to size our window
157 | RECT tr, cr;
158 | HDC hdc = CreateCompatibleDC(NULL);
159 | SelectObject(hdc, MyNiceFont);
160 | SetRect(&tr, 0, 0, 310, 400);
161 | DrawText(hdc, explanation, -1, &tr, DT_CALCRECT |
162 | DT_LEFT | DT_TOP | DT_WORDBREAK);
163 | DeleteDC(hdc);
164 | int h = 104 + tr.bottom + 10;
165 | SetWindowPos(ConfDialog, NULL, 0, 0, 344, h, SWP_NOMOVE);
166 | // h is the desired client height, but SetWindowPos includes title bar;
167 | // so fix it up by hand
168 | GetClientRect(ConfDialog, &cr);
169 | int nh = h + (h - (cr.bottom - cr.top));
170 | SetWindowPos(ConfDialog, NULL, 0, 0, 344, nh, SWP_NOMOVE);
171 |
172 |
173 | PrevCycleProc = SetWindowLongPtr(CycleTextbox, GWLP_WNDPROC,
174 | (LONG_PTR)MyNumberProc);
175 |
176 | PrevCrystalProc = SetWindowLongPtr(CrystalTextbox, GWLP_WNDPROC,
177 | (LONG_PTR)MyNumberProc);
178 |
179 | PrevBaudProc = SetWindowLongPtr(BaudTextbox, GWLP_WNDPROC,
180 | (LONG_PTR)MyNumberProc);
181 | }
182 |
183 | void ShowConfDialog(void)
184 | {
185 | // The window's height will be resized later, to fit the explanation text.
186 | ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"),
187 | WS_OVERLAPPED | WS_SYSMENU,
188 | 100, 100, 0, 0, NULL, NULL, Instance, NULL);
189 |
190 | MakeControls();
191 |
192 | char buf[16];
193 | sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0));
194 | SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf);
195 |
196 | sprintf(buf, "%.6f", Prog.mcuClock / 1e6);
197 | SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf);
198 |
199 | sprintf(buf, "%d", Prog.baudRate);
200 | SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf);
201 |
202 | EnableWindow(MainWindow, FALSE);
203 | ShowWindow(ConfDialog, TRUE);
204 | SetFocus(CycleTextbox);
205 |
206 | MSG msg;
207 | DWORD ret;
208 | DialogDone = FALSE;
209 | DialogCancel = FALSE;
210 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
211 | if(msg.message == WM_KEYDOWN) {
212 | if(msg.wParam == VK_RETURN) {
213 | DialogDone = TRUE;
214 | break;
215 | } else if(msg.wParam == VK_ESCAPE) {
216 | DialogDone = TRUE;
217 | DialogCancel = TRUE;
218 | break;
219 | }
220 | }
221 |
222 | if(IsDialogMessage(ConfDialog, &msg)) continue;
223 | TranslateMessage(&msg);
224 | DispatchMessage(&msg);
225 | }
226 |
227 | if(!DialogCancel) {
228 | char buf[16];
229 | SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
230 | (LPARAM)(buf));
231 | Prog.cycleTime = (int)(1000*atof(buf) + 0.5);
232 | if(Prog.cycleTime == 0) {
233 | Error(_("Zero cycle time not valid; resetting to 10 ms."));
234 | Prog.cycleTime = 10000;
235 | }
236 |
237 | SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
238 | (LPARAM)(buf));
239 | Prog.mcuClock = (int)(1e6*atof(buf) + 0.5);
240 |
241 | SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf),
242 | (LPARAM)(buf));
243 | Prog.baudRate = atoi(buf);
244 | }
245 |
246 | EnableWindow(MainWindow, TRUE);
247 | DestroyWindow(ConfDialog);
248 | return;
249 | }
250 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/contactsdialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Dialog for setting the properties of a set of contacts: negated or not,
21 | // plus the name
22 | // Jonathan Westhues, Oct 2004
23 | //-----------------------------------------------------------------------------
24 | #include
25 | #include
26 | #include
27 |
28 | #include "ldmicro.h"
29 |
30 | static HWND ContactsDialog;
31 |
32 | static HWND NegatedCheckbox;
33 | static HWND SourceInternalRelayRadio;
34 | static HWND SourceInputPinRadio;
35 | static HWND SourceOutputPinRadio;
36 | static HWND NameTextbox;
37 |
38 | static LONG_PTR PrevNameProc;
39 |
40 | //-----------------------------------------------------------------------------
41 | // Don't allow any characters other than A-Za-z0-9_ in the name.
42 | //-----------------------------------------------------------------------------
43 | static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam,
44 | LPARAM lParam)
45 | {
46 | if(msg == WM_CHAR) {
47 | if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
48 | wParam == '\b'))
49 | {
50 | return 0;
51 | }
52 | }
53 |
54 | return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
55 | }
56 |
57 | static void MakeControls(void)
58 | {
59 | HWND grouper = CreateWindowEx(0, WC_BUTTON, _("Source"),
60 | WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
61 | 7, 3, 120, 85, ContactsDialog, NULL, Instance, NULL);
62 | NiceFont(grouper);
63 |
64 | SourceInternalRelayRadio = CreateWindowEx(0, WC_BUTTON, _("Internal Relay"),
65 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
66 | 16, 21, 100, 20, ContactsDialog, NULL, Instance, NULL);
67 | NiceFont(SourceInternalRelayRadio);
68 |
69 | SourceInputPinRadio = CreateWindowEx(0, WC_BUTTON, _("Input pin"),
70 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
71 | 16, 41, 100, 20, ContactsDialog, NULL, Instance, NULL);
72 | NiceFont(SourceInputPinRadio);
73 |
74 | SourceOutputPinRadio = CreateWindowEx(0, WC_BUTTON, _("Output pin"),
75 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
76 | 16, 61, 100, 20, ContactsDialog, NULL, Instance, NULL);
77 | NiceFont(SourceOutputPinRadio);
78 |
79 | HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Name:"),
80 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
81 | 135, 16, 50, 21, ContactsDialog, NULL, Instance, NULL);
82 | NiceFont(textLabel);
83 |
84 | NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
85 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
86 | 190, 16, 115, 21, ContactsDialog, NULL, Instance, NULL);
87 | FixedFont(NameTextbox);
88 |
89 | NegatedCheckbox = CreateWindowEx(0, WC_BUTTON, _("|/| Negated"),
90 | WS_CHILD | BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE,
91 | 146, 44, 160, 20, ContactsDialog, NULL, Instance, NULL);
92 | NiceFont(NegatedCheckbox);
93 |
94 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
95 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
96 | 321, 10, 70, 23, ContactsDialog, NULL, Instance, NULL);
97 | NiceFont(OkButton);
98 |
99 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
100 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
101 | 321, 40, 70, 23, ContactsDialog, NULL, Instance, NULL);
102 | NiceFont(CancelButton);
103 |
104 | PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
105 | (LONG_PTR)MyNameProc);
106 | }
107 |
108 | void ShowContactsDialog(BOOL *negated, char *name)
109 | {
110 | ContactsDialog = CreateWindowClient(0, "LDmicroDialog",
111 | _("Contacts"), WS_OVERLAPPED | WS_SYSMENU,
112 | 100, 100, 404, 95, NULL, NULL, Instance, NULL);
113 |
114 | MakeControls();
115 |
116 | if(name[0] == 'R') {
117 | SendMessage(SourceInternalRelayRadio, BM_SETCHECK, BST_CHECKED, 0);
118 | } else if(name[0] == 'Y') {
119 | SendMessage(SourceOutputPinRadio, BM_SETCHECK, BST_CHECKED, 0);
120 | } else {
121 | SendMessage(SourceInputPinRadio, BM_SETCHECK, BST_CHECKED, 0);
122 | }
123 | if(*negated) {
124 | SendMessage(NegatedCheckbox, BM_SETCHECK, BST_CHECKED, 0);
125 | }
126 | SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1));
127 |
128 | EnableWindow(MainWindow, FALSE);
129 | ShowWindow(ContactsDialog, TRUE);
130 | SetFocus(NameTextbox);
131 | SendMessage(NameTextbox, EM_SETSEL, 0, -1);
132 |
133 | MSG msg;
134 | DWORD ret;
135 | DialogDone = FALSE;
136 | DialogCancel = FALSE;
137 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
138 | if(msg.message == WM_KEYDOWN) {
139 | if(msg.wParam == VK_RETURN) {
140 | DialogDone = TRUE;
141 | break;
142 | } else if(msg.wParam == VK_ESCAPE) {
143 | DialogDone = TRUE;
144 | DialogCancel = TRUE;
145 | break;
146 | }
147 | }
148 |
149 | if(IsDialogMessage(ContactsDialog, &msg)) continue;
150 | TranslateMessage(&msg);
151 | DispatchMessage(&msg);
152 | }
153 |
154 | if(!DialogCancel) {
155 | if(SendMessage(NegatedCheckbox, BM_GETSTATE, 0, 0) & BST_CHECKED) {
156 | *negated = TRUE;
157 | } else {
158 | *negated = FALSE;
159 | }
160 | if(SendMessage(SourceInternalRelayRadio, BM_GETSTATE, 0, 0)
161 | & BST_CHECKED)
162 | {
163 | name[0] = 'R';
164 | } else if(SendMessage(SourceInputPinRadio, BM_GETSTATE, 0, 0)
165 | & BST_CHECKED)
166 | {
167 | name[0] = 'X';
168 | } else {
169 | name[0] = 'Y';
170 | }
171 | SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(name+1));
172 | }
173 |
174 | EnableWindow(MainWindow, TRUE);
175 | DestroyWindow(ContactsDialog);
176 | return;
177 | }
178 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/helpdialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Window to show our internal help. Roll my own using a rich edit control so
21 | // that I don't have to distribute a separate Windows Help or HTML file; the
22 | // manual is compiled in to the exe. Do pretty syntax highlighting style
23 | // colours.
24 | // Jonathan Westhues, Dec 2004
25 | //-----------------------------------------------------------------------------
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | #include "ldmicro.h"
33 |
34 | extern char *HelpText[];
35 | extern char *HelpTextDe[];
36 | extern char *HelpTextFr[];
37 | extern char *HelpTextTr[];
38 |
39 | static char *AboutText[] = {
40 | "",
41 | "ABOUT LDMICRO",
42 | "=============",
43 | "",
44 | "LDmicro is a ladder logic editor, simulator and compiler for 8-bit",
45 | "microcontrollers. It can generate native code for Atmel AVR and Microchip",
46 | "PIC16 CPUs from a ladder diagram.",
47 | "",
48 | "This program is free software: you can redistribute it and/or modify it",
49 | "under the terms of the GNU General Public License as published by the",
50 | "Free Software Foundation, either version 3 of the License, or (at your",
51 | "option) any later version.",
52 | "",
53 | "This program is distributed in the hope that it will be useful, but",
54 | "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY",
55 | "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License",
56 | "for more details.",
57 | "",
58 | "You should have received a copy of the GNU General Public License along",
59 | "with this program. If not, see .",
60 | "",
61 | "The source code for LDmicro is available at",
62 | "",
63 | " http://cq.cx/ladder.pl",
64 | "",
65 | "Copyright 2005-2010 Jonathan Westhues",
66 | "Release 2.2, built " __TIME__ " " __DATE__ ".",
67 | "",
68 | "Email: user jwesthues, at host cq.cx",
69 | "",
70 | NULL
71 | };
72 |
73 | static char **Text[] = {
74 | #if defined(LDLANG_EN) || \
75 | defined(LDLANG_ES) || \
76 | defined(LDLANG_IT) || \
77 | defined(LDLANG_PT)
78 | HelpText,
79 | #elif defined(LDLANG_DE)
80 | HelpTextDe,
81 | #elif defined(LDLANG_FR)
82 | HelpTextFr,
83 | #elif defined(LDLANG_TR)
84 | HelpTextTr,
85 | #else
86 | # error "Bad language"
87 | #endif
88 |
89 | // Let's always keep the about text in English.
90 | AboutText
91 | };
92 |
93 | static HWND HelpDialog[2];
94 | static HWND RichEdit[2];
95 |
96 | static BOOL HelpWindowOpen[2];
97 |
98 | static int TitleHeight;
99 |
100 | #define RICH_EDIT_HEIGHT(h) \
101 | ((((h) - 3 + (FONT_HEIGHT/2)) / FONT_HEIGHT) * FONT_HEIGHT)
102 |
103 | static void SizeRichEdit(int a)
104 | {
105 | RECT r;
106 | GetClientRect(HelpDialog[a], &r);
107 |
108 | SetWindowPos(RichEdit[a], HWND_TOP, 6, 3, r.right - 6,
109 | RICH_EDIT_HEIGHT(r.bottom), 0);
110 | }
111 |
112 | static BOOL Resizing(RECT *r, int wParam)
113 | {
114 | BOOL touched = FALSE;
115 | if(r->right - r->left < 650) {
116 | int diff = 650 - (r->right - r->left);
117 | if(wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT ||
118 | wParam == WMSZ_BOTTOMRIGHT)
119 | {
120 | r->right += diff;
121 | } else {
122 | r->left -= diff;
123 | }
124 | touched = TRUE;
125 | }
126 |
127 | if(!(wParam == WMSZ_LEFT || wParam == WMSZ_RIGHT)) {
128 | int h = r->bottom - r->top - TitleHeight - 5;
129 | if(RICH_EDIT_HEIGHT(h) != h) {
130 | int diff = h - RICH_EDIT_HEIGHT(h);
131 | if(wParam == WMSZ_TOP || wParam == WMSZ_TOPRIGHT ||
132 | wParam == WMSZ_TOPLEFT)
133 | {
134 | r->top += diff;
135 | } else {
136 | r->bottom -= diff;
137 | }
138 | touched = TRUE;
139 | }
140 | }
141 |
142 | return !touched;
143 | }
144 |
145 | static void MakeControls(int a)
146 | {
147 | HMODULE re = LoadLibrary("RichEd20.dll");
148 | if(!re) oops();
149 |
150 | RichEdit[a] = CreateWindowEx(0, RICHEDIT_CLASS,
151 | "", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY |
152 | ES_MULTILINE | WS_VSCROLL,
153 | 0, 0, 100, 100, HelpDialog[a], NULL, Instance, NULL);
154 |
155 | SendMessage(RichEdit[a], WM_SETFONT, (WPARAM)FixedWidthFont, TRUE);
156 | SendMessage(RichEdit[a], EM_SETBKGNDCOLOR, (WPARAM)0, RGB(0, 0, 0));
157 |
158 | SizeRichEdit(a);
159 |
160 | int i;
161 | BOOL nextSubHead = FALSE;
162 | for(i = 0; Text[a][i]; i++) {
163 | char *s = Text[a][i];
164 |
165 | CHARFORMAT cf;
166 | cf.cbSize = sizeof(cf);
167 | cf.dwMask = CFM_BOLD | CFM_COLOR;
168 | cf.dwEffects = 0;
169 | if((s[0] == '=') ||
170 | (Text[a][i+1] && Text[a][i+1][0] == '='))
171 | {
172 | cf.crTextColor = RGB(255, 255, 110);
173 | } else if(s[3] == '|' && s[4] == '|') {
174 | cf.crTextColor = RGB(255, 110, 255);
175 | } else if(s[0] == '>' || nextSubHead) {
176 | // Need to make a copy because the strings we are passed aren't
177 | // mutable.
178 | char copy[1024];
179 | if(strlen(s) >= sizeof(copy)) oops();
180 | strcpy(copy, s);
181 |
182 | int j;
183 | for(j = 1; copy[j]; j++) {
184 | if(copy[j] == ' ' && copy[j-1] == ' ')
185 | break;
186 | }
187 | BOOL justHeading = (copy[j] == '\0');
188 | copy[j] = '\0';
189 | cf.crTextColor = RGB(110, 255, 110);
190 | SendMessage(RichEdit[a], EM_SETCHARFORMAT, SCF_SELECTION,
191 | (LPARAM)&cf);
192 | SendMessage(RichEdit[a], EM_REPLACESEL, (WPARAM)FALSE,
193 | (LPARAM)copy);
194 | SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
195 |
196 | // Special case if there's nothing except title on the line
197 | if(!justHeading) {
198 | copy[j] = ' ';
199 | }
200 | s += j;
201 | cf.crTextColor = RGB(255, 110, 255);
202 | nextSubHead = !nextSubHead;
203 | } else {
204 | cf.crTextColor = RGB(255, 255, 255);
205 | }
206 |
207 | SendMessage(RichEdit[a], EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
208 | SendMessage(RichEdit[a], EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)s);
209 | SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
210 |
211 | if(Text[a][i+1]) {
212 | SendMessage(RichEdit[a], EM_REPLACESEL, FALSE, (LPARAM)"\r\n");
213 | SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
214 | }
215 | }
216 |
217 | SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)0, (LPARAM)0);
218 | }
219 |
220 | //-----------------------------------------------------------------------------
221 | // Window proc for the help dialog.
222 | //-----------------------------------------------------------------------------
223 | static LRESULT CALLBACK HelpProc(HWND hwnd, UINT msg, WPARAM wParam,
224 | LPARAM lParam)
225 | {
226 | int a = (hwnd == HelpDialog[0] ? 0 : 1);
227 | switch (msg) {
228 | case WM_SIZING: {
229 | RECT *r = (RECT *)lParam;
230 | return Resizing(r, wParam);
231 | break;
232 | }
233 | case WM_SIZE:
234 | SizeRichEdit(a);
235 | break;
236 |
237 | case WM_ACTIVATE:
238 | case WM_KEYDOWN:
239 | SetFocus(RichEdit[a]);
240 | break;
241 |
242 | case WM_DESTROY:
243 | case WM_CLOSE:
244 | HelpWindowOpen[a] = FALSE;
245 | // fall through
246 | default:
247 | return DefWindowProc(hwnd, msg, wParam, lParam);
248 | }
249 |
250 | return 1;
251 | }
252 |
253 | //-----------------------------------------------------------------------------
254 | // Create the class for the help window.
255 | //-----------------------------------------------------------------------------
256 | static void MakeClass(void)
257 | {
258 | WNDCLASSEX wc;
259 | memset(&wc, 0, sizeof(wc));
260 | wc.cbSize = sizeof(wc);
261 |
262 | wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC |
263 | CS_DBLCLKS;
264 | wc.lpfnWndProc = (WNDPROC)HelpProc;
265 | wc.hInstance = Instance;
266 | wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
267 | wc.lpszClassName = "LDmicroHelp";
268 | wc.lpszMenuName = NULL;
269 | wc.hCursor = LoadCursor(NULL, IDC_ARROW);
270 | wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
271 | IMAGE_ICON, 32, 32, 0);
272 | wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
273 | IMAGE_ICON, 16, 16, 0);
274 |
275 | RegisterClassEx(&wc);
276 | }
277 |
278 | void ShowHelpDialog(BOOL about)
279 | {
280 | int a = about ? 1 : 0;
281 | if(HelpWindowOpen[a]) {
282 | SetForegroundWindow(HelpDialog[a]);
283 | return;
284 | }
285 |
286 | MakeClass();
287 |
288 | char *s = about ? "About LDmicro" : "LDmicro Help";
289 | HelpDialog[a] = CreateWindowEx(0, "LDmicroHelp", s,
290 | WS_OVERLAPPED | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |
291 | WS_SIZEBOX,
292 | 100, 100, 650, 300+10*FONT_HEIGHT, NULL, NULL, Instance, NULL);
293 | MakeControls(a);
294 |
295 | ShowWindow(HelpDialog[a], TRUE);
296 | SetFocus(RichEdit[a]);
297 |
298 | HelpWindowOpen[a] = TRUE;
299 |
300 | RECT r;
301 | GetClientRect(HelpDialog[a], &r);
302 | TitleHeight = 300 - r.bottom;
303 |
304 | GetWindowRect(HelpDialog[a], &r);
305 | Resizing(&r, WMSZ_TOP);
306 | SetWindowPos(HelpDialog[a], HWND_TOP, r.left, r.top, r.right - r.left,
307 | r.bottom - r.top, 0);
308 | }
309 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/intcode.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Description of the intermediate code that we generate. The routines in
21 | // intcode.cpp generate this intermediate code from the program source. Then
22 | // either we simulate the intermediate code with the routines in simulate.cpp
23 | // or we convert it to PIC or AVR instructions so that it can run on a
24 | // real device.
25 | // Jonathan Westhues, Nov 2004
26 | //-----------------------------------------------------------------------------
27 |
28 | #ifndef __INTCODE_H
29 | #define __INTCODE_H
30 |
31 | #define INT_SET_BIT 1
32 | #define INT_CLEAR_BIT 2
33 | #define INT_COPY_BIT_TO_BIT 3
34 | #define INT_SET_VARIABLE_TO_LITERAL 4
35 | #define INT_SET_VARIABLE_TO_VARIABLE 5
36 | #define INT_INCREMENT_VARIABLE 6
37 | #define INT_SET_VARIABLE_ADD 7
38 | #define INT_SET_VARIABLE_SUBTRACT 8
39 | #define INT_SET_VARIABLE_MULTIPLY 9
40 | #define INT_SET_VARIABLE_DIVIDE 10
41 |
42 | #define INT_READ_ADC 11
43 | #define INT_SET_PWM 12
44 | #define INT_UART_SEND 13
45 | #define INT_UART_RECV 14
46 | #define INT_EEPROM_BUSY_CHECK 15
47 | #define INT_EEPROM_READ 16
48 | #define INT_EEPROM_WRITE 17
49 |
50 | #define INT_IF_GROUP(x) (((x) >= 50) && ((x) < 60))
51 | #define INT_IF_BIT_SET 50
52 | #define INT_IF_BIT_CLEAR 51
53 | #define INT_IF_VARIABLE_LES_LITERAL 52
54 | #define INT_IF_VARIABLE_EQUALS_VARIABLE 53
55 | #define INT_IF_VARIABLE_GRT_VARIABLE 54
56 |
57 | #define INT_ELSE 60
58 | #define INT_END_IF 61
59 |
60 | #define INT_SIMULATE_NODE_STATE 80
61 |
62 | #define INT_COMMENT 100
63 |
64 | // Only used for the interpretable code.
65 | #define INT_END_OF_PROGRAM 255
66 |
67 | #if !defined(INTCODE_H_CONSTANTS_ONLY)
68 | typedef struct IntOpTag {
69 | int op;
70 | char name1[MAX_NAME_LEN];
71 | char name2[MAX_NAME_LEN];
72 | char name3[MAX_NAME_LEN];
73 | SWORD literal;
74 | BOOL *poweredAfter;
75 | } IntOp;
76 |
77 | #define MAX_INT_OPS (1024*16)
78 | extern IntOp IntCode[MAX_INT_OPS];
79 | extern int IntCodeLen;
80 | #endif
81 |
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/interpreted.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // A crunched-down version of the intermediate code (e.g. assigning addresses
21 | // to all the variables instead of just working with their names), suitable
22 | // for interpretation.
23 | // Jonathan Westhues, Aug 2005
24 | //-----------------------------------------------------------------------------
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include "ldmicro.h"
31 | #include "intcode.h"
32 |
33 | static char Variables[MAX_IO][MAX_NAME_LEN];
34 | static int VariablesCount;
35 |
36 | static char InternalRelays[MAX_IO][MAX_NAME_LEN];
37 | static int InternalRelaysCount;
38 |
39 | typedef struct {
40 | WORD op;
41 | WORD name1;
42 | WORD name2;
43 | WORD name3;
44 | SWORD literal;
45 | } BinOp;
46 |
47 | static BinOp OutProg[MAX_INT_OPS];
48 |
49 | static WORD AddrForInternalRelay(char *name)
50 | {
51 | int i;
52 | for(i = 0; i < InternalRelaysCount; i++) {
53 | if(strcmp(InternalRelays[i], name)==0) {
54 | return i;
55 | }
56 | }
57 | strcpy(InternalRelays[i], name);
58 | InternalRelaysCount++;
59 | return i;
60 | }
61 |
62 | static WORD AddrForVariable(char *name)
63 | {
64 | int i;
65 | for(i = 0; i < VariablesCount; i++) {
66 | if(strcmp(Variables[i], name)==0) {
67 | return i;
68 | }
69 | }
70 | strcpy(Variables[i], name);
71 | VariablesCount++;
72 | return i;
73 | }
74 |
75 | static void Write(FILE *f, BinOp *op)
76 | {
77 | BYTE *b = (BYTE *)op;
78 | int i;
79 | for(i = 0; i < sizeof(*op); i++) {
80 | fprintf(f, "%02x", b[i]);
81 | }
82 | fprintf(f, "\n");
83 | }
84 |
85 | void CompileInterpreted(char *outFile)
86 | {
87 | FILE *f = fopen(outFile, "w");
88 | if(!f) {
89 | Error(_("Couldn't write to '%s'"), outFile);
90 | return;
91 | }
92 |
93 | InternalRelaysCount = 0;
94 | VariablesCount = 0;
95 |
96 | fprintf(f, "$$LDcode\n");
97 |
98 | int ipc;
99 | int outPc;
100 | BinOp op;
101 |
102 | // Convert the if/else structures in the intermediate code to absolute
103 | // conditional jumps, to make life a bit easier for the interpreter.
104 | #define MAX_IF_NESTING 32
105 | int ifDepth = 0;
106 | // PC for the if(...) instruction, which we will complete with the
107 | // 'jump to if false' address (which is either the ELSE+1 or the ENDIF+1)
108 | int ifOpIf[MAX_IF_NESTING];
109 | // PC for the else instruction, which we will complete with the
110 | // 'jump to if reached' address (which is the ENDIF+1)
111 | int ifOpElse[MAX_IF_NESTING];
112 |
113 | outPc = 0;
114 | for(ipc = 0; ipc < IntCodeLen; ipc++) {
115 | memset(&op, 0, sizeof(op));
116 | op.op = IntCode[ipc].op;
117 |
118 | switch(IntCode[ipc].op) {
119 | case INT_CLEAR_BIT:
120 | case INT_SET_BIT:
121 | op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
122 | break;
123 |
124 | case INT_COPY_BIT_TO_BIT:
125 | op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
126 | op.name2 = AddrForInternalRelay(IntCode[ipc].name2);
127 | break;
128 |
129 | case INT_SET_VARIABLE_TO_LITERAL:
130 | op.name1 = AddrForVariable(IntCode[ipc].name1);
131 | op.literal = IntCode[ipc].literal;
132 | break;
133 |
134 | case INT_SET_VARIABLE_TO_VARIABLE:
135 | op.name1 = AddrForVariable(IntCode[ipc].name1);
136 | op.name2 = AddrForVariable(IntCode[ipc].name2);
137 | break;
138 |
139 | case INT_INCREMENT_VARIABLE:
140 | op.name1 = AddrForVariable(IntCode[ipc].name1);
141 | break;
142 |
143 | case INT_SET_VARIABLE_ADD:
144 | case INT_SET_VARIABLE_SUBTRACT:
145 | case INT_SET_VARIABLE_MULTIPLY:
146 | case INT_SET_VARIABLE_DIVIDE:
147 | op.name1 = AddrForVariable(IntCode[ipc].name1);
148 | op.name2 = AddrForVariable(IntCode[ipc].name2);
149 | op.name3 = AddrForVariable(IntCode[ipc].name3);
150 | break;
151 |
152 | case INT_IF_BIT_SET:
153 | case INT_IF_BIT_CLEAR:
154 | op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
155 | goto finishIf;
156 | case INT_IF_VARIABLE_LES_LITERAL:
157 | op.name1 = AddrForVariable(IntCode[ipc].name1);
158 | op.literal = IntCode[ipc].literal;
159 | goto finishIf;
160 | case INT_IF_VARIABLE_EQUALS_VARIABLE:
161 | case INT_IF_VARIABLE_GRT_VARIABLE:
162 | op.name1 = AddrForVariable(IntCode[ipc].name1);
163 | op.name2 = AddrForVariable(IntCode[ipc].name2);
164 | goto finishIf;
165 | finishIf:
166 | ifOpIf[ifDepth] = outPc;
167 | ifOpElse[ifDepth] = 0;
168 | ifDepth++;
169 | // jump target will be filled in later
170 | break;
171 |
172 | case INT_ELSE:
173 | ifOpElse[ifDepth-1] = outPc;
174 | // jump target will be filled in later
175 | break;
176 |
177 | case INT_END_IF:
178 | --ifDepth;
179 | if(ifOpElse[ifDepth] == 0) {
180 | // There is no else; if should jump straight to the
181 | // instruction after this one if the condition is false.
182 | OutProg[ifOpIf[ifDepth]].name3 = outPc-1;
183 | } else {
184 | // There is an else clause; if the if is false then jump
185 | // just past the else, and if the else is reached then
186 | // jump to the endif.
187 | OutProg[ifOpIf[ifDepth]].name3 = ifOpElse[ifDepth];
188 | OutProg[ifOpElse[ifDepth]].name3 = outPc-1;
189 | }
190 | // But don't generate an instruction for this.
191 | continue;
192 |
193 | case INT_SIMULATE_NODE_STATE:
194 | case INT_COMMENT:
195 | // Don't care; ignore, and don't generate an instruction.
196 | continue;
197 |
198 | case INT_EEPROM_BUSY_CHECK:
199 | case INT_EEPROM_READ:
200 | case INT_EEPROM_WRITE:
201 | case INT_READ_ADC:
202 | case INT_SET_PWM:
203 | case INT_UART_SEND:
204 | case INT_UART_RECV:
205 | default:
206 | Error(_("Unsupported op (anything ADC, PWM, UART, EEPROM) for "
207 | "interpretable target."));
208 | fclose(f);
209 | return;
210 | }
211 |
212 | memcpy(&OutProg[outPc], &op, sizeof(op));
213 | outPc++;
214 | }
215 |
216 | int i;
217 | for(i = 0; i < outPc; i++) {
218 | Write(f, &OutProg[i]);
219 | }
220 | memset(&op, 0, sizeof(op));
221 | op.op = INT_END_OF_PROGRAM;
222 | Write(f, &op);
223 |
224 |
225 | fprintf(f, "$$bits\n");
226 | for(i = 0; i < InternalRelaysCount; i++) {
227 | if(InternalRelays[i][0] != '$') {
228 | fprintf(f, "%s,%d\n", InternalRelays[i], i);
229 | }
230 | }
231 | fprintf(f, "$$int16s\n");
232 | for(i = 0; i < VariablesCount; i++) {
233 | if(Variables[i][0] != '$') {
234 | fprintf(f, "%s,%d\n", Variables[i], i);
235 | }
236 | }
237 |
238 | fprintf(f, "$$cycle %d us\n", Prog.cycleTime);
239 |
240 | fclose(f);
241 |
242 | char str[MAX_PATH+500];
243 | sprintf(str,
244 | _("Compile successful; wrote interpretable code to '%s'.\r\n\r\n"
245 | "You probably have to adapt the interpreter to your application. See "
246 | "the documentation."), outFile);
247 | CompileSuccessfulMessage(str);
248 | }
249 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-de.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/lang-de.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-es.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/lang-es.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-fr.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/lang-fr.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-it.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/lang-it.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-make.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $engl = 1;
4 | while(<>) {
5 | chomp;
6 |
7 | if(/^\s*$/) {
8 | if($engl) {
9 | next;
10 | } else {
11 | die "blank line mid-translation at $file, $.\n";
12 | }
13 | }
14 |
15 | if($engl) {
16 | $toTranslate = $_;
17 | $engl = 0;
18 | } else {
19 | $translated = $_;
20 |
21 | $toTranslate =~ s/\0/\\"/g;
22 | $toTranslate =~ s#"##g;
23 | $Already{$toTranslate} = 1;
24 | $engl = 1;
25 | }
26 | }
27 |
28 | # A tool to generate a list of strings to internationalize
29 |
30 | for $file (<*.cpp>) {
31 | open(IN, $file) or die;
32 | $source = join("", );
33 | close IN;
34 |
35 | $source =~ s/\\"/\0/g;
36 |
37 | while($source =~ m#
38 | _\( \s*
39 | ((
40 | \s* "
41 | [^"]+
42 | " \s*
43 | )+)
44 | \s*\)
45 | #xsg) {
46 | $str = $1;
47 | $strIn = '';
48 | while($str =~ m#\s*"([^"]+)"\s*#g) {
49 | $strIn .= $1;
50 | }
51 | $Occurs{$strIn} = $c++;
52 | $String{$strIn}++;
53 | }
54 | }
55 |
56 | sub by_occurrence {
57 | $Occurs{$a} <=> $Occurs{$b};
58 | }
59 |
60 | for (sort by_occurrence (keys %String)) {
61 | if (not $Already{$_}) {
62 | $_ =~ s/\0/\\"/g;
63 | print qq{"$_"\n\n\n};
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-pt.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/lang-pt.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/lang-tables.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $t = '';
4 |
5 | for $file (sort ) {
6 | open(IN, $file);
7 |
8 | $name = $file;
9 | $name =~ s#lang-##;
10 | $name =~ s#(.)#uc($1)#e;
11 | $name =~ s#\.txt##;
12 | $nameUc = uc($name);
13 |
14 | print "#ifdef LDLANG_$nameUc\n";
15 | print "static LangTable Lang${name}Table[] = {\n";
16 |
17 | $engl = 1;
18 | $. = 0;
19 | while() {
20 | chomp;
21 |
22 | if(/^\s*$/) {
23 | if($engl) {
24 | next;
25 | } else {
26 | die "blank line mid-translation at $file, $.\n";
27 | }
28 | }
29 |
30 | if($engl) {
31 | $toTranslate = $_;
32 | $engl = 0;
33 | } else {
34 | $translated = $_;
35 |
36 | print " { $toTranslate, $translated },\n";
37 | $engl = 1;
38 | }
39 | }
40 |
41 | print "};\n";
42 |
43 | print <.
18 | //------
19 | //
20 | // Multiple language support. For every non-English language, we have a
21 | // table that maps the English strings to the translated strings. An
22 | // internationalized version of the program will attempt to translate any
23 | // string that is passed, using the appropriate (selected by a #define)
24 | // table. If it fails then it just returns the English.
25 | // Jonathan Westhues, Apr 2007
26 | //-----------------------------------------------------------------------------
27 | #include
28 | #include
29 | #include
30 |
31 | #include "ldmicro.h"
32 |
33 | typedef struct LangTableTag {
34 | char *from;
35 | char *to;
36 | } LangTable;
37 |
38 | typedef struct LangTag {
39 | LangTable *tab;
40 | int n;
41 | } Lang;
42 |
43 | // These are the actual translation tables, so should be included in just
44 | // one place.
45 | #include "obj/lang-tables.h"
46 |
47 | char *_(char *in)
48 | {
49 | Lang *l;
50 |
51 | #if defined(LDLANG_EN)
52 | return in;
53 | #elif defined(LDLANG_DE)
54 | l = &LangDe;
55 | #elif defined(LDLANG_FR)
56 | l = &LangFr;
57 | #elif defined(LDLANG_ES)
58 | l = &LangEs;
59 | #elif defined(LDLANG_IT)
60 | l = &LangIt;
61 | #elif defined(LDLANG_TR)
62 | l = &LangTr;
63 | #elif defined(LDLANG_PT)
64 | l = &LangPt;
65 | #else
66 | # error "Unrecognized language!"
67 | #endif
68 |
69 | int i;
70 |
71 | for(i = 0; i < l->n; i++) {
72 | if(strcmp(in, l->tab[i].from)==0) {
73 | return l->tab[i].to;
74 | }
75 | }
76 |
77 | return in;
78 | }
79 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldinterpret.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/ldinterpret.exe
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldinterpret.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/ldinterpret.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldmicro.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/ldmicro.exe
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldmicro.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 | Ladder logic editor/compiler for PIC and AVR micros.
10 |
11 |
12 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldmicro.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/ldmicro.ico
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/ldmicro.rc:
--------------------------------------------------------------------------------
1 |
2 | // we need a manifest if we want visual styles; put in numbers since somethings a bit screwy
3 | // with my SDK install (I don't think I've got *.rh right)
4 | 1 24 "ldmicro.exe.manifest"
5 |
6 | 4000 ICON "ldmicro.ico"
7 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/make.bat:
--------------------------------------------------------------------------------
1 | @nmake D=LDLANG_EN %*
2 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/makeall.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | sub SYS { system($_[0]); }
4 |
5 | SYS("rm -rf build");
6 | SYS("mkdir build");
7 |
8 | for $f qw(DE ES FR IT PT TR) {
9 | SYS("nmake clean");
10 | SYS("nmake D=LDLANG_$f");
11 | $fl = lc($f);
12 | SYS("copy ldmicro.exe build\\ldmicro-$fl.exe");
13 | }
14 |
15 | SYS("nmake clean");
16 | SYS("nmake D=LDLANG_EN");
17 | SYS("copy ldmicro.exe build\\ldmicro.exe");
18 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/manual-de.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/manual-de.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/manual-fr.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/manual-fr.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/manual-tr.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/manual-tr.txt
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ansic.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ansic.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/avr.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/avr.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/circuit.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/circuit.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/coildialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/coildialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/commentdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/commentdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/compilecommon.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/compilecommon.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/confdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/confdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/contactsdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/contactsdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/draw.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/draw.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/draw_outputdev.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/draw_outputdev.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/freeze.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/freeze.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/helpdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/helpdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/helptext.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/helptext.cpp
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/helptext.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/helptext.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/intcode.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/intcode.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/interpreted.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/interpreted.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/iolist.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/iolist.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/lang-tables.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/lang-tables.h
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/lang.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/lang.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldinterpret.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldinterpret.exe
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldmicro.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldmicro.exe
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldmicro.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldmicro.ilk
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldmicro.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldmicro.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldmicro.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldmicro.pdb
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/ldmicro.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/ldmicro.res
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/loadsave.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/loadsave.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/lutdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/lutdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/maincontrols.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/maincontrols.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/miscutil.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/miscutil.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/pic16.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/pic16.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/resetdialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/resetdialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/schematic.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/schematic.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/simpledialog.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/simpledialog.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/simulate.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/simulate.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/obj/undoredo.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/obj/undoredo.obj
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/Ladder.cpp:
--------------------------------------------------------------------------------
1 | /* This is auto-generated code from LDmicro. Do not edit this file! Go
2 | back to the ladder diagram source for changes in the logic, and make
3 | any C additions either in ladder.h or in additional .c files linked
4 | against this one. */
5 |
6 | /* You must provide ladder.h; there you must provide:
7 | * a typedef for SWORD and BOOL, signed 16 bit and boolean types
8 | (probably typedef signed short SWORD; typedef unsigned char BOOL;)
9 |
10 | You must also provide implementations of all the I/O read/write
11 | either as inlines in the header file or in another source file. (The
12 | I/O functions are all declared extern.)
13 |
14 | See the generated source code (below) for function names. */
15 | #include "ladder.h"
16 |
17 | /* Define EXTERN_EVERYTHING in ladder.h if you want all symbols extern.
18 | This could be useful to implement `magic variables,' so that for
19 | example when you write to the ladder variable duty_cycle, your PLC
20 | runtime can look at the C variable U_duty_cycle and use that to set
21 | the PWM duty cycle on the micro. That way you can add support for
22 | peripherals that LDmicro doesn't know about. */
23 | #ifdef EXTERN_EVERYTHING
24 | #define STATIC
25 | #else
26 | #define STATIC static
27 | #endif
28 |
29 | /* Define NO_PROTOTYPES if you don't want LDmicro to provide prototypes for
30 | all the I/O functions (Read_U_xxx, Write_U_xxx) that you must provide.
31 | If you define this then you must provide your own prototypes for these
32 | functions in ladder.h, or provide definitions (e.g. as inlines or macros)
33 | for them in ladder.h. */
34 | #ifdef NO_PROTOTYPES
35 | #define PROTO(x)
36 | #else
37 | #define PROTO(x) x
38 | #endif
39 |
40 | /* U_xxx symbols correspond to user-defined names. There is such a symbol
41 | for every internal relay, variable, timer, and so on in the ladder
42 | program. I_xxx symbols are internally generated. */
43 | STATIC BOOL I_b_mcr = 0;
44 | #define Read_I_b_mcr() I_b_mcr
45 | #define Write_I_b_mcr(x) I_b_mcr = x
46 | STATIC BOOL I_b_rung_top = 0;
47 | #define Read_I_b_rung_top() I_b_rung_top
48 | #define Write_I_b_rung_top(x) I_b_rung_top = x
49 | STATIC BOOL U_b_Rosc = 0;
50 | #define Read_U_b_Rosc() U_b_Rosc
51 | #define Write_U_b_Rosc(x) U_b_Rosc = x
52 | STATIC BOOL I_b_Tof_antiglitch = 0;
53 | #define Read_I_b_Tof_antiglitch() I_b_Tof_antiglitch
54 | #define Write_I_b_Tof_antiglitch(x) I_b_Tof_antiglitch = x
55 | STATIC SWORD U_i_Tof = 0;
56 | STATIC SWORD U_i_Ton = 0;
57 |
58 | /* You provide this function. */
59 | PROTO(extern BOOL Read_U_b_Xup(void);)
60 |
61 | STATIC BOOL I_b_oneShot_0000 = 0;
62 | #define Read_I_b_oneShot_0000() I_b_oneShot_0000
63 | #define Write_I_b_oneShot_0000(x) I_b_oneShot_0000 = x
64 | STATIC SWORD U_i_Ccnt = 0;
65 | STATIC SWORD U_i_Trto = 0;
66 |
67 | /* You provide these functions. */
68 | PROTO(BOOL Read_U_b_Yup(void);)
69 | PROTO(void Write_U_b_Yup(BOOL v);)
70 |
71 |
72 | /* You provide this function. */
73 | PROTO(extern BOOL Read_U_b_Xdown(void);)
74 |
75 | STATIC BOOL I_b_oneShot_0001 = 0;
76 | #define Read_I_b_oneShot_0001() I_b_oneShot_0001
77 | #define Write_I_b_oneShot_0001(x) I_b_oneShot_0001 = x
78 | STATIC SWORD I_i_scratch = 0;
79 |
80 | /* You provide these functions. */
81 | PROTO(BOOL Read_U_b_Ydown(void);)
82 | PROTO(void Write_U_b_Ydown(BOOL v);)
83 |
84 |
85 | /* You provide this function. */
86 | PROTO(extern BOOL Read_U_b_Xres(void);)
87 |
88 | STATIC BOOL I_b_parOut_0000 = 0;
89 | #define Read_I_b_parOut_0000() I_b_parOut_0000
90 | #define Write_I_b_parOut_0000(x) I_b_parOut_0000 = x
91 | STATIC BOOL I_b_parThis_0000 = 0;
92 | #define Read_I_b_parThis_0000() I_b_parThis_0000
93 | #define Write_I_b_parThis_0000(x) I_b_parThis_0000 = x
94 | STATIC BOOL I_b_scratch = 0;
95 | #define Read_I_b_scratch() I_b_scratch
96 | #define Write_I_b_scratch(x) I_b_scratch = x
97 | STATIC BOOL I_b_oneShot_0002 = 0;
98 | #define Read_I_b_oneShot_0002() I_b_oneShot_0002
99 | #define Write_I_b_oneShot_0002(x) I_b_oneShot_0002 = x
100 | STATIC BOOL I_b_oneShot_0003 = 0;
101 | #define Read_I_b_oneShot_0003() I_b_oneShot_0003
102 | #define Write_I_b_oneShot_0003(x) I_b_oneShot_0003 = x
103 | STATIC BOOL I_b_oneShot_0004 = 0;
104 | #define Read_I_b_oneShot_0004() I_b_oneShot_0004
105 | #define Write_I_b_oneShot_0004(x) I_b_oneShot_0004 = x
106 | STATIC SWORD U_i_Ccirc = 0;
107 | STATIC SWORD I_i_scratch2 = 0;
108 | STATIC BOOL I_b_oneShot_0005 = 0;
109 | #define Read_I_b_oneShot_0005() I_b_oneShot_0005
110 | #define Write_I_b_oneShot_0005(x) I_b_oneShot_0005 = x
111 | STATIC BOOL I_b_Tpulse_antiglitch = 0;
112 | #define Read_I_b_Tpulse_antiglitch() I_b_Tpulse_antiglitch
113 | #define Write_I_b_Tpulse_antiglitch(x) I_b_Tpulse_antiglitch = x
114 | STATIC SWORD U_i_Tpulse = 0;
115 |
116 | /* You provide these functions. */
117 | PROTO(BOOL Read_U_b_Ypulse(void);)
118 | PROTO(void Write_U_b_Ypulse(BOOL v);)
119 |
120 |
121 |
122 | /* Call this function once per PLC cycle. You are responsible for calling
123 | it at the interval that you specified in the MCU configuration when you
124 | generated this code. */
125 | void PlcCycle(void)
126 | {
127 | Write_I_b_mcr(1);
128 |
129 | /* start rung 2 */
130 | Write_I_b_rung_top(Read_I_b_mcr());
131 |
132 | /* start series [ */
133 | if(!Read_U_b_Rosc()) {
134 | Write_I_b_rung_top(0);
135 | }
136 |
137 | if(!Read_I_b_Tof_antiglitch()) {
138 | U_i_Tof = 1;
139 | }
140 | Write_I_b_Tof_antiglitch(1);
141 | if(!Read_I_b_rung_top()) {
142 | if(U_i_Tof < 1) {
143 | U_i_Tof++;
144 | Write_I_b_rung_top(1);
145 | }
146 | } else {
147 | U_i_Tof = 0;
148 | }
149 |
150 | if(Read_I_b_rung_top()) {
151 | if(U_i_Ton < 1) {
152 | U_i_Ton++;
153 | Write_I_b_rung_top(0);
154 | }
155 | } else {
156 | U_i_Ton = 0;
157 | }
158 |
159 | if(Read_I_b_rung_top()) {
160 | Write_U_b_Rosc(0);
161 | } else {
162 | Write_U_b_Rosc(1);
163 | }
164 |
165 | /* ] finish series */
166 |
167 | /* start rung 3 */
168 | Write_I_b_rung_top(Read_I_b_mcr());
169 |
170 | /* start series [ */
171 | if(!Read_U_b_Rosc()) {
172 | Write_I_b_rung_top(0);
173 | }
174 |
175 | if(!Read_U_b_Xup()) {
176 | Write_I_b_rung_top(0);
177 | }
178 |
179 | if(Read_I_b_rung_top()) {
180 | if(!Read_I_b_oneShot_0000()) {
181 | U_i_Ccnt++;
182 | }
183 | }
184 | Write_I_b_oneShot_0000(Read_I_b_rung_top());
185 | if(U_i_Ccnt < 20) {
186 | Write_I_b_rung_top(0);
187 | } else {
188 | Write_I_b_rung_top(1);
189 | }
190 |
191 | if(U_i_Trto < 199) {
192 | if(Read_I_b_rung_top()) {
193 | U_i_Trto++;
194 | }
195 | Write_I_b_rung_top(0);
196 | } else {
197 | Write_I_b_rung_top(1);
198 | }
199 |
200 | Write_U_b_Yup(Read_I_b_rung_top());
201 |
202 | /* ] finish series */
203 |
204 | /* start rung 4 */
205 | Write_I_b_rung_top(Read_I_b_mcr());
206 |
207 | /* start series [ */
208 | if(!Read_U_b_Rosc()) {
209 | Write_I_b_rung_top(0);
210 | }
211 |
212 | if(!Read_U_b_Xdown()) {
213 | Write_I_b_rung_top(0);
214 | }
215 |
216 | if(Read_I_b_rung_top()) {
217 | if(!Read_I_b_oneShot_0001()) {
218 | I_i_scratch = 1;
219 | U_i_Ccnt = U_i_Ccnt - I_i_scratch;
220 | }
221 | }
222 | Write_I_b_oneShot_0001(Read_I_b_rung_top());
223 | if(U_i_Ccnt < 10) {
224 | Write_I_b_rung_top(0);
225 | } else {
226 | Write_I_b_rung_top(1);
227 | }
228 |
229 | Write_U_b_Ydown(Read_I_b_rung_top());
230 |
231 | /* ] finish series */
232 |
233 | /* start rung 5 */
234 | Write_I_b_rung_top(Read_I_b_mcr());
235 |
236 | /* start series [ */
237 | if(!Read_U_b_Xres()) {
238 | Write_I_b_rung_top(0);
239 | }
240 |
241 | /* start parallel [ */
242 | Write_I_b_parOut_0000(0);
243 | Write_I_b_parThis_0000(Read_I_b_rung_top());
244 | Write_I_b_scratch(Read_I_b_parThis_0000());
245 | if(Read_I_b_oneShot_0002()) {
246 | Write_I_b_parThis_0000(0);
247 | }
248 | Write_I_b_oneShot_0002(Read_I_b_scratch());
249 |
250 | if(Read_I_b_parThis_0000()) {
251 | Write_I_b_parOut_0000(1);
252 | }
253 | Write_I_b_parThis_0000(Read_I_b_rung_top());
254 | Write_I_b_scratch(Read_I_b_parThis_0000());
255 | if(!Read_I_b_parThis_0000()) {
256 | if(Read_I_b_oneShot_0003()) {
257 | Write_I_b_parThis_0000(1);
258 | }
259 | } else {
260 | Write_I_b_parThis_0000(0);
261 | }
262 | Write_I_b_oneShot_0003(Read_I_b_scratch());
263 |
264 | if(Read_I_b_parThis_0000()) {
265 | Write_I_b_parOut_0000(1);
266 | }
267 | Write_I_b_rung_top(Read_I_b_parOut_0000());
268 | /* ] finish parallel */
269 | if(Read_I_b_rung_top()) {
270 | U_i_Trto = 0;
271 | }
272 |
273 | /* ] finish series */
274 |
275 | /* start rung 6 */
276 | Write_I_b_rung_top(Read_I_b_mcr());
277 |
278 | /* start series [ */
279 | if(!Read_U_b_Rosc()) {
280 | Write_I_b_rung_top(0);
281 | }
282 |
283 | if(Read_I_b_rung_top()) {
284 | if(!Read_I_b_oneShot_0004()) {
285 | U_i_Ccirc++;
286 | if(U_i_Ccirc < 8) {
287 | } else {
288 | U_i_Ccirc = 0;
289 | }
290 | }
291 | }
292 | Write_I_b_oneShot_0004(Read_I_b_rung_top());
293 |
294 | /* ] finish series */
295 |
296 | /* start rung 7 */
297 | Write_I_b_rung_top(Read_I_b_mcr());
298 |
299 | /* start series [ */
300 | I_i_scratch2 = 3;
301 | if(U_i_Ccirc == I_i_scratch2) {
302 | } else {
303 | Write_I_b_rung_top(0);
304 | }
305 |
306 | Write_I_b_scratch(Read_I_b_rung_top());
307 | if(!Read_I_b_rung_top()) {
308 | if(Read_I_b_oneShot_0005()) {
309 | Write_I_b_rung_top(1);
310 | }
311 | } else {
312 | Write_I_b_rung_top(0);
313 | }
314 | Write_I_b_oneShot_0005(Read_I_b_scratch());
315 |
316 | if(!Read_I_b_Tpulse_antiglitch()) {
317 | U_i_Tpulse = 3;
318 | }
319 | Write_I_b_Tpulse_antiglitch(1);
320 | if(!Read_I_b_rung_top()) {
321 | if(U_i_Tpulse < 3) {
322 | U_i_Tpulse++;
323 | Write_I_b_rung_top(1);
324 | }
325 | } else {
326 | U_i_Tpulse = 0;
327 | }
328 |
329 | Write_U_b_Ypulse(Read_I_b_rung_top());
330 |
331 | /* ] finish series */
332 | }
333 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/TesteLadder.cpp:
--------------------------------------------------------------------------------
1 | /* This is auto-generated code from LDmicro. Do not edit this file! Go
2 | back to the ladder diagram source for changes in the logic, and make
3 | any C additions either in ladder.h or in additional .c files linked
4 | against this one. */
5 |
6 | /* You must provide ladder.h; there you must provide:
7 | * a typedef for SWORD and BOOL, signed 16 bit and boolean types
8 | (probably typedef signed short SWORD; typedef unsigned char BOOL;)
9 |
10 | You must also provide implementations of all the I/O read/write
11 | either as inlines in the header file or in another source file. (The
12 | I/O functions are all declared extern.)
13 |
14 | See the generated source code (below) for function names. */
15 | #include "ladder.h"
16 |
17 | /* Define EXTERN_EVERYTHING in ladder.h if you want all symbols extern.
18 | This could be useful to implement `magic variables,' so that for
19 | example when you write to the ladder variable duty_cycle, your PLC
20 | runtime can look at the C variable U_duty_cycle and use that to set
21 | the PWM duty cycle on the micro. That way you can add support for
22 | peripherals that LDmicro doesn't know about. */
23 | #ifdef EXTERN_EVERYTHING
24 | #define STATIC
25 | #else
26 | #define STATIC static
27 | #endif
28 |
29 | /* Define NO_PROTOTYPES if you don't want LDmicro to provide prototypes for
30 | all the I/O functions (Read_U_xxx, Write_U_xxx) that you must provide.
31 | If you define this then you must provide your own prototypes for these
32 | functions in ladder.h, or provide definitions (e.g. as inlines or macros)
33 | for them in ladder.h. */
34 | #ifdef NO_PROTOTYPES
35 | #define PROTO(x)
36 | #else
37 | #define PROTO(x) x
38 | #endif
39 |
40 | /* U_xxx symbols correspond to user-defined names. There is such a symbol
41 | for every internal relay, variable, timer, and so on in the ladder
42 | program. I_xxx symbols are internally generated. */
43 | STATIC BOOL I_b_mcr = 0;
44 | #define Read_I_b_mcr() I_b_mcr
45 | #define Write_I_b_mcr(x) I_b_mcr = x
46 | STATIC BOOL I_b_rung_top = 0;
47 | #define Read_I_b_rung_top() I_b_rung_top
48 | #define Write_I_b_rung_top(x) I_b_rung_top = x
49 | STATIC BOOL U_b_Rosc = 0;
50 | #define Read_U_b_Rosc() U_b_Rosc
51 | #define Write_U_b_Rosc(x) U_b_Rosc = x
52 | STATIC BOOL I_b_Tof_antiglitch = 0;
53 | #define Read_I_b_Tof_antiglitch() I_b_Tof_antiglitch
54 | #define Write_I_b_Tof_antiglitch(x) I_b_Tof_antiglitch = x
55 | STATIC SWORD U_i_Tof = 0;
56 | STATIC SWORD U_i_Ton = 0;
57 |
58 | /* You provide this function. */
59 | PROTO(extern BOOL Read_U_b_Xup(void);)
60 |
61 | STATIC BOOL I_b_oneShot_0000 = 0;
62 | #define Read_I_b_oneShot_0000() I_b_oneShot_0000
63 | #define Write_I_b_oneShot_0000(x) I_b_oneShot_0000 = x
64 | STATIC SWORD U_i_Ccnt = 0;
65 | STATIC SWORD U_i_Trto = 0;
66 |
67 | /* You provide these functions. */
68 | PROTO(BOOL Read_U_b_Yup(void);)
69 | PROTO(void Write_U_b_Yup(BOOL v);)
70 |
71 |
72 | /* You provide this function. */
73 | PROTO(extern BOOL Read_U_b_Xdown(void);)
74 |
75 | STATIC BOOL I_b_oneShot_0001 = 0;
76 | #define Read_I_b_oneShot_0001() I_b_oneShot_0001
77 | #define Write_I_b_oneShot_0001(x) I_b_oneShot_0001 = x
78 | STATIC SWORD I_i_scratch = 0;
79 |
80 | /* You provide these functions. */
81 | PROTO(BOOL Read_U_b_Ydown(void);)
82 | PROTO(void Write_U_b_Ydown(BOOL v);)
83 |
84 |
85 | /* You provide this function. */
86 | PROTO(extern BOOL Read_U_b_Xres(void);)
87 |
88 | STATIC BOOL I_b_parOut_0000 = 0;
89 | #define Read_I_b_parOut_0000() I_b_parOut_0000
90 | #define Write_I_b_parOut_0000(x) I_b_parOut_0000 = x
91 | STATIC BOOL I_b_parThis_0000 = 0;
92 | #define Read_I_b_parThis_0000() I_b_parThis_0000
93 | #define Write_I_b_parThis_0000(x) I_b_parThis_0000 = x
94 | STATIC BOOL I_b_scratch = 0;
95 | #define Read_I_b_scratch() I_b_scratch
96 | #define Write_I_b_scratch(x) I_b_scratch = x
97 | STATIC BOOL I_b_oneShot_0002 = 0;
98 | #define Read_I_b_oneShot_0002() I_b_oneShot_0002
99 | #define Write_I_b_oneShot_0002(x) I_b_oneShot_0002 = x
100 | STATIC BOOL I_b_oneShot_0003 = 0;
101 | #define Read_I_b_oneShot_0003() I_b_oneShot_0003
102 | #define Write_I_b_oneShot_0003(x) I_b_oneShot_0003 = x
103 | STATIC BOOL I_b_oneShot_0004 = 0;
104 | #define Read_I_b_oneShot_0004() I_b_oneShot_0004
105 | #define Write_I_b_oneShot_0004(x) I_b_oneShot_0004 = x
106 | STATIC SWORD U_i_Ccirc = 0;
107 | STATIC SWORD I_i_scratch2 = 0;
108 | STATIC BOOL I_b_oneShot_0005 = 0;
109 | #define Read_I_b_oneShot_0005() I_b_oneShot_0005
110 | #define Write_I_b_oneShot_0005(x) I_b_oneShot_0005 = x
111 | STATIC BOOL I_b_Tpulse_antiglitch = 0;
112 | #define Read_I_b_Tpulse_antiglitch() I_b_Tpulse_antiglitch
113 | #define Write_I_b_Tpulse_antiglitch(x) I_b_Tpulse_antiglitch = x
114 | STATIC SWORD U_i_Tpulse = 0;
115 |
116 | /* You provide these functions. */
117 | PROTO(BOOL Read_U_b_Ypulse(void);)
118 | PROTO(void Write_U_b_Ypulse(BOOL v);)
119 |
120 |
121 |
122 | /* Call this function once per PLC cycle. You are responsible for calling
123 | it at the interval that you specified in the MCU configuration when you
124 | generated this code. */
125 | void PlcCycle(void)
126 | {
127 | Write_I_b_mcr(1);
128 |
129 | /* start rung 2 */
130 | Write_I_b_rung_top(Read_I_b_mcr());
131 |
132 | /* start series [ */
133 | if(!Read_U_b_Rosc()) {
134 | Write_I_b_rung_top(0);
135 | }
136 |
137 | if(!Read_I_b_Tof_antiglitch()) {
138 | U_i_Tof = 1;
139 | }
140 | Write_I_b_Tof_antiglitch(1);
141 | if(!Read_I_b_rung_top()) {
142 | if(U_i_Tof < 1) {
143 | U_i_Tof++;
144 | Write_I_b_rung_top(1);
145 | }
146 | } else {
147 | U_i_Tof = 0;
148 | }
149 |
150 | if(Read_I_b_rung_top()) {
151 | if(U_i_Ton < 1) {
152 | U_i_Ton++;
153 | Write_I_b_rung_top(0);
154 | }
155 | } else {
156 | U_i_Ton = 0;
157 | }
158 |
159 | if(Read_I_b_rung_top()) {
160 | Write_U_b_Rosc(0);
161 | } else {
162 | Write_U_b_Rosc(1);
163 | }
164 |
165 | /* ] finish series */
166 |
167 | /* start rung 3 */
168 | Write_I_b_rung_top(Read_I_b_mcr());
169 |
170 | /* start series [ */
171 | if(!Read_U_b_Rosc()) {
172 | Write_I_b_rung_top(0);
173 | }
174 |
175 | if(!Read_U_b_Xup()) {
176 | Write_I_b_rung_top(0);
177 | }
178 |
179 | if(Read_I_b_rung_top()) {
180 | if(!Read_I_b_oneShot_0000()) {
181 | U_i_Ccnt++;
182 | }
183 | }
184 | Write_I_b_oneShot_0000(Read_I_b_rung_top());
185 | if(U_i_Ccnt < 20) {
186 | Write_I_b_rung_top(0);
187 | } else {
188 | Write_I_b_rung_top(1);
189 | }
190 |
191 | if(U_i_Trto < 199) {
192 | if(Read_I_b_rung_top()) {
193 | U_i_Trto++;
194 | }
195 | Write_I_b_rung_top(0);
196 | } else {
197 | Write_I_b_rung_top(1);
198 | }
199 |
200 | Write_U_b_Yup(Read_I_b_rung_top());
201 |
202 | /* ] finish series */
203 |
204 | /* start rung 4 */
205 | Write_I_b_rung_top(Read_I_b_mcr());
206 |
207 | /* start series [ */
208 | if(!Read_U_b_Rosc()) {
209 | Write_I_b_rung_top(0);
210 | }
211 |
212 | if(!Read_U_b_Xdown()) {
213 | Write_I_b_rung_top(0);
214 | }
215 |
216 | if(Read_I_b_rung_top()) {
217 | if(!Read_I_b_oneShot_0001()) {
218 | I_i_scratch = 1;
219 | U_i_Ccnt = U_i_Ccnt - I_i_scratch;
220 | }
221 | }
222 | Write_I_b_oneShot_0001(Read_I_b_rung_top());
223 | if(U_i_Ccnt < 10) {
224 | Write_I_b_rung_top(0);
225 | } else {
226 | Write_I_b_rung_top(1);
227 | }
228 |
229 | Write_U_b_Ydown(Read_I_b_rung_top());
230 |
231 | /* ] finish series */
232 |
233 | /* start rung 5 */
234 | Write_I_b_rung_top(Read_I_b_mcr());
235 |
236 | /* start series [ */
237 | if(!Read_U_b_Xres()) {
238 | Write_I_b_rung_top(0);
239 | }
240 |
241 | /* start parallel [ */
242 | Write_I_b_parOut_0000(0);
243 | Write_I_b_parThis_0000(Read_I_b_rung_top());
244 | Write_I_b_scratch(Read_I_b_parThis_0000());
245 | if(Read_I_b_oneShot_0002()) {
246 | Write_I_b_parThis_0000(0);
247 | }
248 | Write_I_b_oneShot_0002(Read_I_b_scratch());
249 |
250 | if(Read_I_b_parThis_0000()) {
251 | Write_I_b_parOut_0000(1);
252 | }
253 | Write_I_b_parThis_0000(Read_I_b_rung_top());
254 | Write_I_b_scratch(Read_I_b_parThis_0000());
255 | if(!Read_I_b_parThis_0000()) {
256 | if(Read_I_b_oneShot_0003()) {
257 | Write_I_b_parThis_0000(1);
258 | }
259 | } else {
260 | Write_I_b_parThis_0000(0);
261 | }
262 | Write_I_b_oneShot_0003(Read_I_b_scratch());
263 |
264 | if(Read_I_b_parThis_0000()) {
265 | Write_I_b_parOut_0000(1);
266 | }
267 | Write_I_b_rung_top(Read_I_b_parOut_0000());
268 | /* ] finish parallel */
269 | if(Read_I_b_rung_top()) {
270 | U_i_Trto = 0;
271 | }
272 |
273 | /* ] finish series */
274 |
275 | /* start rung 6 */
276 | Write_I_b_rung_top(Read_I_b_mcr());
277 |
278 | /* start series [ */
279 | if(!Read_U_b_Rosc()) {
280 | Write_I_b_rung_top(0);
281 | }
282 |
283 | if(Read_I_b_rung_top()) {
284 | if(!Read_I_b_oneShot_0004()) {
285 | U_i_Ccirc++;
286 | if(U_i_Ccirc < 8) {
287 | } else {
288 | U_i_Ccirc = 0;
289 | }
290 | }
291 | }
292 | Write_I_b_oneShot_0004(Read_I_b_rung_top());
293 |
294 | /* ] finish series */
295 |
296 | /* start rung 7 */
297 | Write_I_b_rung_top(Read_I_b_mcr());
298 |
299 | /* start series [ */
300 | I_i_scratch2 = 3;
301 | if(U_i_Ccirc == I_i_scratch2) {
302 | } else {
303 | Write_I_b_rung_top(0);
304 | }
305 |
306 | Write_I_b_scratch(Read_I_b_rung_top());
307 | if(!Read_I_b_rung_top()) {
308 | if(Read_I_b_oneShot_0005()) {
309 | Write_I_b_rung_top(1);
310 | }
311 | } else {
312 | Write_I_b_rung_top(0);
313 | }
314 | Write_I_b_oneShot_0005(Read_I_b_scratch());
315 |
316 | if(!Read_I_b_Tpulse_antiglitch()) {
317 | U_i_Tpulse = 3;
318 | }
319 | Write_I_b_Tpulse_antiglitch(1);
320 | if(!Read_I_b_rung_top()) {
321 | if(U_i_Tpulse < 3) {
322 | U_i_Tpulse++;
323 | Write_I_b_rung_top(1);
324 | }
325 | } else {
326 | U_i_Tpulse = 0;
327 | }
328 |
329 | Write_U_b_Ypulse(Read_I_b_rung_top());
330 |
331 | /* ] finish series */
332 | }
333 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/expected/contacts.hex:
--------------------------------------------------------------------------------
1 | :020000040000FA
2 | :100000008A110A1208280000000000000000000009
3 | :10001000283084005830A0008001840AA00B0C28EE
4 | :10002000103095002730960000308E0000308F0091
5 | :10003000013090000B309700831686309F008312AA
6 | :10004000003085008316DF30850083120030860083
7 | :100050008316FF3086008312003087008316FC3041
8 | :10006000870083120C1D32280C116400A914A918F2
9 | :100070002915A91C291105183E2829112919071429
10 | :10008000291D0710A9182915A91C2911A911291919
11 | :100090002916291D291285184E282912291E512892
12 | :1000A000A91529192916291D2912051958282912B7
13 | :1000B000291E5B28A915A9192915A91D2911291D72
14 | :1000C00062288516A9182915A91C291185196928DE
15 | :1000D0002911051E6C282911A91229192917291D72
16 | :1000E0002913291F74288512291F7728A916291971
17 | :1000F0002917291D2913291F7F2887108028871475
18 | :10010000291F8328A916A91A2915A91E29118A01B0
19 | :02011000322893
20 | :02400E00723FFF
21 | :00000001FF
22 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/expected/integers.hex:
--------------------------------------------------------------------------------
1 | :1000000022C0189518951895189518951895189553
2 | :100010001895189518951895189518951895189578
3 | :100020001895189518951895189518951895189568
4 | :100030001895189518951895189518951895189558
5 | :10004000189518951895B0E0AEE504E00C93B0E073
6 | :10005000ADE50FEF0C93B5E0A0E000E020E034E068
7 | :10006000A150B0400C93215030402223C9F73323D4
8 | :10007000B9F7B0E0AAE304E00C93B0E0ABE300E032
9 | :100080000C93B0E0A7E300E00C93B0E0A8E301E03C
10 | :100090000C93B0E0A4E300E00C93B0E0A5E300E033
11 | :1000A0000C93B0E0A1E300E40C93B0E0A2E300E025
12 | :1000B0000C93B0E0A6E200E00C93B0E0A7E200E011
13 | :1000C0000C93B0E0AFE400E00C93B0E0AEE40AE0E3
14 | :1000D0000C93B0E0ABE404EF0C93B0E0AAE402E2CE
15 | :1000E0000C93B0E0A9E500E40C93B0E0A8E50C9116
16 | :1000F00006FFFBCFB0E0A8E50C9100640C93A89537
17 | :10010000B1E0A1E00C9102600C93B1E0A1E00C9190
18 | :10011000B1E0A1E01C9101FF1B7F01FD14601C9365
19 | :10012000B1E0A1E00C91077F0C93B1E0A1E00C914C
20 | :10013000B1E0A1E01C9102FF1F7E02FD10611C9343
21 | :10014000B0E0A6E30C9100FD05C0B1E0A1E00C9188
22 | :100150000F7E0C93B1E0A1E00C9104FF08C0B1E068
23 | :10016000A2E00BE20C93B1E0A3E005E00C93B1E058
24 | :10017000A1E00C9104FF05C0B1E0A1E00C91086082
25 | :100180000C93B1E0A1E00C91B1E0A1E01C9102FF61
26 | :100190001F7E02FD10611C93B0E0A6E30C9100FFEE
27 | :1001A00005C0B1E0A1E00C910F7E0C93B1E0A1E09D
28 | :1001B0000C9104FF08C0B1E0A2E004EF0C93B1E0A1
29 | :1001C000A3E00FEF0C93B1E0A1E00C9104FF05C098
30 | :1001D000B1E0A1E00C9108600C93B1E0A1E00C91BA
31 | :1001E000B1E0A1E01C9103FF1B7F03FD14601C9391
32 | :1001F000B1E0A1E00C91B1E0A1E01C9101FF1B7FF7
33 | :1002000001FD14601C93B1E0A1E00C910F7D0C93F3
34 | :10021000B1E0A1E00C91B1E0A1E01C9102FF1F7BD5
35 | :1002200002FD10641C93B1E0A1E00C9106FF1CC01C
36 | :10023000B1E0A4E008EE0C93B1E0A5E003E00C937C
37 | :10024000B1E0A2E02C91B1E0A3E03C91B1E0A4E0E8
38 | :100250000C91B1E0A5E01C91200F311FB1E0A6E0A8
39 | :100260002C93B1E0A7E03C93B1E0A1E00C9106FF34
40 | :1002700005C0B1E0A1E00C9100620C93B1E0A1E0F7
41 | :100280000C91B1E0A1E01C9102FF1F7B02FD106404
42 | :100290001C93B1E0A1E00C9106FF1CC0B1E0A4E00A
43 | :1002A00005E00C93B1E0A5E000E00C93B1E0A2E022
44 | :1002B0002C91B1E0A3E03C91B1E0A4E00C91B1E05D
45 | :1002C000A5E01C91201B310BB1E0A8E02C93B1E01C
46 | :1002D000A9E03C93B1E0A1E00C9106FF05C0B1E0BC
47 | :1002E000A1E00C9100620C93B1E0A1E00C91B1E0AF
48 | :1002F000A1E01C9102FF1F7B02FD10641C93B1E082
49 | :10030000A1E00C9106FF1DC0B1E0A4E003E00C9356
50 | :10031000B1E0A5E000E00C93B1E0A2E02C91B1E0E7
51 | :10032000A3E03C91B1E0A4E00C91B1E0A5E01C9108
52 | :10033000ECEEF3E00995B1E0AAE02C93B1E0ABE07C
53 | :100340003C93B1E0A1E00C9106FF05C0B1E0A1E053
54 | :100350000C9100620C93B1E0A1E00C91B1E0A1E03E
55 | :100360001C9102FF1F7B02FD10641C93B1E0A1E011
56 | :100370000C9106FF1DC0B1E0A4E003E00C93B1E0D6
57 | :10038000A5E000E00C93B1E0A4E02C91B1E0A5E081
58 | :100390003C91B1E0AAE00C91B1E0ABE01C91EDEF33
59 | :1003A000F3E00995B1E0ACE00C93B1E0ADE01C9353
60 | :1003B000B1E0A1E00C9106FF05C0B1E0A1E00C9115
61 | :1003C00000620C93B1E0A1E00C91B1E0A1E01C91BE
62 | :1003D00005FF1B7F05FD14601C93B1E0A1E00C91AB
63 | :1003E000B1E0A1E01C9101FF1B7F01FD14601C9393
64 | :1003F000B1E0A1E00C910F770C93B1E0A1E00C917A
65 | :10040000B1E0AEE01C9102FF1E7F02FD11601C9363
66 | :10041000B1E0A4E00BE20C93B1E0A5E005E00C93A1
67 | :10042000B1E0A2E00C91B1E0A3E01C91B1E0A4E046
68 | :100430002C91B1E0A5E03C910217130709F405C027
69 | :10044000B1E0AEE00C910E7F0C93B1E0AEE00C9108
70 | :1004500000FF05C0B1E0A1E00C9100680C93B1E091
71 | :10046000A1E00C91B1E0AEE01C9102FF1E7F02FD05
72 | :1004700011601C93B1E0AEE00C9100FF05C0B1E04B
73 | :10048000A1E00C9100680C93B1E0A1E00C91B1E007
74 | :10049000A1E01C9107FF1B7F07FD14601C93B1E0D6
75 | :1004A000AEE00C910D7F0C93B1E0A1E00C91B1E0B6
76 | :1004B000AEE01C9102FF1B7F02FD14601C93B1E0B3
77 | :1004C000A4E000E00C93B1E0A5E000E00C93B1E003
78 | :1004D000A4E00C91B1E0A5E01C91B1E0A6E02C9164
79 | :1004E000B1E0A7E03C91201731070CF405C0B1E062
80 | :1004F000AEE00C910B7F0C93B1E0AEE00C9102FFEB
81 | :1005000005C0B1E0AEE00C9102600C93B1E0A1E057
82 | :100510000C91B1E0AEE01C9102FF1B7F02FD146064
83 | :100520001C93B1E0A4E006E20C93B1E0A5E005E085
84 | :100530000C93B1E0A8E00C91B1E0A9E01C91B1E00E
85 | :10054000A4E02C91B1E0A5E03C91201731072CF4F8
86 | :10055000B1E0AEE00C910B7F0C93B1E0AEE00C91FA
87 | :1005600002FF05C0B1E0AEE00C9102600C93B1E077
88 | :10057000A1E00C91B1E0AEE01C9102FF1B7F02FDF7
89 | :1005800014601C93B1E0AEE00C9102FF05C0B1E035
90 | :10059000AEE00C9102600C93B1E0AEE00C91B1E0E2
91 | :1005A000A1E01C9101FF1B7F01FD14601C93B1E0D1
92 | :1005B000AEE00C91077F0C93B1E0A1E00C91B1E0AB
93 | :1005C000AEE01C9102FF1F7E02FD10611C93B1E0A2
94 | :1005D000A4E000E20C93B1E0A5E00EE40C93B1E0DE
95 | :1005E000A6E00C91B1E0A7E01C91B1E0A4E02C9151
96 | :1005F000B1E0A5E03C91201731070CF405C0B1E053
97 | :10060000AEE00C910F7E0C93B1E0AEE00C9104FFD4
98 | :1006100005C0B1E0AEE00C9108600C93B1E0A1E040
99 | :100620000C91B1E0AEE01C9102FF1F7E02FD106153
100 | :100630001C93B1E0A4E001E80C93B1E0A5E00FE069
101 | :100640000C93B1E0A4E00C91B1E0A5E01C91B1E005
102 | :10065000AAE02C91B1E0ABE03C91201731072CF4DB
103 | :10066000B1E0AEE00C910F7E0C93B1E0AEE00C91E6
104 | :1006700004FF05C0B1E0AEE00C9108600C93B1E05E
105 | :10068000A1E00C91B1E0AEE01C9102FF1F7E02FDE3
106 | :1006900010611C93B1E0AEE00C910F7E0C93B1E0C1
107 | :1006A000AEE00C9104FF05C0B1E0AEE00C91086033
108 | :1006B0000C93B1E0AEE00C91B1E0A1E01C9103FF1E
109 | :1006C0001B7F03FD14601C93B1E0A1E00C91B0E02E
110 | :1006D000ABE31C9102FF1B7F02FD14601C93B1E091
111 | :1006E000A1E00C91B1E0A1E01C9101FF1B7F01FD95
112 | :1006F00014601C93B1E0A4E00CED0C93B1E0A5E014
113 | :100700000FEF0C93B1E0AAE00C91B1E0ABE01C91CB
114 | :10071000B1E0A4E02C91B1E0A5E03C9102171307F1
115 | :1007200029F4B1E0A1E00C910B7F0C93B1E0A4E0BF
116 | :1007300000E00C93B1E0A5E000E00C93B1E0A2E092
117 | :100740000C91B1E0A3E01C91B1E0A4E02C91B1E0E8
118 | :10075000A5E03C91201731070CF405C0B1E0A1E001
119 | :100760000C910B7F0C93B1E0A1E00C9102FF1EC035
120 | :10077000B1E0AFE00C91B1E0A0E11C9123E130E0E9
121 | :100780000217130794F4B1E0AFE00C91B1E0A0E1DF
122 | :100790001C91039509F413951C93B1E0AFE00C9301
123 | :1007A000B1E0A1E00C910B7F0C9308C0B1E0AFE089
124 | :1007B00000E00C93B1E0A0E100E00C93B1E0A1E017
125 | :1007C0000C91B0E0A2E31C9102FF1F7B02FD1064BC
126 | :1007D0001C93E5E7F0E00994551B441B60E110F41D
127 | :1007E000400F511F20FD401B20FD510B5595479593
128 | :1007F000379527956A9599F70895D12ED32617FF37
129 | :1008000004C0109500950F5F1F4F37FF04C030954F
130 | :1008100020952F5F3F4FEE24FF1841E1001F111F6D
131 | :100820004A9539F4D7FE04C0109500950F5F1F4F0D
132 | :100830000895EE1CFF1CE21AF30A20F4E20EF31EE8
133 | :080840008894ECCF0894EACF84
134 | :00000001FF
135 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/expected/misc-ops.hex:
--------------------------------------------------------------------------------
1 | :020000040000FA
2 | :100000008A110A1208280000000000000000000009
3 | :10001000283084005830A0008001840AA00B0C28EE
4 | :10002000103095002730960000308E0000308F0091
5 | :10003000013090000B309700831686309F008312AA
6 | :10004000003085008316FD30850083120030860065
7 | :100050008316FF3086008312003087008316FD3040
8 | :10006000870083120C1D32280C116400A914A918F2
9 | :100070002915A91C291105183E282911A91842285B
10 | :10008000A91446282919A914291DA910A918291548
11 | :10009000A91C2911A9194D282911291D64280030EE
12 | :1000A0002B0203195A28A00020092B05A006A01B2B
13 | :1000B0005F28632831302A02031C5F286328AA0FB7
14 | :1000C0006228AB0A291168280030AA000030AB0072
15 | :1000D000291A6E283130AC000030AD0029162919DC
16 | :1000E000862800302D0203197C28A00020092D0548
17 | :1000F000A006A01B8128852831302C02031C8128F2
18 | :100100008528AC0F8428AD0A29158A280030AC0058
19 | :100110000030AD00291D8E28A9118F28A915A91816
20 | :100120002915A91C2911A91996282911291DB228B8
21 | :10013000A91AB2283008AE003108AF003208B0006A
22 | :100140003308B1003408B2003508B3003608B400F3
23 | :100150003708B5003808B6003908B7003A08B800C3
24 | :100160003B08B9002919A916291DA912A918291592
25 | :10017000A91C291129132919A917291DA913A91F78
26 | :10018000D82851309F00831680309F00831206309C
27 | :10019000A100A10BC9281F151F19CC281E08BD00DE
28 | :1001A00083161E088312BC00831686309F008312BC
29 | :1001B000A91FDB2829172919A917291DA913A91F68
30 | :1001C000E5283C08BA003D08BB00A91FE82829170C
31 | :1001D000291B2915291F2911A9182915A91C29111D
32 | :1001E0003E102919BE14291DBE10A919F828BE10E9
33 | :1001F000BE1C14293E191429BF0FFF28C00A003065
34 | :10020000400203190A29A00020094005A006A01BEE
35 | :100210000F29102905303F02031C0F29102914292A
36 | :100220000030BF000030C000BE183E15BE1C3E119D
37 | :10023000BE1C1B293E142919BE14291DBE10BE1C4C
38 | :1002400071290030C1000030C2003F084102031D87
39 | :10025000312940084202031D31290A30C300003011
40 | :10026000C4000130C1000030C2003F084102031D3C
41 | :10027000412940084202031D41294630C300003095
42 | :10028000C4000230C1000030C2003F084102031D1B
43 | :10029000512940084202031D51295030C30000304B
44 | :1002A000C4000330C1000030C2003F084102031DFA
45 | :1002B000612940084202031D61294630C300003015
46 | :1002C000C4000430C1000030C2003F084102031DD9
47 | :1002D000712940084202031D71290A30C300003011
48 | :1002E000C400BE1C74293E142919BE14291DBE1059
49 | :1002F000BE1C9E294308A000A1016430A200A301F6
50 | :1003000001308A00BB2101308A002308A1002208A5
51 | :10031000A0006430A200A30101308A00D221013084
52 | :100320008A0020089B00BE199E29BE1583166330E3
53 | :10033000920083120C309D0004309200BE1CA12953
54 | :100340003E143E1829153E1C2911A9182915A91C6F
55 | :100350002911A918AD29A914B1292919A914291DF0
56 | :10036000A910A9182915A91C291129198514291DB5
57 | :1003700085108A013228A501A4010310A30CA20C48
58 | :100380001030A600031CCA292008A4070318A50AD8
59 | :100390002108A5070310A50CA40CA30CA20CA60B06
60 | :1003A000C229080021082306A700A31FDC29A209EF
61 | :1003B000A309A20A0319A30AA11FE329A009A109FD
62 | :1003C000A00A0319A10AA501A40103101130A60077
63 | :1003D000A00DA10DA6030319012AA40DA50D220845
64 | :1003E000A402031CA5032308A502A51FFF292208B8
65 | :1003F000A4070318A50A2308A5070310E829031476
66 | :10040000E829A71F0800A009A109A00A0319A10A49
67 | :020410000800E2
68 | :02400E00723FFF
69 | :00000001FF
70 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/expected/pic16-hw.hex:
--------------------------------------------------------------------------------
1 | :020000040000FA
2 | :100000008A110A1208280000000000000000000009
3 | :10001000283084005830A0008001840AA00B0C28EE
4 | :10002000103095002730960000308E0000308F0091
5 | :10003000013090000B309700831686309F008312AA
6 | :10004000003085008316FF30850083120030860063
7 | :100050008316FF3086008312003087008316FD3040
8 | :1000600087008312003088008316FF3088008312D7
9 | :1000700000308900831607308900831283161930F7
10 | :1000800099008312831620309800831290309800D4
11 | :100090000C1D48280C116400A914A9182915A91CC5
12 | :1000A0002911291DD928A91989282912831603176E
13 | :1000B0008C186F2883120313291C722803178D0ACA
14 | :1000C0000313280803178C0083168C130C15553066
15 | :1000D0008D00AA308D008C14831203132910831213
16 | :1000E00003132916291A8928A915031700308D0032
17 | :1000F00083168C130C1483120C080313AA00031725
18 | :1001000001308D0083168C130C1483120C0803131A
19 | :10011000AB002912831603178C18A328831203132C
20 | :10012000291CA62803178D0A0313280803178C001F
21 | :1001300083168C130C1555308D00AA308D008C144D
22 | :10014000831203132910831203132916291AD9289D
23 | :10015000031700308D0083168C130C1483120C08C7
24 | :100160000313AC00031701308D0083168C130C149D
25 | :1001700083120C080313AD002C082A02031DC528A6
26 | :100180002D082B02031DC528D92829142B08A800E7
27 | :10019000031700308D0003132A0803178C00831601
28 | :1001A0008C130C1555308D00AA308D008C148312E1
29 | :1001B0000313A9182915A91C2911291DF62849304E
30 | :1001C0009F00831680309F0083120630A100A10B90
31 | :1001D000E7281F151F19EA281E08AF0083161E08FE
32 | :1001E0008312AE00831686309F008312A91829154A
33 | :1001F000A91C2911A91229192917291D2913051824
34 | :1002000002292913291F0529A91629192917291D8A
35 | :1002100029130030B0000230B1003109A1002F05D0
36 | :10022000A0002F08A104A10931082F0203192129D8
37 | :10023000A105A200220920052104A206A21B26294D
38 | :10024000272930082E02031C262927292913291FB4
39 | :100250002A29A916A91A2915A91E29112919291609
40 | :10026000291D2912A91F35292911291AA917291E63
41 | :10027000A913291D4A290130B0000030B1002A0815
42 | :100280003007AA002010031820142B083107AB00F8
43 | :100290002018AB0AA9182915A91C291132102919EF
44 | :1002A000B214291DB2100A30B0000030B10031097B
45 | :1002B000A1002B05A0002B08A104A10931082B02E5
46 | :1002C00003196B29A105A200220920052104A20619
47 | :1002D000A21B7029712930082A02031C7029712978
48 | :1002E0007229B210B21C78291430B3000030B40067
49 | :1002F000B21C7B2932142919B214291DB2100A30FC
50 | :10030000B0000030B1003109A1002B05A0002B087E
51 | :10031000A104A10931082B0203199729A105A20004
52 | :10032000220920052104A206A21B9C299D29300830
53 | :100330002A02031C9C299D29B210B21CA329323029
54 | :10034000B3000030B400B21CA62932142919B2142B
55 | :10035000291DB210B21CD0293308A000A1017D30A4
56 | :10036000A200A30105308A00812501308A002308FC
57 | :10037000A1002208A0006430A200A30105308A0079
58 | :10038000982501308A0020089B003219D0293215A7
59 | :1003900083167C30920083120C309D000530920051
60 | :1003A000B21CD329321432182915321C2911A9186C
61 | :1003B0002915A91C2911291DF2290030360203191B
62 | :1003C000E829A00020093605A006A01BED29F12987
63 | :1003D00063303502031CED29F129B50FF029B60A67
64 | :1003E0002911F6290030B5000030B6002919291668
65 | :1003F000291D2912B21DFD292911291AB215291EFC
66 | :10040000B211291D092A321A092A0030B70000301A
67 | :10041000B80029193216291D32123708B9003808D8
68 | :10042000BA000030380203191C2AA0002009380540
69 | :10043000A006A01B212A222A10303702031C212AE1
70 | :10044000222A262AFF30B900FF30BA002912291EBD
71 | :100450002B2A2C089900291283169818312A831206
72 | :1004600029168312291E382AFF30B900FF30BA003E
73 | :100470000030AC000030AD002C083902031D482AC2
74 | :100480002D083A02031D482A7330B0000030B10035
75 | :100490000130AC000030AD002C083902031D582A91
76 | :1004A0002D083A02031D582A6130B0000030B10017
77 | :1004B0000230AC000030AD002C083902031D682A60
78 | :1004C0002D083A02031D682A7630B0000030B100D2
79 | :1004D0000330AC000030AD002C083902031D782A2F
80 | :1004E0002D083A02031D782A6530B0000030B100B3
81 | :1004F0000430AC000030AD002C083902031D882AFE
82 | :100500002D083A02031D882A6430B0000030B10083
83 | :100510000530AC000030AD002C083902031D982ACC
84 | :100520002D083A02031D982A2030B0000030B10097
85 | :100530000630AC000030AD002C083902031DA82A9B
86 | :100540002D083A02031DA82A3D30B0000030B1004A
87 | :100550000730AC000030AD002C083902031DB82A6A
88 | :100560002D083A02031DB82A2030B0000030B10037
89 | :100570000830AC000030AD0029122C083902031DF0
90 | :10058000C62A2D083A02031DC62A2916291EF32A57
91 | :100590002A08BB002B08BC002030B0000030B1009E
92 | :1005A00000302B020319DB2AA00020092B05A0062E
93 | :1005B000A01BE02AF32A00302A02031CE02AF32AB7
94 | :1005C0002D30B0000030B1000030AC000030AD0084
95 | :1005D0002A082C02BB002010031820142B082D021F
96 | :1005E000BC00201CBC030930AC000030AD00291257
97 | :1005F0002C083902031D012B2D083A02031D012B83
98 | :100600002916291E542BB2161030AC002730AD002D
99 | :100610003B08A0003C08A1002C08A2002D08A30064
100 | :1006200005308A00982503308A002008B000210890
101 | :10063000B1002C08A0002D08A1003008A20031084C
102 | :10064000A30005308A00812503308A002208AC000F
103 | :100650002308AD002C083B02BB0020100318201417
104 | :100660002D083C02BC00201CBC033030AC00003024
105 | :10067000AD0030082C07B0002010031820143108FA
106 | :100680002D07B1002018B10A2C083002031D532B8E
107 | :100690002D083102031D532BB21E522B2030B00007
108 | :1006A0000030B100542BB2120A30AC000030AD0063
109 | :1006B00029122C083902031D622B2D083A02031D52
110 | :1006C000622B2916291EB42BE830AC000330AD0094
111 | :1006D0003B08A0003C08A1002C08A2002D08A300A4
112 | :1006E00005308A00982503308A002008B0002108D0
113 | :1006F000B1002C08A0002D08A1003008A20031088C
114 | :10070000A30005308A00812503308A002208AC004E
115 | :100710002308AD002C083B02BB0020100318201456
116 | :100720002D083C02BC00201CBC033030AC00003063
117 | :10073000AD0030082C07B000201003182014310839
118 | :100740002D07B1002018B10A2C083002031DB32B6D
119 | :100750002D083102031DB32BB21EB22B2030B00086
120 | :100760000030B100B42BB2120B30AC000030AD0041
121 | :1007700029122C083902031DC22B2D083A02031D31
122 | :10078000C22B2916291E142C6430AC000030AD0099
123 | :100790003B08A0003C08A1002C08A2002D08A300E3
124 | :1007A00005308A00982503308A002008B00021080F
125 | :1007B000B1002C08A0002D08A1003008A2003108CB
126 | :1007C000A30005308A00812503308A002208AC008E
127 | :1007D0002308AD002C083B02BB0020100318201496
128 | :1007E0002D083C02BC00201CBC033030AC000030A3
129 | :1007F000AD0030082C07B000201003182014310879
130 | :100800002D07B1002018B10A2C083002031D132C4B
131 | :100810002D083102031D132CB21E122C2030B00003
132 | :100820000030B100142CB2120C30AC000030AD001E
133 | :1008300029122C083902031D222C2D083A02031D0F
134 | :10084000222C2916291E742C0A30AC000030AD0071
135 | :100850003B08A0003C08A1002C08A2002D08A30022
136 | :1008600005308A00982504308A002008B00021084D
137 | :10087000B1002C08A0002D08A1003008A20031080A
138 | :10088000A30005308A00812504308A002208AC00CC
139 | :100890002308AD002C083B02BB00201003182014D5
140 | :1008A0002D083C02BC00201CBC033030AC000030E2
141 | :1008B000AD0030082C07B0002010031820143108B8
142 | :1008C0002D07B1002018B10A2C083002031D732C2B
143 | :1008D0002D083102031D732CB21E722C2030B00083
144 | :1008E0000030B100742CB2120D30AC000030AD00FD
145 | :1008F00029122C083902031D822C2D083A02031DEF
146 | :10090000822C2916291EC42C0130AC000030AD0009
147 | :100910003B08A0003C08A1002C08A2002D08A30061
148 | :1009200005308A00982504308A002008B00021088C
149 | :10093000B1002C08A0002D08A1003008A200310849
150 | :10094000A30005308A00812504308A002208AC000B
151 | :100950002308AD002C083B02BB0020100318201414
152 | :100960002D083C02BC00201CBC033030AC00003021
153 | :10097000AD0030082C07B0002010031820143108F7
154 | :100980002D07B1002018B10A0E30AC000030AD00C8
155 | :100990002C083902031DD42C2D083A02031DD42C37
156 | :1009A0000D30B0000030B1000F30AC000030AD00B1
157 | :1009B0002C083902031DE42C2D083A02031DE42CF7
158 | :1009C0000A30B0000030B10000303A020319EF2CB9
159 | :1009D000A00020093A05A006A01BF42CF52C00303D
160 | :1009E0003902031CF42CF52C042D2916291EFA2C8F
161 | :1009F00030089900291283169818002D83122916A1
162 | :100A00008312B70F042DB80A2911003038020319D8
163 | :100A1000102DA00020093805A006A01B152D162DAD
164 | :100A200010303702031C152D162D2915A91829156C
165 | :100A3000A91C2911291D202D7830BD000030BE00D1
166 | :100A4000A9182915A91C2911291D3B2D0030400288
167 | :100A50000319312DA00020094005A006A01B362D4A
168 | :100A60003A2DC7303F02031C362D3A2DBF0F392DCA
169 | :100A7000C00A29113F2D0030BF000030C0002919E5
170 | :100A80002916291D2912321F462D2911291A32171C
171 | :100A9000291E3213291D4E2D3D0899002911831658
172 | :100AA0009818542D831229158312A9182915A91CE9
173 | :100AB0002911291D6B2D29118C1E6B2D1A08C100BF
174 | :100AC000C20129159818672D1819672D6B2D1A0862
175 | :100AD0001A08181218166130B0000030B100410831
176 | :100AE0003002031D782D42083102031D782D792D27
177 | :100AF0002911291D7F2D0030AA000030AB008A018A
178 | :100B00004828A501A4010310A30CA20C1030A600D4
179 | :100B1000031C902D2008A4070318A50A2108A50787
180 | :100B20000310A50CA40CA30CA20CA60B882D080086
181 | :100B300021082306A700A31FA22DA209A309A20A28
182 | :100B40000319A30AA11FA92DA009A109A00A03192D
183 | :100B5000A10AA501A40103101130A600A00DA10D4A
184 | :100B6000A6030319C72DA40DA50D2208A402031C7A
185 | :100B7000A5032308A502A51FC52D2208A407031855
186 | :100B8000A50A2308A5070310AE2D0314AE2DA71F39
187 | :0E0B90000800A009A109A00A0319A10A080083
188 | :02400E00723FFF
189 | :00000001FF
190 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/expected/timers-counters.hex:
--------------------------------------------------------------------------------
1 | :1000000022C0189518951895189518951895189553
2 | :100010001895189518951895189518951895189578
3 | :100020001895189518951895189518951895189568
4 | :100030001895189518951895189518951895189558
5 | :10004000189518951895B0E0AEE500E10C93B0E076
6 | :10005000ADE50FEF0C93B1E1A0E000E020E030E16E
7 | :10006000A150B0400C93215030402223C9F73323D4
8 | :10007000B9F7B0E0AAE300E20C93B0E0ABE300E034
9 | :100080000C93B0E0A7E300E00C93B0E0A8E300E03D
10 | :100090000C93B0E0A4E300E00C93B0E0A5E300E033
11 | :1000A0000C93B0E0A1E304E00C93B0E0A2E300E025
12 | :1000B0000C93B0E0A2E200E00C93B0E0A3E207E012
13 | :1000C0000C93B0E0A1E600E20C93B0E0A2E600E001
14 | :1000D0000C93B0E0A4E600E00C93B0E0A5E600E0ED
15 | :1000E0000C93B0E0AFE400E00C93B0E0AEE409E0C4
16 | :1000F0000C93B0E0ABE40CE90C93B0E0AAE40EE39F
17 | :100100000C93B0E0A7E500E10C93B0E0A6E50C91FC
18 | :1001100004FFFBCFB0E0A6E50C9100610C93A8951D
19 | :10012000B1E0A1E00C9102600C93B1E0A1E00C9170
20 | :10013000B1E0A1E01C9101FF1B7F01FD14601C9345
21 | :10014000B1E0A1E00C9103FD05C0B1E0A1E00C918C
22 | :100150000B7F0C93B1E0A1E00C9104FD08C0B1E06D
23 | :10016000A2E009E00C93B1E0A3E000E00C93B1E061
24 | :10017000A1E00C9100610C93B1E0A1E00C9102FDB3
25 | :100180001EC0B1E0A2E00C91B1E0A3E01C9129E017
26 | :1001900030E00217130794F4B1E0A2E00C91B1E053
27 | :1001A000A3E01C91039509F413951C93B1E0A2E020
28 | :1001B0000C93B1E0A1E00C9104600C9308C0B1E095
29 | :1001C000A2E000E00C93B1E0A3E000E00C93B1E00A
30 | :1001D000A1E00C9102FF1EC0B1E0A4E00C91B1E0DF
31 | :1001E000A5E01C9129E030E00217130794F4B1E078
32 | :1001F000A4E00C91B1E0A5E01C91039509F41395DE
33 | :100200001C93B1E0A4E00C93B1E0A1E00C910B7F52
34 | :100210000C9308C0B1E0A4E000E00C93B1E0A5E0CD
35 | :1002200000E00C93B1E0A1E00C9102FF06C0B1E048
36 | :10023000A1E00C91077F0C9305C0B1E0A1E00C9107
37 | :1002400008600C93B1E0A1E00C91B1E0A1E01C9139
38 | :1002500001FF1B7F01FD14601C93B1E0A1E00C9134
39 | :1002600003FD05C0B1E0A1E00C910B7F0C93B0E061
40 | :10027000A1E20C9102FD05C0B1E0A1E00C910B7F61
41 | :100280000C93B1E0A1E00C9102FF12C0B1E0A1E03B
42 | :100290000C9105FD0DC0B1E0A6E00C91B1E0A7E026
43 | :1002A0001C91039509F413951C93B1E0A6E00C93FF
44 | :1002B000B1E0A1E00C91B1E0A1E01C9102FF1F7D33
45 | :1002C00002FD10621C93B1E0A6E00C91B1E0A7E042
46 | :1002D0001C9124E130E00217130734F4B1E0A1E0EF
47 | :1002E0000C910B7F0C9305C0B1E0A1E00C91046070
48 | :1002F0000C93B1E0A8E00C91B1E0A9E01C9127EECD
49 | :1003000033E002171307C4F4B1E0A1E00C9102FF3F
50 | :100310000DC0B1E0A8E00C91B1E0A9E01C910395FB
51 | :1003200009F413951C93B1E0A8E00C93B1E0A1E0AF
52 | :100330000C910B7F0C9305C0B1E0A1E00C9104601F
53 | :100340000C93B1E0A1E00C91B0E0A2E61C9102FF99
54 | :100350001F7D02FD10621C93B1E0A1E00C91B1E0A1
55 | :10036000A1E01C9101FF1B7F01FD14601C93B1E013
56 | :10037000A1E00C9103FD05C0B1E0A1E00C910B7F61
57 | :100380000C93B0E0A1E20C9100FD05C0B1E0A1E04A
58 | :100390000C910B7F0C93B1E0A1E00C9102FF21C006
59 | :1003A000B1E0A1E00C9106FD1CC0B1E0AAE001E0C3
60 | :1003B0000C93B1E0ABE000E00C93B1E0A6E02C912F
61 | :1003C000B1E0A7E03C91B1E0AAE00C91B1E0ABE074
62 | :1003D0001C91201B310BB1E0A6E02C93B1E0A7E00B
63 | :1003E0003C93B1E0A1E00C91B1E0A1E01C9102FFCF
64 | :1003F0001F7B02FD10641C93B1E0A6E00C91B1E0FC
65 | :10040000A7E01C912AE030E00217130734F4B1E0B2
66 | :10041000A1E00C910B7F0C9305C0B1E0A1E00C9121
67 | :1004200004600C93B1E0A1E00C91B0E0A2E31C9158
68 | :1004300002FF1B7F02FD14601C93B1E0A1E00C9150
69 | :10044000B1E0A1E01C9101FF1B7F01FD14601C9332
70 | :10045000B0E0A1E20C9101FD05C0B1E0A1E00C917A
71 | :100460000B7F0C93B1E0A1E00C910F770C93B1E0FE
72 | :10047000A1E00C91B1E0ACE01C9102FF1E7F02FDF7
73 | :1004800011601C93B1E0ACE00C91B1E0ACE01C91C8
74 | :1004900000FF1D7F00FD12601C93B1E0ACE00C91E9
75 | :1004A00002FF05C0B1E0ACE00C910E7F0C93B1E00F
76 | :1004B000ACE00C91B1E0ACE01C9101FF1B7F01FDB1
77 | :1004C00014601C93B1E0ACE00C9100FF05C0B1E0FA
78 | :1004D000A1E00C9100680C93B1E0A1E00C91B1E0B7
79 | :1004E000ACE01C9102FF1E7F02FD11601C93B1E085
80 | :1004F000ACE00C91B1E0ACE01C9100FF1D7F00FD71
81 | :1005000012601C93B1E0ACE00C9100FD0BC0B1E0B7
82 | :10051000ACE00C9103FF05C0B1E0ACE00C910160D0
83 | :100520000C9305C0B1E0ACE00C910E7F0C93B1E0F0
84 | :10053000ACE00C91B1E0ACE01C9101FF177F01FD34
85 | :1005400018601C93B1E0ACE00C9100FF05C0B1E075
86 | :10055000A1E00C9100680C93B1E0A1E00C91B1E036
87 | :10056000A1E01C9107FF1B7F07FD14601C93B1E005
88 | :10057000A1E00C9102FF08C0B1E0A8E000E00C93FC
89 | :10058000B1E0A9E000E00C93B1E0A1E00C91B1E092
90 | :10059000A1E01C9101FF1B7F01FD14601C93B1E0E1
91 | :1005A000A1E00C9103FD05C0B1E0A1E00C910B7F2F
92 | :1005B0000C93B1E0A1E00C9102FF26C0B1E0ACE0E9
93 | :1005C0000C9104FD21C0B1E0ADE00C91B1E0AEE0D2
94 | :1005D0001C91039509F413951C93B1E0ADE00C93C5
95 | :1005E000B1E0ADE00C91B1E0AEE01C9128E030E06C
96 | :1005F000021713070CF408C0B1E0ADE000E00C9363
97 | :10060000B1E0AEE000E00C93B1E0A1E00C91B1E00C
98 | :10061000ACE01C9102FF1F7E02FD10611C93B1E053
99 | :10062000A1E00C91B1E0A1E01C9101FF1B7F01FD55
100 | :1006300014601C93B1E0AFE003E00C93B1E0A0E1E3
101 | :1006400000E00C93B1E0ADE00C91B1E0AEE01C91A4
102 | :10065000B1E0AFE02C91B1E0A0E13C9102171307AB
103 | :1006600009F405C0B1E0A1E00C910B7F0C93B1E05F
104 | :10067000A1E00C91B1E0ACE01C9102FF1D7F02FDF6
105 | :1006800012601C93B1E0A1E00C9102FD0BC0B1E03F
106 | :10069000ACE00C9105FF05C0B1E0A1E00C91046055
107 | :1006A0000C9305C0B1E0A1E00C910B7F0C93B1E07D
108 | :1006B000ACE00C91B1E0ACE01C9101FF1F7D01FDAD
109 | :1006C00010621C93B1E0ACE00C9106FD08C0B1E0F3
110 | :1006D000A1E103E10C93B1E0A2E100E00C93B1E0F1
111 | :1006E000ACE00C9100640C93B1E0A1E00C9102FD30
112 | :1006F0001EC0B1E0A1E10C91B1E0A2E11C9123E1A7
113 | :1007000030E00217130794F4B1E0A1E10C91B1E0DD
114 | :10071000A2E11C91039509F413951C93B1E0A1E1AA
115 | :100720000C93B1E0A1E00C9104600C9308C0B1E01F
116 | :10073000A1E100E00C93B1E0A2E100E00C93B1E094
117 | :10074000A1E00C91B0E0ABE31C9102FF1F7D02FD24
118 | :0A07500010621C93E5E8F0E0099444
119 | :00000001FF
120 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/go.bat:
--------------------------------------------------------------------------------
1 | @perl run-tests.pl
2 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/run-tests.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | if (not -d 'results/') {
4 | mkdir 'results';
5 | }
6 |
7 | $c = 0;
8 | for $test () {
9 | $output = $test;
10 | $output =~ s/^tests/results/;
11 | $output =~ s/\.ld$/.hex/;
12 |
13 | unlink $output;
14 |
15 | $cmd = "../ldmicro.exe /c $test $output";
16 | system $cmd;
17 | $c++;
18 | }
19 |
20 | print "\ndifferences follow:\n";
21 | @diff = `diff -q results expected`;
22 | for(@diff) {
23 | print " $_";
24 | }
25 | $fc = scalar @diff;
26 | print "($fc difference(s)/$c)\n";
27 | if($fc == 0) {
28 | print "pass!\n";
29 | exit(0);
30 | } else {
31 | print "FAIL\n";
32 | exit(-1);
33 | }
34 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/avr-hw.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Atmel AVR ATmega128 64-TQFP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\avr-hw.hex
7 |
8 | IO LIST
9 | Xinc at 2
10 | Aanalog at 61
11 | END
12 |
13 | PROGRAM
14 | RUNG
15 | COMMENT The more hardware-oriented ops (PWM, ADC, UART, EEPROM), test for the\r\nAVRs.
16 | END
17 | RUNG
18 | PERSIST saved
19 | END
20 | RUNG
21 | READ_ADC Aanalog
22 | END
23 | RUNG
24 | PARALLEL
25 | CONTACTS Xinc 0
26 | GEQ Aanalog 512
27 | END
28 | OSR
29 | ADD saved saved 1
30 | END
31 | RUNG
32 | PARALLEL
33 | SERIES
34 | LES saved 10
35 | MOVE duty 20
36 | END
37 | SERIES
38 | GEQ saved 10
39 | MOVE duty 50
40 | END
41 | SET_PWM duty 2000
42 | END
43 | END
44 | RUNG
45 | TON Tfmtd 1000000
46 | OSR
47 | FORMATTED_STRING saved 15 115 97 118 101 100 32 61 32 92 45 53 92 114 92 110
48 | END
49 | RUNG
50 | MOVE char 'x'
51 | END
52 | RUNG
53 | TON Tutx 2000000
54 | OSR
55 | UART_SEND char
56 | END
57 | RUNG
58 | UART_RECV inchar
59 | EQU inchar 'a'
60 | MOVE saved 0
61 | END
62 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/contacts.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F876 28-PDIP or 28-SOIC
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\contacts.hex
7 |
8 | IO LIST
9 | Xa at 2
10 | Xb at 3
11 | Xc at 4
12 | Xd at 5
13 | Xe at 6
14 | Yf at 11
15 | Yg at 7
16 | Yh at 12
17 | END
18 |
19 | PROGRAM
20 | RUNG
21 | COMMENT All types of contacts (NO, NC), and all types of coils (normal, inverted, set,\r\nreset); also test series and parallel combinations.
22 | END
23 | RUNG
24 | CONTACTS Xa 0
25 | COIL Yf 0 0 0
26 | END
27 | RUNG
28 | PARALLEL
29 | CONTACTS Xb 0
30 | CONTACTS Xc 0
31 | END
32 | COIL Yg 0 1 0
33 | END
34 | RUNG
35 | CONTACTS Xd 0
36 | CONTACTS Xe 1
37 | PARALLEL
38 | COIL Yg 0 0 1
39 | COIL Yh 1 0 0
40 | END
41 | END
42 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/integers.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Atmel AVR ATmega162 40-PDIP
3 | CYCLE=50000
4 | CRYSTAL=10000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\integers.hex
7 |
8 | IO LIST
9 | Xa at 1
10 | Yno at 16
11 | Yok at 37
12 | END
13 |
14 | PROGRAM
15 | RUNG
16 | COMMENT Test integer variable manipulations: move, arithmetic, comparison. Also test\r\na 50 ms cycle time, and the ATmega162 (odd timer register locations).
17 | END
18 | RUNG
19 | PARALLEL
20 | SERIES
21 | CONTACTS Xa 0
22 | MOVE a 1323
23 | END
24 | SERIES
25 | CONTACTS Xa 1
26 | MOVE a -12
27 | END
28 | END
29 | END
30 | RUNG
31 | PARALLEL
32 | ADD c a 1000
33 | SUB d a 5
34 | MUL e a 3
35 | DIV f e 3
36 | END
37 | END
38 | RUNG
39 | PARALLEL
40 | EQU a 1323
41 | SHORT
42 | END
43 | PARALLEL
44 | LES c 0
45 | LEQ d 1318
46 | SHORT
47 | END
48 | SHORT
49 | PARALLEL
50 | GRT c 20000
51 | GEQ e 3969
52 | OPEN
53 | END
54 | COIL Yok 0 0 0
55 | END
56 | RUNG
57 | NEQ e -36
58 | GRT a 0
59 | TON Ton 1000000
60 | COIL Yno 0 0 0
61 | END
62 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/misc-ops.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F876 28-PDIP or 28-SOIC
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\misc-ops.hex
7 |
8 | IO LIST
9 | Xon at 2
10 | Yalways at 3
11 | Ain at 4
12 | END
13 |
14 | PROGRAM
15 | RUNG
16 | COMMENT Little things: shift register, look-up table, master control relay.\r\n
17 | END
18 | RUNG
19 | CONTACTS Xon 0
20 | MASTER_RELAY
21 | END
22 | RUNG
23 | CONTACTS Rosc 0
24 | TON Ton 500000
25 | TOF Tof 500000
26 | COIL Rosc 1 0 0
27 | END
28 | RUNG
29 | CONTACTS Rosc 0
30 | SHIFT_REGISTER reg 7
31 | END
32 | RUNG
33 | PARALLEL
34 | READ_ADC Ain
35 | MOVE reg0 Ain
36 | END
37 | END
38 | RUNG
39 | PARALLEL
40 | SERIES
41 | CONTACTS Rosc 0
42 | CTC Ci 4
43 | END
44 | LOOK_UP_TABLE duty Ci 5 0 10 70 80 70 10
45 | SET_PWM duty 10000
46 | END
47 | END
48 | RUNG
49 | MASTER_RELAY
50 | END
51 | RUNG
52 | COIL Yalways 0 0 0
53 | END
54 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/pic16-hw.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F877 40-PDIP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\pic-hw.hex
7 |
8 | IO LIST
9 | Xinc at 2
10 | Aanalog at 3
11 | END
12 |
13 | PROGRAM
14 | RUNG
15 | COMMENT The more hardware-oriented ops (PWM, ADC, UART, EEPROM), test for the\r\nPIC16s.
16 | END
17 | RUNG
18 | PERSIST saved
19 | END
20 | RUNG
21 | READ_ADC Aanalog
22 | END
23 | RUNG
24 | PARALLEL
25 | CONTACTS Xinc 0
26 | GEQ Aanalog 512
27 | END
28 | OSR
29 | ADD saved saved 1
30 | END
31 | RUNG
32 | PARALLEL
33 | SERIES
34 | LES saved 10
35 | MOVE duty 20
36 | END
37 | SERIES
38 | GEQ saved 10
39 | MOVE duty 50
40 | END
41 | SET_PWM duty 2000
42 | END
43 | END
44 | RUNG
45 | TON Tfmtd 1000000
46 | OSR
47 | FORMATTED_STRING saved 15 115 97 118 101 100 32 61 32 92 45 53 92 114 92 110
48 | END
49 | RUNG
50 | MOVE char 'x'
51 | END
52 | RUNG
53 | TON Tutx 2000000
54 | OSR
55 | UART_SEND char
56 | END
57 | RUNG
58 | UART_RECV inchar
59 | EQU inchar 'a'
60 | MOVE saved 0
61 | END
62 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/reg/tests/timers-counters.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Atmel AVR ATmega128 64-TQFP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=C:\depot\ldmicro\reg\expected\timers-counters.ld
7 |
8 | IO LIST
9 | Xdown at 2
10 | Xres at 3
11 | Xup at 4
12 | Ydown at 27
13 | Ypulse at 46
14 | Yup at 56
15 | END
16 |
17 | PROGRAM
18 | RUNG
19 | COMMENT Test all the timers (TON, TOF, RTO) and counters (CTC, CTU, CTD), and the\r\nreset (RES) instruction. Also test one-shots.
20 | END
21 | RUNG
22 | CONTACTS Rosc 0
23 | TOF Tof 100000
24 | TON Ton 100000
25 | COIL Rosc 1 0 0
26 | END
27 | RUNG
28 | CONTACTS Rosc 0
29 | CONTACTS Xup 0
30 | CTU Ccnt 20
31 | RTO Trto 10000000
32 | COIL Yup 0 0 0
33 | END
34 | RUNG
35 | CONTACTS Rosc 0
36 | CONTACTS Xdown 0
37 | CTD Ccnt 10
38 | COIL Ydown 0 0 0
39 | END
40 | RUNG
41 | CONTACTS Xres 0
42 | PARALLEL
43 | OSR
44 | OSF
45 | END
46 | RES Trto
47 | END
48 | RUNG
49 | CONTACTS Rosc 0
50 | CTC Ccirc 7
51 | END
52 | RUNG
53 | EQU Ccirc 3
54 | OSF
55 | TOF Tpulse 200000
56 | COIL Ypulse 0 0 0
57 | END
58 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/resetdialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // Dialog for setting the properties of a set of a RES reset element: name,
21 | // which can be that of either a timer or a counter.
22 | // Jonathan Westhues, Nov 2004
23 | //-----------------------------------------------------------------------------
24 | #include
25 | #include
26 | #include
27 |
28 | #include "ldmicro.h"
29 |
30 | static HWND ResetDialog;
31 |
32 | static HWND TypeTimerRadio;
33 | static HWND TypeCounterRadio;
34 | static HWND NameTextbox;
35 |
36 | static LONG_PTR PrevNameProc;
37 |
38 | //-----------------------------------------------------------------------------
39 | // Don't allow any characters other than A-Za-z0-9_ in the name.
40 | //-----------------------------------------------------------------------------
41 | static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam,
42 | LPARAM lParam)
43 | {
44 | if(msg == WM_CHAR) {
45 | if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
46 | wParam == '\b'))
47 | {
48 | return 0;
49 | }
50 | }
51 |
52 | return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
53 | }
54 |
55 | static void MakeControls(void)
56 | {
57 | HWND grouper = CreateWindowEx(0, WC_BUTTON, _("Type"),
58 | WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
59 | 7, 3, 120, 65, ResetDialog, NULL, Instance, NULL);
60 | NiceFont(grouper);
61 |
62 | TypeTimerRadio = CreateWindowEx(0, WC_BUTTON, _("Timer"),
63 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
64 | 16, 21, 100, 20, ResetDialog, NULL, Instance, NULL);
65 | NiceFont(TypeTimerRadio);
66 |
67 | TypeCounterRadio = CreateWindowEx(0, WC_BUTTON, _("Counter"),
68 | WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
69 | 16, 41, 100, 20, ResetDialog, NULL, Instance, NULL);
70 | NiceFont(TypeCounterRadio);
71 |
72 | HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Name:"),
73 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
74 | 135, 16, 50, 21, ResetDialog, NULL, Instance, NULL);
75 | NiceFont(textLabel);
76 |
77 | NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
78 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
79 | 190, 16, 115, 21, ResetDialog, NULL, Instance, NULL);
80 | FixedFont(NameTextbox);
81 |
82 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
83 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
84 | 321, 10, 70, 23, ResetDialog, NULL, Instance, NULL);
85 | NiceFont(OkButton);
86 |
87 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
88 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
89 | 321, 40, 70, 23, ResetDialog, NULL, Instance, NULL);
90 | NiceFont(CancelButton);
91 |
92 | PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
93 | (LONG_PTR)MyNameProc);
94 | }
95 |
96 | void ShowResetDialog(char *name)
97 | {
98 | ResetDialog = CreateWindowClient(0, "LDmicroDialog",
99 | _("Reset"), WS_OVERLAPPED | WS_SYSMENU,
100 | 100, 100, 404, 75, NULL, NULL, Instance, NULL);
101 |
102 | MakeControls();
103 |
104 | if(name[0] == 'T') {
105 | SendMessage(TypeTimerRadio, BM_SETCHECK, BST_CHECKED, 0);
106 | } else {
107 | SendMessage(TypeCounterRadio, BM_SETCHECK, BST_CHECKED, 0);
108 | }
109 | SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1));
110 |
111 | EnableWindow(MainWindow, FALSE);
112 | ShowWindow(ResetDialog, TRUE);
113 | SetFocus(NameTextbox);
114 | SendMessage(NameTextbox, EM_SETSEL, 0, -1);
115 |
116 | MSG msg;
117 | DWORD ret;
118 | DialogDone = FALSE;
119 | DialogCancel = FALSE;
120 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
121 | if(msg.message == WM_KEYDOWN) {
122 | if(msg.wParam == VK_RETURN) {
123 | DialogDone = TRUE;
124 | break;
125 | } else if(msg.wParam == VK_ESCAPE) {
126 | DialogDone = TRUE;
127 | DialogCancel = TRUE;
128 | break;
129 | }
130 | }
131 |
132 | if(IsDialogMessage(ResetDialog, &msg)) continue;
133 | TranslateMessage(&msg);
134 | DispatchMessage(&msg);
135 | }
136 |
137 | if(!DialogCancel) {
138 | if(SendMessage(TypeTimerRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
139 | name[0] = 'T';
140 | } else {
141 | name[0] = 'C';
142 | }
143 | SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(name+1));
144 | }
145 |
146 | EnableWindow(MainWindow, TRUE);
147 | DestroyWindow(ResetDialog);
148 | }
149 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/7seg-display.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | CYCLE=5000
3 | CRYSTAL=4000000
4 | BAUD=2400
5 |
6 | IO LIST
7 | Ycom_digit0 at 0
8 | Ycom_digit1 at 0
9 | Ycom_digit2 at 0
10 | Yseg_a at 0
11 | Yseg_b at 0
12 | Yseg_c at 0
13 | Yseg_d at 0
14 | Yseg_e at 0
15 | Yseg_f at 0
16 | Yseg_g at 0
17 | END
18 |
19 | PROGRAM
20 | RUNG
21 | COMMENT Sample program: how to drive a multiplexed 7-segment LED display. This is\r\nfor a 3-digit common-cathode display but it is easy to modify.
22 | END
23 | RUNG
24 | COMMENT With a 5 ms cycle time, this will oscillate at 100 Hz, which should be\r\nokay (33 Hz refresh rate, 1/3 duty cycle).
25 | END
26 | RUNG
27 | CONTACTS Rdosc 1
28 | COIL Rdosc 0 0 0
29 | END
30 | RUNG
31 | CONTACTS Rdosc 0
32 | CTC Cdigit 2
33 | END
34 | RUNG
35 | COMMENT Use the Ycom_digitx lines to drive the base/gate of the NPN transistor/\r\nn-FET used to switch the cathode of digit x.
36 | END
37 | RUNG
38 | PARALLEL
39 | SERIES
40 | EQU Cdigit 0
41 | PARALLEL
42 | COIL Ycom_digit0 0 0 0
43 | MOVE digit digit0
44 | END
45 | END
46 | SERIES
47 | EQU Cdigit 1
48 | PARALLEL
49 | COIL Ycom_digit1 0 0 0
50 | MOVE digit digit1
51 | END
52 | END
53 | SERIES
54 | EQU Cdigit 2
55 | PARALLEL
56 | COIL Ycom_digit2 0 0 0
57 | MOVE digit digit2
58 | END
59 | END
60 | END
61 | END
62 | RUNG
63 | COMMENT You can drive the segment pins of the display directly from the GPIO pins,\r\nYseg_a to Yseg_b.
64 | END
65 | RUNG
66 | PARALLEL
67 | SERIES
68 | NEQ digit 1
69 | NEQ digit 4
70 | COIL Yseg_a 0 0 0
71 | END
72 | SERIES
73 | NEQ digit 5
74 | NEQ digit 6
75 | COIL Yseg_b 0 0 0
76 | END
77 | SERIES
78 | NEQ digit 2
79 | COIL Yseg_c 0 0 0
80 | END
81 | SERIES
82 | NEQ digit 1
83 | NEQ digit 4
84 | NEQ digit 7
85 | COIL Yseg_d 0 0 0
86 | END
87 | SERIES
88 | PARALLEL
89 | EQU digit 0
90 | EQU digit 2
91 | EQU digit 6
92 | EQU digit 8
93 | END
94 | COIL Yseg_e 0 0 0
95 | END
96 | SERIES
97 | NEQ digit 1
98 | NEQ digit 2
99 | NEQ digit 3
100 | NEQ digit 7
101 | COIL Yseg_f 0 0 0
102 | END
103 | SERIES
104 | NEQ digit 0
105 | NEQ digit 1
106 | NEQ digit 7
107 | COIL Yseg_g 0 0 0
108 | END
109 | END
110 | END
111 | RUNG
112 | COMMENT Fill in your program here; just set the output that you want on digit0,\r\ndigit1, and digit2.
113 | END
114 | RUNG
115 | PARALLEL
116 | MOVE digit0 1
117 | MOVE digit1 8
118 | MOVE digit2 5
119 | END
120 | END
121 | RUNG
122 | COMMENT by Jonathan Westhues, June 2005
123 | END
124 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/blink.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F877 40-PDIP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | COMPILED=C:\depot\ldmicro\pic.hex
6 |
7 | IO LIST
8 | Xbutton at 21
9 | Yled at 30
10 | END
11 |
12 | PROGRAM
13 | RUNG
14 | CONTACTS Xbutton 1
15 | CTC Cwhich 4
16 | END
17 | RUNG
18 | CONTACTS Xbutton 1
19 | OSF
20 | TOF Tdblclk 500000
21 | COIL Rdblclk 0 0 0
22 | END
23 | RUNG
24 | CONTACTS Xbutton 1
25 | CONTACTS Rdblclk 0
26 | MOVE Cwhich 3
27 | END
28 | RUNG
29 | CONTACTS Rfast 0
30 | TOF Tffast 100000
31 | TON Tnfast 100000
32 | COIL Rfast 1 0 0
33 | END
34 | RUNG
35 | CONTACTS Rslow 0
36 | TON Tnslow 100000
37 | TOF Tfslow 1000000
38 | COIL Rslow 1 0 0
39 | END
40 | RUNG
41 | PARALLEL
42 | SERIES
43 | EQU Cwhich 0
44 | CONTACTS Rfast 0
45 | END
46 | SERIES
47 | EQU Cwhich 1
48 | CONTACTS Rslow 0
49 | END
50 | SERIES
51 | EQU Cwhich 2
52 | CONTACTS Rslow 1
53 | END
54 | EQU Cwhich 3
55 | SERIES
56 | EQU Cwhich 4
57 | OPEN
58 | END
59 | END
60 | COIL Yled 0 0 0
61 | END
62 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/pic-adc.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F877 40-PDIP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=c:\temp\asd.hex
7 |
8 | IO LIST
9 | Xlimit at 2
10 | Yled at 22
11 | Ain at 3
12 | END
13 |
14 | PROGRAM
15 | RUNG
16 | COMMENT Serial/ADC test program for PIC16F877: read an ADC input, convert from integer to string\r\n(three ASCII chars), then send it out over the serial port. Display a message at startup:
17 | END
18 | RUNG
19 | PARALLEL
20 | SERIES
21 | EQU Cinit 2
22 | MOVE initc 'a'
23 | END
24 | SERIES
25 | EQU Cinit 3
26 | MOVE initc 'd'
27 | END
28 | SERIES
29 | EQU Cinit 4
30 | MOVE initc 'c'
31 | END
32 | SERIES
33 | PARALLEL
34 | EQU Cinit 0
35 | EQU Cinit 5
36 | END
37 | MOVE initc 13
38 | END
39 | SERIES
40 | PARALLEL
41 | EQU Cinit 1
42 | EQU Cinit 6
43 | END
44 | MOVE initc 10
45 | END
46 | END
47 | END
48 | RUNG
49 | TON Ttod 500000
50 | CONTACTS Rinitdone 1
51 | CONTACTS Rtxbusy 1
52 | UART_SEND initc
53 | COIL Rtxbusy 0 0 0
54 | END
55 | RUNG
56 | CONTACTS Rtxbusy 0
57 | CTU Cinit 7
58 | COIL Rinitdone 0 0 0
59 | END
60 | RUNG
61 | COMMENT Clock for the ADC read and a circular counter that sequences it. Just block the\r\noscillator until the init sequence completes.
62 | END
63 | RUNG
64 | CONTACTS Rinitdone 0
65 | CONTACTS Rosc 1
66 | TOF Tct1 50000
67 | TON Tct2 50000
68 | COIL Rosc 0 0 0
69 | END
70 | RUNG
71 | CONTACTS Rosc 0
72 | CTC Cchar 4
73 | END
74 | RUNG
75 | OSR
76 | MOVE Cchar 3
77 | END
78 | RUNG
79 | COMMENT Read the A/D input, then saturate the input so that we only have to display three digits.
80 | END
81 | RUNG
82 | PARALLEL
83 | READ_ADC Ain
84 | SERIES
85 | LEQ Ain 999
86 | MOVE intval Ain
87 | END
88 | SERIES
89 | GEQ Ain 1000
90 | MOVE intval 999
91 | END
92 | END
93 | END
94 | RUNG
95 | COMMENT Split the integer into the ones, tens, and hundreds digits. This is just cumbersome, but\r\nit does not waste much memory (the multiply and divide are subroutines in the PIC code).
96 | END
97 | RUNG
98 | PARALLEL
99 | DIV hundreds intval 100
100 | MUL hundredsv hundreds 100
101 | SUB wohundreds intval hundredsv
102 | DIV tens wohundreds 10
103 | MUL tensv tens 10
104 | SUB ones wohundreds tensv
105 | END
106 | END
107 | RUNG
108 | COMMENT Now convert the ones, tens, and hundreds digits to ASCII characters by adding\r\nASCII character '0' (since the ASCII digits are contiguous in order).
109 | END
110 | RUNG
111 | PARALLEL
112 | ADD hunc hundreds '0'
113 | ADD tensc tens '0'
114 | ADD onesc ones '0'
115 | END
116 | END
117 | RUNG
118 | COMMENT Then send out the characters. For each line we must send out five characters:\r\nhundreds, tens, ones, ones, carriage return, newline; use a CTC to sequence.
119 | END
120 | RUNG
121 | PARALLEL
122 | SERIES
123 | EQU Cchar 0
124 | MOVE outch hunc
125 | END
126 | SERIES
127 | EQU Cchar 1
128 | MOVE outch tensc
129 | END
130 | SERIES
131 | EQU Cchar 2
132 | MOVE outch onesc
133 | END
134 | SERIES
135 | EQU Cchar 3
136 | MOVE outch 13
137 | END
138 | SERIES
139 | EQU Cchar 4
140 | MOVE outch 10
141 | END
142 | END
143 | END
144 | RUNG
145 | COMMENT Time it off Rosc (10 characters/s) which is slow so ignore the busy out.
146 | END
147 | RUNG
148 | CONTACTS Rosc 0
149 | OSR
150 | UART_SEND outch
151 | END
152 | RUNG
153 | PARALLEL
154 | CONTACTS Rosc 0
155 | CONTACTS Xlimit 1
156 | END
157 | COIL Yled 0 0 0
158 | END
159 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/serial.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Microchip PIC16F877 40-PDIP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | BAUD=2400
6 | COMPILED=c:\temp\ser.hex
7 |
8 | IO LIST
9 | Yled at 22
10 | END
11 |
12 | PROGRAM
13 | RUNG
14 | CONTACTS Rosc 1
15 | TOF Tct1 250000
16 | TON Tct2 250000
17 | COIL Rosc 0 0 0
18 | END
19 | RUNG
20 | CONTACTS Rfast 1
21 | TOF Tct3 100000
22 | TON Tct4 100000
23 | COIL Rfast 0 0 0
24 | END
25 | RUNG
26 | CONTACTS Rosc 0
27 | CTC Cwhich 4
28 | END
29 | RUNG
30 | PARALLEL
31 | SERIES
32 | EQU Cwhich 0
33 | MOVE ch 'A'
34 | END
35 | SERIES
36 | EQU Cwhich 1
37 | MOVE ch 'b'
38 | END
39 | SERIES
40 | EQU Cwhich 2
41 | MOVE ch 'c'
42 | END
43 | SERIES
44 | EQU Cwhich 3
45 | MOVE ch 13
46 | END
47 | SERIES
48 | EQU Cwhich 4
49 | MOVE ch 10
50 | END
51 | END
52 | END
53 | RUNG
54 | CONTACTS Rosc 0
55 | OSF
56 | UART_SEND ch
57 | END
58 | RUNG
59 | UART_RECV inch
60 | COIL Rjustgot 0 1 0
61 | END
62 | RUNG
63 | CONTACTS Rjustgot 0
64 | TON Tnew 1000000
65 | COIL Rjustgot 0 0 1
66 | END
67 | RUNG
68 | PARALLEL
69 | SERIES
70 | CONTACTS Rjustgot 0
71 | CONTACTS Rfast 0
72 | END
73 | SERIES
74 | CONTACTS Rjustgot 1
75 | PARALLEL
76 | SERIES
77 | EQU inch 'o'
78 | SHORT
79 | END
80 | SERIES
81 | EQU inch 'b'
82 | CONTACTS Rosc 0
83 | END
84 | SERIES
85 | SHORT
86 | OPEN
87 | END
88 | END
89 | END
90 | END
91 | COIL Yled 0 0 0
92 | END
93 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/traffic.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | MICRO=Atmel AVR ATmega128 64-TQFP
3 | CYCLE=10000
4 | CRYSTAL=4000000
5 | COMPILED=C:\depot\ldmicro\out.hex
6 |
7 | IO LIST
8 | Xbutton1 at 46
9 | Xbutton2 at 45
10 | Ygreen at 49
11 | Yred at 51
12 | Ywait at 48
13 | Yyellow at 50
14 | END
15 |
16 | PROGRAM
17 | RUNG
18 | CONTACTS Rclock 1
19 | TOF Ton 500000
20 | TON Toff 500000
21 | COIL Rclock 0 0 0
22 | END
23 | RUNG
24 | CONTACTS Rclock 0
25 | CTC Ccycle 19
26 | END
27 | RUNG
28 | GEQ Ccycle 0
29 | LES Ccycle 8
30 | COIL Yred 0 0 0
31 | END
32 | RUNG
33 | GEQ Ccycle 8
34 | LES Ccycle 12
35 | COIL Yyellow 0 0 0
36 | END
37 | RUNG
38 | GEQ Ccycle 12
39 | LES Ccycle 20
40 | PARALLEL
41 | COIL Ygreen 0 0 0
42 | COIL Rwait 0 0 1
43 | END
44 | END
45 | RUNG
46 | PARALLEL
47 | CONTACTS Xbutton1 1
48 | CONTACTS Xbutton2 1
49 | END
50 | PARALLEL
51 | SERIES
52 | GEQ Ccycle 0
53 | LES Ccycle 6
54 | MOVE cycle 6
55 | END
56 | COIL Rwait 0 1 0
57 | END
58 | END
59 | RUNG
60 | CONTACTS Rwait 0
61 | PARALLEL
62 | SERIES
63 | GEQ Ccycle 8
64 | LES Ccycle 12
65 | CONTACTS Rclock 0
66 | END
67 | SERIES
68 | GEQ Ccycle 0
69 | LES Ccycle 8
70 | END
71 | END
72 | COIL Ywait 0 0 0
73 | END
74 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/sample/var-timer.ld:
--------------------------------------------------------------------------------
1 | LDmicro0.1
2 | CYCLE=10000
3 | CRYSTAL=4000000
4 | BAUD=2400
5 |
6 | IO LIST
7 | Xin at 0
8 | Yout at 0
9 | Apot at 0
10 | END
11 |
12 | PROGRAM
13 | RUNG
14 | COMMENT This is the actual variable-delay TOF timer. When Rdel_input goes high, Rdel_output goes high \r\nt_max cycle times later. When Rdel_input goes low, Rdel_output goes low immediately.
15 | END
16 | RUNG
17 | CONTACTS Rdel_input 0
18 | LEQ t_count t_max
19 | ADD t_count t_count 1
20 | END
21 | RUNG
22 | CONTACTS Rdel_input 1
23 | MOVE t_count 0
24 | END
25 | RUNG
26 | COMMENT The extra branch is to make a delay of 0 cycles work correctly.
27 | END
28 | RUNG
29 | PARALLEL
30 | GRT t_count t_max
31 | SERIES
32 | CONTACTS Rdel_input 0
33 | EQU t_max 0
34 | END
35 | END
36 | COIL Rdel_output 0 0 0
37 | END
38 | RUNG
39 | COMMENT \r\n
40 | END
41 | RUNG
42 | COMMENT This is just an example of how to use the timer. The voltage attached to Apot (which goes\r\nfrom 0 V to Vdd) sets the delay between when Xin goes high and when Yout goes high.
43 | END
44 | RUNG
45 | READ_ADC Apot
46 | END
47 | RUNG
48 | COMMENT This only works with a cycle time of 10 ms. If we want the delay to be between 0 s and 5 s,\r\nthen it should be 0 to 500 cycle times; the ADC goes from 0 to 1023, so (roughly) divide by 2.
49 | END
50 | RUNG
51 | DIV t_max Apot 2
52 | END
53 | RUNG
54 | COMMENT Then just hook up the input and the output of the timer to pins. Of course\r\nthat could drive more complicated logic, not just a pin on the processor.
55 | END
56 | RUNG
57 | CONTACTS Xin 0
58 | COIL Rdel_input 0 0 0
59 | END
60 | RUNG
61 | CONTACTS Rdel_output 0
62 | COIL Yout 0 0 0
63 | END
64 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/simpledialog.cpp:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // Copyright 2007 Jonathan Westhues
3 | //
4 | // This file is part of LDmicro.
5 | //
6 | // LDmicro is free software: you can redistribute it and/or modify
7 | // it under the terms of the GNU General Public License as published by
8 | // the Free Software Foundation, either version 3 of the License, or
9 | // (at your option) any later version.
10 | //
11 | // LDmicro is distributed in the hope that it will be useful,
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | // GNU General Public License for more details.
15 | //
16 | // You should have received a copy of the GNU General Public License
17 | // along with LDmicro. If not, see .
18 | //------
19 | //
20 | // All the simple dialogs that just require a row of text boxes: timer name
21 | // and delay, counter name and count, move and arithmetic destination and
22 | // operands. Try to reuse code a bit.
23 | // Jonathan Westhues, Nov 2004
24 | //-----------------------------------------------------------------------------
25 | #include
26 | #include
27 | #include
28 | #include
29 |
30 | #include "ldmicro.h"
31 |
32 | static HWND SimpleDialog;
33 |
34 | #define MAX_BOXES 5
35 |
36 | static HWND Textboxes[MAX_BOXES];
37 | static HWND Labels[MAX_BOXES];
38 |
39 | static LONG_PTR PrevAlnumOnlyProc[MAX_BOXES];
40 | static LONG_PTR PrevNumOnlyProc[MAX_BOXES];
41 |
42 | static BOOL NoCheckingOnBox[MAX_BOXES];
43 |
44 | //-----------------------------------------------------------------------------
45 | // Don't allow any characters other than -A-Za-z0-9_ in the box.
46 | //-----------------------------------------------------------------------------
47 | static LRESULT CALLBACK MyAlnumOnlyProc(HWND hwnd, UINT msg, WPARAM wParam,
48 | LPARAM lParam)
49 | {
50 | if(msg == WM_CHAR) {
51 | if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
52 | wParam == '\b' || wParam == '-' || wParam == '\''))
53 | {
54 | return 0;
55 | }
56 | }
57 |
58 | int i;
59 | for(i = 0; i < MAX_BOXES; i++) {
60 | if(hwnd == Textboxes[i]) {
61 | return CallWindowProc((WNDPROC)PrevAlnumOnlyProc[i], hwnd, msg,
62 | wParam, lParam);
63 | }
64 | }
65 | oops();
66 | }
67 |
68 | //-----------------------------------------------------------------------------
69 | // Don't allow any characters other than -0-9. in the box.
70 | //-----------------------------------------------------------------------------
71 | static LRESULT CALLBACK MyNumOnlyProc(HWND hwnd, UINT msg, WPARAM wParam,
72 | LPARAM lParam)
73 | {
74 | if(msg == WM_CHAR) {
75 | if(!(isdigit(wParam) || wParam == '.' || wParam == '\b'
76 | || wParam == '-'))
77 | {
78 | return 0;
79 | }
80 | }
81 |
82 | int i;
83 | for(i = 0; i < MAX_BOXES; i++) {
84 | if(hwnd == Textboxes[i]) {
85 | return CallWindowProc((WNDPROC)PrevNumOnlyProc[i], hwnd, msg,
86 | wParam, lParam);
87 | }
88 | }
89 | oops();
90 | }
91 |
92 | static void MakeControls(int boxes, char **labels, DWORD fixedFontMask)
93 | {
94 | int i;
95 | HDC hdc = GetDC(SimpleDialog);
96 | SelectObject(hdc, MyNiceFont);
97 |
98 | SIZE si;
99 |
100 | int maxLen = 0;
101 | for(i = 0; i < boxes; i++) {
102 | GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
103 | if(si.cx > maxLen) maxLen = si.cx;
104 | }
105 |
106 | int adj;
107 | if(maxLen > 70) {
108 | adj = maxLen - 70;
109 | } else {
110 | adj = 0;
111 | }
112 |
113 | for(i = 0; i < boxes; i++) {
114 | GetTextExtentPoint32(hdc, labels[i], strlen(labels[i]), &si);
115 |
116 | Labels[i] = CreateWindowEx(0, WC_STATIC, labels[i],
117 | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
118 | (80 + adj) - si.cx - 4, 13 + i*30, si.cx, 21,
119 | SimpleDialog, NULL, Instance, NULL);
120 | NiceFont(Labels[i]);
121 |
122 | Textboxes[i] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
123 | WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS |
124 | WS_VISIBLE,
125 | 80 + adj, 12 + 30*i, 120 - adj, 21,
126 | SimpleDialog, NULL, Instance, NULL);
127 |
128 | if(fixedFontMask & (1 << i)) {
129 | FixedFont(Textboxes[i]);
130 | } else {
131 | NiceFont(Textboxes[i]);
132 | }
133 | }
134 | ReleaseDC(SimpleDialog, hdc);
135 |
136 | OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
137 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
138 | 218, 11, 70, 23, SimpleDialog, NULL, Instance, NULL);
139 | NiceFont(OkButton);
140 |
141 | CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
142 | WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
143 | 218, 41, 70, 23, SimpleDialog, NULL, Instance, NULL);
144 | NiceFont(CancelButton);
145 | }
146 |
147 | BOOL ShowSimpleDialog(char *title, int boxes, char **labels, DWORD numOnlyMask,
148 | DWORD alnumOnlyMask, DWORD fixedFontMask, char **dests)
149 | {
150 | BOOL didCancel;
151 |
152 | if(boxes > MAX_BOXES) oops();
153 |
154 | SimpleDialog = CreateWindowClient(0, "LDmicroDialog", title,
155 | WS_OVERLAPPED | WS_SYSMENU,
156 | 100, 100, 304, 15 + 30*(boxes < 2 ? 2 : boxes), NULL, NULL,
157 | Instance, NULL);
158 |
159 | MakeControls(boxes, labels, fixedFontMask);
160 |
161 | int i;
162 | for(i = 0; i < boxes; i++) {
163 | SendMessage(Textboxes[i], WM_SETTEXT, 0, (LPARAM)dests[i]);
164 |
165 | if(numOnlyMask & (1 << i)) {
166 | PrevNumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
167 | (LONG_PTR)MyNumOnlyProc);
168 | }
169 | if(alnumOnlyMask & (1 << i)) {
170 | PrevAlnumOnlyProc[i] = SetWindowLongPtr(Textboxes[i], GWLP_WNDPROC,
171 | (LONG_PTR)MyAlnumOnlyProc);
172 | }
173 | }
174 |
175 | EnableWindow(MainWindow, FALSE);
176 | ShowWindow(SimpleDialog, TRUE);
177 | SetFocus(Textboxes[0]);
178 | SendMessage(Textboxes[0], EM_SETSEL, 0, -1);
179 |
180 | MSG msg;
181 | DWORD ret;
182 | DialogDone = FALSE;
183 | DialogCancel = FALSE;
184 | while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) {
185 | if(msg.message == WM_KEYDOWN) {
186 | if(msg.wParam == VK_RETURN) {
187 | DialogDone = TRUE;
188 | break;
189 | } else if(msg.wParam == VK_ESCAPE) {
190 | DialogDone = TRUE;
191 | DialogCancel = TRUE;
192 | break;
193 | }
194 | }
195 |
196 | if(IsDialogMessage(SimpleDialog, &msg)) continue;
197 | TranslateMessage(&msg);
198 | DispatchMessage(&msg);
199 | }
200 |
201 | didCancel = DialogCancel;
202 |
203 | if(!didCancel) {
204 | for(i = 0; i < boxes; i++) {
205 | if(NoCheckingOnBox[i]) {
206 | char get[64];
207 | SendMessage(Textboxes[i], WM_GETTEXT, 60, (LPARAM)get);
208 | strcpy(dests[i], get);
209 | } else {
210 | char get[20];
211 | SendMessage(Textboxes[i], WM_GETTEXT, 15, (LPARAM)get);
212 |
213 | if( (!strchr(get, '\'')) ||
214 | (get[0] == '\'' && get[2] == '\'' && strlen(get)==3) )
215 | {
216 | if(strlen(get) == 0) {
217 | Error(_("Empty textbox; not permitted."));
218 | } else {
219 | strcpy(dests[i], get);
220 | }
221 | } else {
222 | Error(_("Bad use of quotes: <%s>"), get);
223 | }
224 | }
225 | }
226 | }
227 |
228 | EnableWindow(MainWindow, TRUE);
229 | DestroyWindow(SimpleDialog);
230 |
231 | return !didCancel;
232 | }
233 |
234 | void ShowTimerDialog(int which, int *delay, char *name)
235 | {
236 | char *s;
237 | switch(which) {
238 | case ELEM_TON: s = _("Turn-On Delay"); break;
239 | case ELEM_TOF: s = _("Turn-Off Delay"); break;
240 | case ELEM_RTO: s = _("Retentive Turn-On Delay"); break;
241 | default: oops(); break;
242 | }
243 |
244 | char *labels[] = { _("Name:"), _("Delay (ms):") };
245 |
246 | char delBuf[16];
247 | char nameBuf[16];
248 | sprintf(delBuf, "%.3f", (*delay / 1000.0));
249 | strcpy(nameBuf, name+1);
250 | char *dests[] = { nameBuf, delBuf };
251 |
252 | if(ShowSimpleDialog(s, 2, labels, (1 << 1), (1 << 0), (1 << 0), dests)) {
253 | name[0] = 'T';
254 | strcpy(name+1, nameBuf);
255 | double del = atof(delBuf);
256 | if(del > 2140000) { // 2**31/1000, don't overflow signed int
257 | Error(_("Delay too long; maximum is 2**31 us."));
258 | } else if(del <= 0) {
259 | Error(_("Delay cannot be zero or negative."));
260 | } else {
261 | *delay = (int)(1000*del + 0.5);
262 | }
263 | }
264 | }
265 |
266 | void ShowCounterDialog(int which, int *maxV, char *name)
267 | {
268 | char *title;
269 |
270 | switch(which) {
271 | case ELEM_CTU: title = _("Count Up"); break;
272 | case ELEM_CTD: title = _("Count Down"); break;
273 | case ELEM_CTC: title = _("Circular Counter"); break;
274 |
275 | default: oops();
276 | }
277 |
278 | char *labels[] = { _("Name:"), (which == ELEM_CTC ? _("Max value:") :
279 | _("True if >= :")) };
280 | char maxS[128];
281 | sprintf(maxS, "%d", *maxV);
282 | char *dests[] = { name+1, maxS };
283 | ShowSimpleDialog(title, 2, labels, 0x2, 0x1, 0x1, dests);
284 | *maxV = atoi(maxS);
285 | }
286 |
287 | void ShowCmpDialog(int which, char *op1, char *op2)
288 | {
289 | char *title;
290 | char *l2;
291 | switch(which) {
292 | case ELEM_EQU:
293 | title = _("If Equals");
294 | l2 = "= :";
295 | break;
296 |
297 | case ELEM_NEQ:
298 | title = _("If Not Equals");
299 | l2 = "/= :";
300 | break;
301 |
302 | case ELEM_GRT:
303 | title = _("If Greater Than");
304 | l2 = "> :";
305 | break;
306 |
307 | case ELEM_GEQ:
308 | title = _("If Greater Than or Equal To");
309 | l2 = ">= :";
310 | break;
311 |
312 | case ELEM_LES:
313 | title = _("If Less Than");
314 | l2 = "< :";
315 | break;
316 |
317 | case ELEM_LEQ:
318 | title = _("If Less Than or Equal To");
319 | l2 = "<= :";
320 | break;
321 |
322 | default:
323 | oops();
324 | }
325 | char *labels[] = { _("'Closed' if:"), l2 };
326 | char *dests[] = { op1, op2 };
327 | ShowSimpleDialog(title, 2, labels, 0, 0x3, 0x3, dests);
328 | }
329 |
330 | void ShowMoveDialog(char *dest, char *src)
331 | {
332 | char *labels[] = { _("Destination:"), _("Source:") };
333 | char *dests[] = { dest, src };
334 | ShowSimpleDialog(_("Move"), 2, labels, 0, 0x3, 0x3, dests);
335 | }
336 |
337 | void ShowReadAdcDialog(char *name)
338 | {
339 | char *labels[] = { _("Destination:") };
340 | char *dests[] = { name };
341 | ShowSimpleDialog(_("Read A/D Converter"), 1, labels, 0, 0x1, 0x1, dests);
342 | }
343 |
344 | void ShowSetPwmDialog(char *name, int *targetFreq)
345 | {
346 | char freq[100];
347 | sprintf(freq, "%d", *targetFreq);
348 |
349 | char *labels[] = { _("Duty cycle var:"), _("Frequency (Hz):") };
350 | char *dests[] = { name, freq };
351 | ShowSimpleDialog(_("Set PWM Duty Cycle"), 2, labels, 0x2, 0x1, 0x1, dests);
352 |
353 | *targetFreq = atoi(freq);
354 | }
355 |
356 | void ShowUartDialog(int which, char *name)
357 | {
358 | char *labels[] = { (which == ELEM_UART_RECV) ? _("Destination:") :
359 | _("Source:") };
360 | char *dests[] = { name };
361 |
362 | ShowSimpleDialog((which == ELEM_UART_RECV) ? _("Receive from UART") :
363 | _("Send to UART"), 1, labels, 0, 0x1, 0x1, dests);
364 | }
365 |
366 | void ShowMathDialog(int which, char *dest, char *op1, char *op2)
367 | {
368 | char *l2, *title;
369 | if(which == ELEM_ADD) {
370 | l2 = "+ :";
371 | title = _("Add");
372 | } else if(which == ELEM_SUB) {
373 | l2 = "- :";
374 | title = _("Subtract");
375 | } else if(which == ELEM_MUL) {
376 | l2 = "* :";
377 | title = _("Multiply");
378 | } else if(which == ELEM_DIV) {
379 | l2 = "/ :";
380 | title = _("Divide");
381 | } else oops();
382 |
383 | char *labels[] = { _("Destination:"), _("is set := :"), l2 };
384 | char *dests[] = { dest, op1, op2 };
385 | ShowSimpleDialog(title, 3, labels, 0, 0x7, 0x7, dests);
386 | }
387 |
388 | void ShowShiftRegisterDialog(char *name, int *stages)
389 | {
390 | char stagesStr[20];
391 | sprintf(stagesStr, "%d", *stages);
392 |
393 | char *labels[] = { _("Name:"), _("Stages:") };
394 | char *dests[] = { name, stagesStr };
395 | ShowSimpleDialog(_("Shift Register"), 2, labels, 0x2, 0x1, 0x1, dests);
396 |
397 | *stages = atoi(stagesStr);
398 |
399 | if(*stages <= 0 || *stages >= 200) {
400 | Error(_("Not a reasonable size for a shift register."));
401 | *stages = 1;
402 | }
403 | }
404 |
405 | void ShowFormattedStringDialog(char *var, char *string)
406 | {
407 | char *labels[] = { _("Variable:"), _("String:") };
408 | char *dests[] = { var, string };
409 | NoCheckingOnBox[0] = TRUE;
410 | NoCheckingOnBox[1] = TRUE;
411 | ShowSimpleDialog(_("Formatted String Over UART"), 2, labels, 0x0,
412 | 0x1, 0x3, dests);
413 | NoCheckingOnBox[0] = FALSE;
414 | NoCheckingOnBox[1] = FALSE;
415 | }
416 |
417 | void ShowPersistDialog(char *var)
418 | {
419 | char *labels[] = { _("Variable:") };
420 | char *dests[] = { var };
421 | ShowSimpleDialog(_("Make Persistent"), 1, labels, 0, 1, 1, dests);
422 | }
423 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/txt2c.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | print <
6 | EOT
7 |
8 | for $manual () {
9 |
10 | if($manual eq 'manual.txt') {
11 | $name = "HelpText";
12 | # Some languages don't have translated manuals yet, so use English
13 | $ifdef = "#if defined(LDLANG_EN) || defined(LDLANG_ES) || defined(LDLANG_IT) || " .
14 | "defined(LDLANG_PT)";
15 | } elsif($manual =~ /manual-(.)(.)\.txt/) {
16 | $p = uc($1) . lc($2);
17 | $ifdef = "#ifdef LDLANG_" . uc($1 . $2);
18 | $name = "HelpText$p";
19 | } else {
20 | die;
21 | }
22 |
23 | print <) {
30 | chomp;
31 | s/\\/\\\\/g;
32 | s/"/\\"/g;
33 |
34 | print qq{ "$_",\n};
35 | }
36 | close IN;
37 |
38 | print <.
18 | //------
19 | //
20 | // Routines to maintain the stack of recent versions of the program that we
21 | // use for the undo/redo feature. Don't be smart at all; keep deep copies of
22 | // the entire program at all times.
23 | // Jonathan Westhues, split May 2005
24 | //-----------------------------------------------------------------------------
25 | #include
26 | #include
27 | #include
28 |
29 | #include "ldmicro.h"
30 |
31 | // Store a `deep copy' of the entire program before every change, in a
32 | // circular buffer so that the first one scrolls out as soon as the buffer
33 | // is full and we try to push another one.
34 | #define MAX_LEVELS_UNDO 32
35 | typedef struct ProgramStackTag {
36 | PlcProgram prog[MAX_LEVELS_UNDO];
37 | struct {
38 | int gx;
39 | int gy;
40 | } cursor[MAX_LEVELS_UNDO];
41 | int write;
42 | int count;
43 | } ProgramStack;
44 |
45 | static struct {
46 | ProgramStack undo;
47 | ProgramStack redo;
48 | } Undo;
49 |
50 | //-----------------------------------------------------------------------------
51 | // Make a `deep copy' of a circuit. Used for making a copy of the program
52 | // whenever we change it, for undo purposes. Fast enough that we shouldn't
53 | // need to be smart.
54 | //-----------------------------------------------------------------------------
55 | static void *DeepCopy(int which, void *any)
56 | {
57 | switch(which) {
58 | CASE_LEAF {
59 | ElemLeaf *l = AllocLeaf();
60 | memcpy(l, any, sizeof(*l));
61 | l->selectedState = SELECTED_NONE;
62 | return l;
63 | }
64 | case ELEM_SERIES_SUBCKT: {
65 | int i;
66 | ElemSubcktSeries *n = AllocSubcktSeries();
67 | ElemSubcktSeries *s = (ElemSubcktSeries *)any;
68 | n->count = s->count;
69 | for(i = 0; i < s->count; i++) {
70 | n->contents[i].which = s->contents[i].which;
71 | n->contents[i].d.any = DeepCopy(s->contents[i].which,
72 | s->contents[i].d.any);
73 | }
74 | return n;
75 | }
76 | case ELEM_PARALLEL_SUBCKT: {
77 | int i;
78 | ElemSubcktParallel *n = AllocSubcktParallel();
79 | ElemSubcktParallel *p = (ElemSubcktParallel *)any;
80 | n->count = p->count;
81 | for(i = 0; i < p->count; i++) {
82 | n->contents[i].which = p->contents[i].which;
83 | n->contents[i].d.any = DeepCopy(p->contents[i].which,
84 | p->contents[i].d.any);
85 | }
86 | return n;
87 | }
88 | default:
89 | oops();
90 | break;
91 | }
92 | }
93 |
94 | //-----------------------------------------------------------------------------
95 | // Empty out a ProgramStack data structure, either .undo or .redo: set the
96 | // count to zero and free all the program copies in it.
97 | //-----------------------------------------------------------------------------
98 | static void EmptyProgramStack(ProgramStack *ps)
99 | {
100 | while(ps->count > 0) {
101 | int a = (ps->write - 1);
102 | if(a < 0) a += MAX_LEVELS_UNDO;
103 | ps->write = a;
104 | (ps->count)--;
105 |
106 | int i;
107 | for(i = 0; i < ps->prog[ps->write].numRungs; i++) {
108 | FreeCircuit(ELEM_SERIES_SUBCKT, ps->prog[ps->write].rungs[i]);
109 | }
110 | }
111 | }
112 |
113 | //-----------------------------------------------------------------------------
114 | // Push the current program onto a program stack. Can either make a deep or
115 | // a shallow copy of the linked data structures.
116 | //-----------------------------------------------------------------------------
117 | static void PushProgramStack(ProgramStack *ps, BOOL deepCopy)
118 | {
119 | if(ps->count == MAX_LEVELS_UNDO) {
120 | int i;
121 | for(i = 0; i < ps->prog[ps->write].numRungs; i++) {
122 | FreeCircuit(ELEM_SERIES_SUBCKT,
123 | ps->prog[ps->write].rungs[i]);
124 | }
125 | } else {
126 | (ps->count)++;
127 | }
128 |
129 | memcpy(&(ps->prog[ps->write]), &Prog, sizeof(Prog));
130 | if(deepCopy) {
131 | int i;
132 | for(i = 0; i < Prog.numRungs; i++) {
133 | ps->prog[ps->write].rungs[i] =
134 | (ElemSubcktSeries *)DeepCopy(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
135 | }
136 | }
137 |
138 | int gx, gy;
139 | if(FindSelected(&gx, &gy)) {
140 | ps->cursor[ps->write].gx = gx;
141 | ps->cursor[ps->write].gy = gy;
142 | } else {
143 | ps->cursor[ps->write].gx = -1;
144 | ps->cursor[ps->write].gy = -1;
145 | }
146 |
147 | int a = (ps->write + 1);
148 | if(a >= MAX_LEVELS_UNDO) a -= MAX_LEVELS_UNDO;
149 | ps->write = a;
150 | }
151 |
152 | //-----------------------------------------------------------------------------
153 | // Pop a program stack onto the current program. Always does a shallow copy.
154 | // Internal error if the stack was empty.
155 | //-----------------------------------------------------------------------------
156 | static void PopProgramStack(ProgramStack *ps)
157 | {
158 | int a = (ps->write - 1);
159 | if(a < 0) a += MAX_LEVELS_UNDO;
160 | ps->write = a;
161 | (ps->count)--;
162 |
163 | memcpy(&Prog, &ps->prog[ps->write], sizeof(Prog));
164 |
165 | SelectedGxAfterNextPaint = ps->cursor[ps->write].gx;
166 | SelectedGyAfterNextPaint = ps->cursor[ps->write].gy;
167 | }
168 |
169 | //-----------------------------------------------------------------------------
170 | // Push a copy of the PLC program onto the undo history, replacing (and
171 | // freeing) the oldest one if necessary.
172 | //-----------------------------------------------------------------------------
173 | void UndoRemember(void)
174 | {
175 | // can't redo after modifying the program
176 | EmptyProgramStack(&(Undo.redo));
177 | PushProgramStack(&(Undo.undo), TRUE);
178 |
179 | SetUndoEnabled(TRUE, FALSE);
180 | }
181 |
182 | //-----------------------------------------------------------------------------
183 | // Pop the undo history one level, or do nothing if we're out of levels of
184 | // undo. This means that we push the current program on the redo stack, and
185 | // pop the undo stack onto the current program.
186 | //-----------------------------------------------------------------------------
187 | void UndoUndo(void)
188 | {
189 | if(Undo.undo.count <= 0) return;
190 |
191 | ForgetEverything();
192 |
193 | PushProgramStack(&(Undo.redo), FALSE);
194 | PopProgramStack(&(Undo.undo));
195 |
196 | if(Undo.undo.count > 0) {
197 | SetUndoEnabled(TRUE, TRUE);
198 | } else {
199 | SetUndoEnabled(FALSE, TRUE);
200 | }
201 | RefreshControlsToSettings();
202 | RefreshScrollbars();
203 | InvalidateRect(MainWindow, NULL, FALSE);
204 | }
205 |
206 | //-----------------------------------------------------------------------------
207 | // Redo an undone operation. Push the current program onto the undo stack,
208 | // and pop the redo stack into the current program.
209 | //-----------------------------------------------------------------------------
210 | void UndoRedo(void)
211 | {
212 | if(Undo.redo.count <= 0) return;
213 |
214 | ForgetEverything();
215 |
216 | PushProgramStack(&(Undo.undo), FALSE);
217 | PopProgramStack(&(Undo.redo));
218 |
219 | if(Undo.redo.count > 0) {
220 | SetUndoEnabled(TRUE, TRUE);
221 | } else {
222 | SetUndoEnabled(TRUE, FALSE);
223 | }
224 | RefreshControlsToSettings();
225 | RefreshScrollbars();
226 | InvalidateRect(MainWindow, NULL, FALSE);
227 | }
228 |
229 | //-----------------------------------------------------------------------------
230 | // Empty out our undo history entirely, as when loading a new file.
231 | //-----------------------------------------------------------------------------
232 | void UndoFlush(void)
233 | {
234 | EmptyProgramStack(&(Undo.undo));
235 | EmptyProgramStack(&(Undo.redo));
236 | SetUndoEnabled(FALSE, FALSE);
237 | }
238 |
239 | //-----------------------------------------------------------------------------
240 | // Is it possible to undo some operation? The display code needs to do that,
241 | // due to an ugly hack for handling too-long lines; the only thing that
242 | // notices that easily is the display code, which will respond by undoing
243 | // the last operation, presumably the one that added the long line.
244 | //-----------------------------------------------------------------------------
245 | BOOL CanUndo(void)
246 | {
247 | return (Undo.undo.count > 0);
248 | }
249 |
250 |
--------------------------------------------------------------------------------
/ldmicro-rel2.2/ldmicro/vc100.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thiagoralves/OpenPLC-Ladder-Editor/cc85272e497d4738d94b533b5a173332f1c61339/ldmicro-rel2.2/ldmicro/vc100.pdb
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | This program is free software: you can redistribute it and/or modify
2 | it under the terms of the Creative Commons Attribution-ShareAlike 4.0
3 | International (CC BY-SA 4.0)
4 |
5 | This program is distributed in the hope that it will be useful,
6 | but WITHOUT ANY WARRANTY; without even the implied warranty of
7 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 | CC BY-SA 4.0 License for more details.
9 |
10 | You should have received a copy of the CC BY-SA 4.0 License along with
11 | this program. If not, see .
--------------------------------------------------------------------------------