MicroPython for the Calliope mini
This is the source code for MicroPython running on the Calliope mini!
Various things are in this repository, including:
- Source code in source/ and inc/ directories.
- Example Python programs in the examples/ directory.
- Tools in the tools/ directory.
The source code is a yotta application and needs yotta to build, along with an ARM compiler toolchain (eg arm-none-eabi-gcc and friends).
Ubuntu users can install the needed packages using:
sudo add-apt-repository -y ppa:team-gcc-arm-embedded sudo add-apt-repository -y ppa:pmiller-opensource/ppa sudo apt-get update sudo apt-get install cmake ninja-build gcc-arm-none-eabi srecord libssl-dev pip3 install yotta
Once all packages are installed, use yotta to build. You will need an ARM mbed account to complete the first command, and will be prompted to create one as a part of the process.
Use target bbc-microbit-classic-gcc-nosd:
yt target bbc-microbit-classic-gcc-nosd
Run yotta update to fetch remote assets:
Start the build:
The resulting calliope-micropython.hex file to flash onto the device can be found in the build/bbc-microbit-classic-gcc-nosd/source from the root of the repository.
There is a Makefile provided that does some extra preprocessing of the source, which is needed only if you add new interned strings to qstrdefsport.h. The Makefile also puts the resulting firmware at build/firmware.hex, and includes some convenience targets.
How to use
Upon reset you will have a REPL on the USB CDC serial port, with baudrate 115200 (eg picocom /dev/ttyACM0 -b 115200).
>>> import calliope_mini >>> calliope_mini.display.scroll('hello!') >>> calliope_mini.button_a.is_pressed() >>> dir(calliope_mini)
Tab completion works and is very useful!
You can also use the tools/pyboard.py script to run Python scripts directly from your PC, eg:
$ ./tools/pyboard.py /dev/ttyACM0 examples/conway.py
Be brave! Break things! Learn and have fun!