Difference between revisions of "Projects:Badge/Emulator"
From SHA2017 Wiki
m (Fixed typo code) |
|||
| Line 22: | Line 22: | ||
<nowiki>git clone --recursive https://github.com/SHA2017-badge/Firmware.git | <nowiki>git clone --recursive https://github.com/SHA2017-badge/Firmware.git | ||
cd Firmware/micropython/lib | cd Firmware/micropython/lib | ||
| − | clone https://github.com/ARMmbed/mbedtls.git | + | git clone https://github.com/ARMmbed/mbedtls.git |
cd mbedtls | cd mbedtls | ||
make | make | ||
Revision as of 22:30, 18 June 2017
Badge Emulator
You can now play with the badge software before you even receive your badge!
Limitations
Currently LEDs and vibrator are not supported.
Apparently key-presses etc can only be caught while actively waiting. Might not be much of a limitation.
Installation
Linux
sudo apt-get install libncurses5-dev flex bison gperf python-serial libffi-dev libsdl2-dev libmbedtls-dev
Or equivalent installation of requirements on your distribution.
git clone --recursive https://github.com/SHA2017-badge/Firmware.git cd Firmware/micropython/unix make
macOS
git clone --recursive https://github.com/SHA2017-badge/Firmware.git cd Firmware/micropython/lib git clone https://github.com/ARMmbed/mbedtls.git cd mbedtls make sudo make install cd ../../unix make
Usage
./micropython demo.py
You can also just start ./micropython and start using the MicroPython modules.
import ugfx
ugfx.init()
ugfx.clear(ugfx.BLACK)
ugfx.fill_circle(60, 60, 50, ugfx.WHITE);
ugfx.fill_circle(60, 60, 40, ugfx.BLACK);
ugfx.fill_circle(60, 60, 30, ugfx.WHITE);
ugfx.fill_circle(60, 60, 20, ugfx.BLACK);
ugfx.fill_circle(60, 60, 10, ugfx.WHITE);
ugfx.thickline(1,1,100,100,ugfx.WHITE,10,5)
ugfx.box(30,30,50,50,ugfx.WHITE)
ugfx.string(150,25,"STILL","Roboto_BlackItalic24",ugfx.WHITE)
ugfx.string(130,50,"Hacking","PermanentMarker22",ugfx.WHITE)
len = ugfx.get_string_width("Hacking","PermanentMarker22")
ugfx.line(130, 72, 144 + len, 72, ugfx.WHITE)
ugfx.line(140 + len, 52, 140 + len, 70, ugfx.WHITE)
ugfx.string(140,75,"Anyway","Roboto_BlackItalic24",ugfx.WHITE)
ugfx.flush()
You can also use woezel to install software from the Hatchery.
import woezel
woezel.install('game_of_life')
import game_of_life
