Skip to content

Commit 5ced8ff

Browse files
committed
Type Bool added, needed for Arduino Uno
1 parent f3c87d2 commit 5ced8ff

File tree

7 files changed

+74
-68
lines changed

7 files changed

+74
-68
lines changed

README.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ What's new:
3030

3131
- Comments in code of SimPyLC/scene.py adapted to clarify different purpose of axis and pivot, and of passing angle to __init__ versus passing it to __call__
3232
- Spaces rather than tabs are now used in the sourcecode.
33-
- Adapted for Python 3.5 (SimPyLC 2.1.2 is last version running with Python 2.7)
33+
- Adapted for Python 3.6 (SimPyLC 2.1.2 is last version running with Python 2.7)
3434
- Development status bumped to production / stable.
3535
- Native.py files replaced by native.cpp files, which are plain C++, hence benefit from syntax highlighting. You'll have to adapt your existing code to this (by merely leaving things out).
3636
- Code now generated in a separate subdirectory to avoid confusion, especially with native.cpp.
@@ -41,21 +41,22 @@ REMARK: All complete Arduino examples were tested on the Arduino Due, since that
4141

4242
Bugs fixed:
4343

44-
- __nonzero__ changed to __bool__, as required by the move from Python 2.7 to Python 3.5. The blinkingLight demo will now work again.
44+
- Type Bool added, needed for Arduino Uno.
45+
- __nonzero__ changed to __bool__, as required by the move from Python 2.7 to Python 3.6. The blinkingLight demo will now work again.
4546
- Sidewalks raised above road in arduinoTrafficLights example.
4647
- Unused circuit group 'Lights' deleted from control in arduinoTrafficLights example.
4748

4849
**Bug reports and feature requests are most welcome and will be taken under serious consideration on a non-committal basis**
4950

5051
Requirements for Windows:
5152

52-
1. Install WinPython 3.5, e.g. from https://winpython.github.io
53+
1. Install WinPython 3.6, e.g. from https://winpython.github.io
5354
2. (Optional) Copy SimPyLC\\SimPyLC\\QuartzMS.TTF to C:\\Windows\\Fonts
5455
3. (Optional) You can may also add SimPyLC\\SimPyLC to your PYTHONPATH
5556

5657
Requirements for Linux:
5758

58-
1. Install Python 3.5 and PyOpenGL
59+
1. Install Python 3.6 and PyOpenGL
5960

6061
Usage:
6162

SimPyLC/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import os
2828

2929
programName = 'SimPyLC'
30-
programVersion = '3.5.5'
30+
programVersion = '3.6.1'
3131
programNameAndVersion = '{0} {1}'.format (programName, programVersion)
3232
programDir = os.getcwd () .replace ('\\', '/') .rsplit ('/', 3) [-1]
3333

SimPyLC/coder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def getPrologue (self):
224224
225225
#define {0}False 0
226226
#define {0}True 1
227+
#define {0}Bool bool
227228
#define {0}UInt unsigned long
228229
#define {0}Int long
229230
#define {0}Float double

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def read (*paths):
88

99
setup (
1010
name = 'SimPyLC',
11-
version = '3.5.5',
11+
version = '3.6.1',
1212
description = 'SimPyLC PLC simulator, after its C++ big brother that has controlled industrial installations for more than 20 years now. ARDUINO CODE GENERATION ADDED!',
1313
long_description = (
1414
read ('README.rst') + '\n\n' +
15-
read ('qQuickLicence.txt')
15+
read ('qQuickLicense.txt')
1616
),
1717
keywords = ['PLC', 'Arduino','simulator', 'SimPyLC', 'emulator', 'GEATEC', 'opy', 'eden'],
1818
url = 'http://www.qquick.org/educational',
@@ -30,6 +30,7 @@ def read (*paths):
3030
'Topic :: Software Development :: Libraries :: Python Modules',
3131
'Operating System :: Microsoft :: Windows',
3232
'Operating System :: POSIX :: Linux',
33-
'Programming Language :: Python :: 3.5'
33+
'Programming Language :: Python :: 3.5',
34+
'Programming Language :: Python :: 3.6'
3435
],
3536
)

