Difference between revisions of "Projects:Badge/Emulator"
| Line 26: | Line 26: | ||
==Installation== | ==Installation== | ||
| − | ===Linux=== | + | ===Debian-based GNU/Linux=== |
<nowiki>sudo apt-get install libncurses5-dev flex bison gperf python-serial libffi-dev libsdl2-dev libmbedtls-dev</nowiki> | <nowiki>sudo apt-get install libncurses5-dev flex bison gperf python-serial libffi-dev libsdl2-dev libmbedtls-dev</nowiki> | ||
Or equivalent installation of requirements on your distribution. | Or equivalent installation of requirements on your distribution. | ||
Latest revision as of 12:22, 6 August 2017
Contents
Badge Emulator
You can now play with the badge software before you even receive your badge!
Limitations
Apparently key-presses etc can only be caught while actively waiting. Might not be much of a limitation.
Keys
Arrow keys: UP, DOWN, LEFT, RIGHT
PageUP: A
PageDown: B
Home: Select
End: Start
Delete: Flash
Enter: Middle (unused)
Installation
Debian-based GNU/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
Arch-Linux
git clone --recursive https://github.com/SHA2017-badge/Firmware.git cd Firmware/micropython/unix git clone https://github.com/ARMmbed/mbedtls.git cd mbedtls make sudo make install cd .. make
NixOS
git clone --recursive https://github.com/SHA2017-badge/Firmware.git cd Firmware/micropython/unix nix-shell --packages gcc ncurses5 flex bison2 gperf \ python35Packages.pyserial libffi SDL2 mbedtls \ --pure --command 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
if you get an error that sdl2-config is missing (/usr/local/bin/sdl2-config: No such file or directory), you can install it using e.g. homebrew, like this: brew install SDL2
Older macOS installs have some missing headers: https://github.com/SHA2017-badge/Firmware/issues/99
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
