The following steps are applicable only to development on Linux.
- Installing Poetry dependencies
- Install MicroPython firmware
- Understand the file structure
- Use either WebREPL or RShell
This project uses the Poetry dependency manager. Install that and run the following to install the poetry dependencies:
poetry installEnter the virtualenv created by Poetry:
poetry shellIdentify the serial port your Watchy is connected to:
python -m serial.tools.list_portsExample output:
/dev/ttyUSB0
1 ports foundIf the serial port is inaccessible, you may need to give yourself the necessary permissions:
sudo usermod -aG tty $USER
sudo usermod -aG dialout $USER
# re-enter your shell
exec su -l $USER
cd watchy_py
poetry shellDownload the latest stable MicroPython firmware.
Proceed to install the new firmware:
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 ~/Downloads/esp32-20220618-v1.19.1.binThere are 2 main MicroPython scripts:
- boot.py: this is run immediately after the Watchy boots up and by convention contains only code initialising debuggers, REPLs, etc.
- main.py: this is run immediately after
boot.pyruns and should contain your application code. You can import other dependencies in this file.
You can use MicroPython's webrepl to develop wirelessly over WiFi.
Install RShell and run the RShell development scripts to install the MicroPython firmware and transfer the files from this repository onto the board.
Rename src/secrets.example.py to src/secrets.py and fill in the secrets appropriately.
You can use rshell to run Python scripts on the Watchy.
python shell
rshellAnd then within rshell's interactive prompt, connect to the Watchy:
connect serial /dev/ttyUSB0You can then access the Watchy's filesystem:
ls /pyboard
cp src/main.py /pyboard/Or even edit a file directly on the Watchy:
edit /pyboard/main.pyYou can get a Python REPL prompt over the serial port:
replThe controls are emacs-style, so use [C-x], i.e. Ctrl-A Ctrl-X.
Useful development commands:
./scripts/flash_micropython.sh # to re-flash micropython firmware if the MCU freezes up
./scripts/flash_src.sh # to transfer and run new files in a single commandSince the reset pin on Watchy isn't easily accessible, you may want to do the following using rshell:
cp reset.py /pyboard/
repl ~ import reset ~- Fonts: peterhinch/micropython-font-to-py
./scripts/font-to-py.py -x input.ttf <font_size> out.py
- Images: image2cpp
