Skip to content
This repository was archived by the owner on Jan 1, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
14 changes: 14 additions & 0 deletions emulator/badge.py
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions emulator/emulate.py
Original file line number Diff line number Diff line change
@@ -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')
1 change: 1 addition & 0 deletions emulator/esp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Emulating the ESP API:
14 changes: 14 additions & 0 deletions emulator/machine.py
Original file line number Diff line number Diff line change
@@ -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"