diff --git a/.gitmodules b/.gitmodules index 20a4449..198620c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ branch = master [submodule "micropython"] path = micropython - url = https://github.com/SHA2017-badge/micropython-esp32.git + url = https://github.com/HackerHotel/micropython-esp32.git branch = master [submodule "ugfx"] path = ugfx diff --git a/README.md b/README.md index b70dc9c..1e12b57 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,5 @@ Badge Emulator -------------- ``` make -C micropython/unix -cd micropython/unix -./micropython ../../examples/Game\ of\ Life/game_of_life.py +./emulator/emulate.py examples/Game\ of\ Life/game_of_life.py ``` diff --git a/emulator/badge.py b/emulator/badge.py new file mode 100644 index 0000000..7f2c6a0 --- /dev/null +++ b/emulator/badge.py @@ -0,0 +1,14 @@ +# Emulating the badge module +# +# The badge module is a C module with Python bindings +# on the real badge, but for the emulator it's just a +# plain python module. + +def nvs_get_u16(namespace, key, value): + return value + +def eink_init(): + "ok" + +def safe_mode(): + return False diff --git a/emulator/emulate.py b/emulator/emulate.py new file mode 100755 index 0000000..cb95ef5 --- /dev/null +++ b/emulator/emulate.py @@ -0,0 +1,23 @@ +#!./micropython/unix/micropython + +# 'Emulator' to run badge micropython scripts on linux. +# +# Usage: './emulator/emulate.py micropython/esp32/modules/launcher.py' +# +# Needs this wrapper python script so the python module loader prefers the +# emulated module implementations in './emulator' over the 'real' +# implementations next to the to-be-emulated application. + +import sys,os + +print('Running',sys.argv[1],'in badge emulator') + +dir = '/'.join(sys.argv[1].split('/')[:-1]) +file = sys.argv[1].split('/')[-1] + +sys.path.append(dir) + +print('looking for',file,'in sys.path:',sys.path) + +__import__(file) +print('yolo') diff --git a/emulator/esp.py b/emulator/esp.py new file mode 100644 index 0000000..11a2462 --- /dev/null +++ b/emulator/esp.py @@ -0,0 +1 @@ +# Emulating the ESP API: diff --git a/emulator/machine.py b/emulator/machine.py new file mode 100644 index 0000000..8427a36 --- /dev/null +++ b/emulator/machine.py @@ -0,0 +1,14 @@ +# Emulating the machine API + +class Pin: + """"tee hee""" + +class RTC: + def wake_on_ext0(self, pin, level): + "ok" + +class Timer: + PERIODIC=1 + + def init(self, mode, period, callback): + "TODO" diff --git a/micropython b/micropython index 5dbf3e7..9527cca 160000 --- a/micropython +++ b/micropython @@ -1 +1 @@ -Subproject commit 5dbf3e7e6af454fc0a26ff2a281718c4b353d49a +Subproject commit 9527ccad30e4213307269de672af94adf4452988