summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rwxr-xr-xtools/preprocess.py27
-rw-r--r--wasp/boards/pinetime/watch.py.in (renamed from wasp/boards/pinetime/watch.py)4
4 files changed, 34 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 16efb0b..e6f30d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
__pycache__
docs/build
attic/
+wasp/boards/pinetime/watch.py
diff --git a/Makefile b/Makefile
index 82e6366..f0fd8ff 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ bootloader:
softdevice:
micropython/ports/nrf/drivers/bluetooth/download_ble_stack.sh
-micropython:
+micropython: wasp/boards/pinetime/watch.py
$(MAKE) -C micropython/mpy-cross
$(RM) micropython/ports/nrf/build-$(BOARD)-s132/frozen_content.c
$(MAKE) -C micropython/ports/nrf \
@@ -39,6 +39,10 @@ micropython:
--application micropython/ports/nrf/build-$(BOARD)-s132/firmware.hex \
micropython.zip
+wasp/boards/pinetime/watch.py : wasp/boards/pinetime/watch.py.in
+ (cd wasp; ../tools/preprocess.py boards/pinetime/watch.py.in > \
+ boards/pinetime/watch.py)
+
dfu:
python3 -m nordicsemi dfu serial --package micropython.zip --port /dev/ttyACM0
diff --git a/tools/preprocess.py b/tools/preprocess.py
new file mode 100755
index 0000000..4c43c2a
--- /dev/null
+++ b/tools/preprocess.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+# SPDX-License-Identifier: LGPL-3.0-or-later
+# Copyright (C) 2020 Daniel Thompson
+"""Quick and dirty macro processor.
+
+Currently the only support macro is #include!
+"""
+
+import sys
+
+def preprocess(fname):
+ with open(fname) as f:
+ for ln in f.readlines():
+ ln = ln.rstrip()
+
+ macro = ln.lstrip()
+ if macro.startswith('#include'):
+ exec(macro[1:])
+ else:
+ print(ln)
+
+def include(fname):
+ preprocess(fname)
+
+for arg in sys.argv[1:]:
+ preprocess(arg)
diff --git a/wasp/boards/pinetime/watch.py b/wasp/boards/pinetime/watch.py.in
index 1caeea5..46fc6f6 100644
--- a/wasp/boards/pinetime/watch.py
+++ b/wasp/boards/pinetime/watch.py.in
@@ -84,9 +84,7 @@ except AttributeError:
os.mount(flash,'/flash')
with open('/flash/main.py', 'w') as f:
f.write('''\
-import manager
-wasp = manager.Manager(watch)
-wasp.run()
+#include('main.py')
''')
# Only change directory if the button is not pressed (this will