simulations/arduinoLedTimer/generated/arduinoLedTimer/arduinoLedTimer.ino

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
// ====== BEGIN OF LICENCE COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
5+
// ====== BEGIN OF License COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
66
//
77
// I M P O R T A N T S A F E T Y N O T I C E
88
//
@@ -12,12 +12,12 @@
1212
// USE OF THIS CODE IS GOVERNED BY THE QQUICK LICENSE (WWW.QQUICK.ORG/LICENSE).
1313
// YOUR LICENSE TO USE THIS GENERATED CODE AUTOMATICALLY ENDS IF YOU REMOVE OR LEAVE OUT THIS LICENSE COMMENT BLOCK OR THE CODE THAT GENERATED IT.
1414
//
15-
// ====== END OF LICENCE COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
15+
// ====== END OF License COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
1616

1717

1818

19-
// Generator: SimPyLC 2.1.2
20-
// Generated: 2016-12-09 19:38:24.144225
19+
// Generator: SimPyLC 3.6.0
20+
// Generated: 2017-08-21 18:50:37.930289
2121
// Target platform: Arduino
2222

2323

@@ -66,14 +66,15 @@
6666
// Support operations
6767

6868
#define update()\
69-
thenExact = nowExact; nowExact = getNowExact(); period = 1e-6 * (nowExact - thenExact);\
70-
nowInexact = getNowInexact();\
71-
first = False;
69+
thenExact = nowExact; nowExact = getNowExact(); period = 1e-6 * (nowExact - thenExact);\
70+
nowInexact = getNowInexact();\
71+
first = False;
7272

7373
// Types
7474

7575
#define False 0
7676
#define True 1
77+
#define Bool bool
7778
#define UInt unsigned long
7879
#define Int long
7980
#define Float double
@@ -88,7 +89,7 @@
8889
#define abs1(value) fabs (value)
8990
#define max2(value0, value1) fmax (value0, value1)
9091
#define min2(value0, value1) fmin (value0, value1)
91-
#define limit3(value, aLimit0, aLimit1) min (max (value, aLimit0), aLimit1)
92+
#define limit3(value, aLimit0, aLimit1) min (max (value, aLimit0), aLimit1)
9293
#define limit2(value, aLimit) limit3 (value, -aLimit, aLimit)
9394
#define digit2(value, index) getDigit (int (value), index)
9495

@@ -134,9 +135,9 @@ void cycle () {
134135
reset2 (blinkTimer, (elapsed1 (blinkTimer) > blinkTime));
135136
mark2 (led, (elapsed1 (blinkTimer) < 0.2));
136137

137-
// ______ System ______
138+
// ______ System ______
138139

139-
update ();
140+
update ();
140141
}
141142

142143

@@ -169,11 +170,11 @@ Removing this header ends your licence.
169170
*/
170171

171172
void setup () {
172-
pinMode (13, OUTPUT);
173+
pinMode (13, OUTPUT);
173174
}
174175

175176
void loop () {
176-
cycle ();
177-
digitalWrite (13, led);
178-
}
177+
cycle ();
178+
digitalWrite (13, led);
179+
}
179180

simulations/arduinoStove/generated/arduinoStove/arduinoStove.ino

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33

44

5-
// ====== BEGIN OF LICENCE COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
5+
// ====== BEGIN OF License COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
66
//
7-
// I M P O R T A N T S A F E T Y N O T I C E
7+
// I M P O R T A N T S A F E T Y N O T I C E
88
//
99
// THIS CODE IS INTENDED SOLELY FOR EDUCATIONAL PURPOSES AND IS FUNDAMENTALLY UNSUITABLE FOR CONTROLLING REAL SYSTEMS.
1010
// IT IS STRICKTLY PROHIBITED TO USE THIS GENERATED CODE IN ANY SITUATION THAT ENTAILS RISK OF DAMAGE OR INJURIES.
1111
//
1212
// USE OF THIS CODE IS GOVERNED BY THE QQUICK LICENSE (WWW.QQUICK.ORG/LICENSE).
1313
// YOUR LICENSE TO USE THIS GENERATED CODE AUTOMATICALLY ENDS IF YOU REMOVE OR LEAVE OUT THIS LICENSE COMMENT BLOCK OR THE CODE THAT GENERATED IT.
1414
//
15-
// ====== END OF LICENCE COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
15+
// ====== END OF License COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
1616

1717

1818

