Skip to content
This repository was archived by the owner on Jan 1, 2019. It is now read-only.

Commit 631c699

Browse files
committed
Allow emulated startup of launcher and installer
Restructured some bits to make it easier to fill in the blanks. With these changes the emulator can successfully start the launcher and the installer, though actually interacting with them is not yet supported. Additional benefit is that this allows moving some of the emulation code out of the micropython repo, keeping that repo more in sync with upstream. Merge HackerHotel/micropython-esp32#1 and update the submodule in this PR before merging this PR.
1 parent e9c4b2a commit 631c699

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,5 @@ Badge Emulator
107107
--------------
108108
```
109109
make -C micropython/unix
110-
cd micropython/unix
111-
./micropython ../../examples/Game\ of\ Life/game_of_life.py
110+
./emulator/emulate.py examples/Game\ of\ Life/game_of_life.py
112111
```

emulator/badge.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Emulating the badge module
2+
#
3+
# The badge module is a C module with Python bindings
4+
# on the real badge, but for the emulator it's just a
5+
# plain python module.
6+
7+
def nvs_get_u16(namespace, key, value):
8+
return value
9+
10+
def eink_init():
11+
"ok"
12+
13+
def safe_mode():
14+
return False

emulator/emulate.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!./micropython/unix/micropython
2+
3+
# 'Emulator' to run badge micropython scripts on linux.
4+
#
5+
# Usage: './emulator/emulate.py micropython/esp32/modules/launcher.py'
6+
#
7+
# Needs this wrapper python script so the python module loader prefers the
8+
# emulated module implementations in './emulator' over the 'real'
9+
# implementations next to the to-be-emulated application.
10+
11+
import sys,os
12+
13+
print('Running',sys.argv[1],'in badge emulator')
14+
15+
dir = '/'.join(sys.argv[1].split('/')[:-1])
16+
file = sys.argv[1].split('/')[-1]
17+
18+
sys.path.append(dir)
19+
20+
print('looking for',file,'in sys.path:',sys.path)
21+
22+
__import__(file)
23+
print('yolo')

emulator/esp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Emulating the ESP API:

emulator/machine.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Emulating the machine API
2+
3+
class Pin:
4+
""""tee hee"""
5+
6+
class RTC:
7+
def wake_on_ext0(self, pin, level):
8+
"ok"
9+
10+
class Timer:
11+
PERIODIC=1
12+
13+
def init(self, mode, period, callback):
14+
"TODO"

0 commit comments

Comments
 (0)