Skip to content

Commit af9e9b4

Browse files
committed
control.py: Allow alternate serial interface
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 4d6f25a commit af9e9b4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ options:
5151
--clock Display the current time
5252
--gui Launch the graphical version of the program
5353
--panic Crash the firmware (TESTING ONLY)
54+
--serial-dev SERIAL_DEV
55+
Change the serial dev. Probably /dev/ttyACM0 on Linux, COM0 on Windows
56+
5457
```
5558

5659
Examples

control.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
'double-gradient', 'zigzag', 'panic', 'lotus2']
1717
DRAW_PATTERNS = ['off', 'on', 'foo']
1818

19+
SERIAL_DEV = None
20+
1921

2022
def main():
2123
parser = argparse.ArgumentParser()
@@ -41,8 +43,14 @@ def main():
4143
action="store_true")
4244
parser.add_argument("--panic", help="Crash the firmware (TESTING ONLY)",
4345
action="store_true")
46+
parser.add_argument("--serial-dev", help="Change the serial dev. Probably /dev/ttyACM0 on Linux, COM0 on Windows",
47+
default='/dev/ttyACM0')
4448
args = parser.parse_args()
4549

50+
if args.serial_dev is not None:
51+
global SERIAL_DEV
52+
SERIAL_DEV = args.serial_dev
53+
4654
if args.bootloader:
4755
bootloader()
4856
elif args.sleep is not None:
@@ -180,7 +188,8 @@ def clock():
180188

181189
def send_command(command):
182190
print(f"Sending command: {command}")
183-
with serial.Serial('/dev/ttyACM0', 9600) as s:
191+
global SERIAL_DEV
192+
with serial.Serial(SERIAL_DEV, 9600) as s:
184193
s.write(command)
185194

186195

@@ -249,6 +258,8 @@ def gui():
249258
window.close()
250259

251260

261+
# 5x6 font. Leaves 2 pixels on each side empty
262+
# We can leave one row empty below and then the display fits 5 of these digits.
252263
def number(num):
253264
numbers = {
254265
'0': [

0 commit comments

Comments
 (0)