19-
// Generator: SimPyLC 3.5.0
20-
// Generated: 2017-01-23 12:26:00.389172
19+
// Generator: SimPyLC 3.6.0
20+
// Generated: 2017-08-21 18:45:36.728265
2121
// Target platform: Arduino
2222

2323

@@ -66,14 +66,15 @@
6666
// Support operations
6767

6868
#define update()\
69-
thenExact = nowExact; nowExact = getNowExact(); period = 1e-6 * (nowExact - thenExact);\
70-
nowInexact = getNowInexact();\
71-
first = False;
69+
thenExact = nowExact; nowExact = getNowExact(); period = 1e-6 * (nowExact - thenExact);\
70+
nowInexact = getNowInexact();\
71+
first = False;
7272

7373
// Types
7474

7575
#define False 0
7676
#define True 1
77+
#define Bool bool
7778
#define UInt unsigned long
7879
#define Int long
7980
#define Float double
@@ -88,14 +89,14 @@
8889
#define abs1(value) fabs (value)
8990
#define max2(value0, value1) fmax (value0, value1)
9091
#define min2(value0, value1) fmin (value0, value1)
91-
#define limit3(value, aLimit0, aLimit1) min (max (value, aLimit0), aLimit1)
92+
#define limit3(value, aLimit0, aLimit1) min (max (value, aLimit0), aLimit1)
9293
#define limit2(value, aLimit) limit3 (value, -aLimit, aLimit)
9394
#define digit2(value, index) getDigit (int (value), index)
9495

9596
// ____________ General functions ____________
9697

9798
int getDigit (int value, int index) {
98-
return (index == 0) ? value % 10 : getDigit (value / 10, --index);
99+
return (index == 0) ? value % 10 : getDigit (value / 10, --index);
99100
}
100101

101102
// ____________ General variables ____________
@@ -285,9 +286,9 @@ void cycle () {
285286
set3 (sweepMin, 1000, (!elapsed1 (sweepWatch)));
286287
set3 (sweepMax, 0, (!elapsed1 (sweepWatch)));
287288

288-
// ______ System ______
289+
// ______ System ______
289290

290-
update ();
291+
update ();
291292
}
292293

293294

