Badger2040: Allow builtin demos to be replaced

pull/257/head
Phil Howard 2022-03-01 15:18:40 +00:00
rodzic 665ed08123
commit 6e7d8a1682
3 zmienionych plików z 6 dodań i 16 usunięć

Wyświetl plik

@ -45,7 +45,7 @@ jobs:
- name: Copy modules & examples
run: |
cp -r pimoroni-pico-${GITHUB_SHA}/micropython/badger2040_modules_py/* micropython/ports/rp2/modules/
cp pimoroni-pico-${GITHUB_SHA}/micropython/examples/badger2040/launcher.py micropython/ports/rp2/modules/
cp pimoroni-pico-${GITHUB_SHA}/micropython/examples/badger2040/launcher.py micropython/ports/rp2/modules/_launcher.py
cp pimoroni-pico-${GITHUB_SHA}/micropython/examples/badger2040/clock.py micropython/ports/rp2/modules/_clock.py
cp pimoroni-pico-${GITHUB_SHA}/micropython/examples/badger2040/fonts.py micropython/ports/rp2/modules/_fonts.py
cp pimoroni-pico-${GITHUB_SHA}/micropython/examples/badger2040/e-reader.py micropython/ports/rp2/modules/_ebook.py

Wyświetl plik

@ -1,19 +1,6 @@
#import gc
#import machine
#
#a = machine.Pin(12, machine.Pin.IN, machine.Pin.PULL_DOWN)
#b = machine.Pin(13, machine.Pin.IN, machine.Pin.PULL_DOWN)
#c = machine.Pin(14, machine.Pin.IN, machine.Pin.PULL_DOWN)
#
#if a.value() or b.value() or c.value():
# for k in locals().keys():
# if k not in ("gc"):
# del locals()[k]
# gc.collect()
# __import__("launcher.py")
try:
open("main.py", "r")
except OSError:
with open("main.py", "w") as f:
f.write("import launcher")
f.write("import _launcher")
f.flush()

Wyświetl plik

@ -171,7 +171,10 @@ def launch(file):
if k not in ("gc", "file"):
del locals()[k]
gc.collect()
__import__(file)
try:
__import__(file[1:]) # Try to import _[file] (drop underscore prefix)
except ImportError:
__import__(file) # Failover to importing [_file]
sys.exit(0)