@@ -297,7 +298,7 @@ void cycle () {
297298

298299

299300
// Pins configured for Arduino Due, adapt for Uno
300-
301+
301302
int dataPin = 22, clockPin = 24, latchPin = 26;
302303
int powerPin = 28, childLockPin = 30, plateSelectPin = 32;
303304
int upPin = 34, downPin = 36, alarmSelectPin = 38;
@@ -309,44 +310,44 @@ int gain = 255 / 9;
309310
int dark = 0, g = 1, f = 2, e = 4, d = 8, c = 16, b = 32, a = 64, dot = 128;
310311

311312
int segments [] = {
312-
a + b + c + d + e + f,
313-
b + c,
314-
a + b + g + e + d,
315-
a + b + g + c + d,
316-
f + g + b + c,
317-
a + f + g + c + d,
318-
a + f + e + d + c + g,
319-
a + b + c,
320-
a + b + c + d + e + f + g,
321-
g + f + a + b + c + d
313+
a + b + c + d + e + f,
314+
b + c,
315+
a + b + g + e + d,
316+
a + b + g + c + d,
317+
f + g + b + c,
318+
a + f + g + c + d,
319+
a + f + e + d + c + g,
320+
a + b + c,
321+
a + b + c + d + e + f + g,
322+
g + f + a + b + c + d
322323
};
323324

324325
void setup () {
325-
pinMode (dataPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(latchPin, OUTPUT);
326-
pinMode (powerPin, INPUT); pinMode (childLockPin, INPUT); pinMode (plateSelectPin, INPUT);
327-
pinMode (upPin, INPUT); pinMode (downPin, INPUT); pinMode (alarmSelectPin, INPUT);
328-
pinMode (plate0Pin, OUTPUT); pinMode (plate1Pin, OUTPUT); pinMode (plate2Pin, OUTPUT); pinMode (plate3Pin, OUTPUT);
329-
pinMode (buzzerPin, OUTPUT);
326+
pinMode (dataPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(latchPin, OUTPUT);
327+
pinMode (powerPin, INPUT); pinMode (childLockPin, INPUT); pinMode (plateSelectPin, INPUT);
328+
pinMode (upPin, INPUT); pinMode (downPin, INPUT); pinMode (alarmSelectPin, INPUT);
329+
pinMode (plate0Pin, OUTPUT); pinMode (plate1Pin, OUTPUT); pinMode (plate2Pin, OUTPUT); pinMode (plate3Pin, OUTPUT);
330+
pinMode (buzzerPin, OUTPUT);
330331
}
331332

332333
void readInputs () {
333-
powerButton = digitalRead (powerPin); childLockButton = digitalRead (childLockPin); plateSelectButton = digitalRead (plateSelectPin);
334-
upButton = digitalRead (upPin); downButton = digitalRead (downPin); alarmSelectButton = digitalRead (alarmSelectPin);
334+
powerButton = digitalRead (powerPin); childLockButton = digitalRead (childLockPin); plateSelectButton = digitalRead (plateSelectPin);
335+
upButton = digitalRead (upPin); downButton = digitalRead (downPin); alarmSelectButton = digitalRead (alarmSelectPin);
335336
}
336337

337-
void writeOutputs () {
338-
analogWrite (plate0Pin, gain * plate0Temp); analogWrite (plate1Pin, gain * plate1Temp);
339-
analogWrite (plate2Pin, gain * plate2Temp); analogWrite (plate3Pin, gain * plate3Temp);
340-
digitalWrite (buzzerPin, buzzer);
341-
342-
digitalWrite (latchPin, 0);
343-
shiftOut (dataPin, clockPin, LSBFIRST, 1 << int (3 - digitIndex));
344-
shiftOut (dataPin, clockPin, LSBFIRST, ~(power ? (segments [int (digitValue)] + (digitDot ? dot : dark)) : dark)); // Active low
345-
digitalWrite (latchPin, 1);
338+
void writeOutputs () {
339+
analogWrite (plate0Pin, gain * plate0Temp); analogWrite (plate1Pin, gain * plate1Temp);
340+
analogWrite (plate2Pin, gain * plate2Temp); analogWrite (plate3Pin, gain * plate3Temp);
341+
digitalWrite (buzzerPin, buzzer);
342+
343+
digitalWrite (latchPin, 0);
344+
shiftOut (dataPin, clockPin, LSBFIRST, 1 << int (3 - digitIndex));
345+
shiftOut (dataPin, clockPin, LSBFIRST, ~(power ? (segments [int (digitValue)] + (digitDot ? dot : dark)) : dark)); // Active low
346+
digitalWrite (latchPin, 1);
346347
}
347348

348349
void loop () {
349-
readInputs ();
350-
cycle ();
351-
writeOutputs ();
350+
readInputs ();
351+
cycle ();
352+
writeOutputs ();
352353
}

simulations/arduinoTrafficLights/generated/arduinoTrafficLights/arduinoTrafficLights.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
// ====== BEGIN OF LICENCE COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
5+
// ====== BEGIN OF License COMMENT BLOCK, INCLUDE IN ANY COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
66
//
77
// I M P O R T A N T S A F E T Y N O T I C E
88
//
@@ -12,12 +12,12 @@
1212
// USE OF THIS CODE IS GOVERNED BY THE QQUICK LICENSE (WWW.QQUICK.ORG/LICENSE).
1313
// YOUR LICENSE TO USE THIS GENERATED CODE AUTOMATICALLY ENDS IF YOU REMOVE OR LEAVE OUT THIS LICENSE COMMENT BLOCK OR THE CODE THAT GENERATED IT.
1414
//
15-
// ====== END OF LICENCE COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
15+
// ====== END OF License COMMENT BLOCK, INCLUDE IN COPY OF THIS GENERATED CODE AND DO NOT REMOVE ======
1616

1717

1818

19-
// Generator: SimPyLC 3.5.5
20-
// Generated: 2017-02-10 22:15:41.179688
19+
// Generator: SimPyLC 3.6.0
20+
// Generated: 2017-08-21 18:46:41.937185
2121
// Target platform: Arduino
2222

2323

@@ -74,6 +74,7 @@
7474

7575
#define False 0
7676
#define True 1
77+
#define Bool bool
7778
#define UInt unsigned long
7879
#define Int long
7980
#define Float double

0 commit comments

Comments
 (0)