Written by Lup Yuen Lee, a Techie and Educator in IoT. For more content like this, please visit his blog.
PineTime works great with Zephyr, the open source Real-Time Operating System (RTOS). Think of PineTime as a supercharged BBC micro:bit (or Arduino Uno) that comes with Bluetooth LE, colour LCD display (240 x 240), touchscreen, heart rate sensor and accelerometer.
PineTime is incredibly hackable: Flash our own firmware, build our own watch faces, render graphics on the touchscreen, … The PineTime FOSS Community is always happy to help you hack PineTime!
C is the most common language for coding PineTime. If you’re familiar with Python, try coding PineTime with MicroPython on wasp-os.
If you’re into cutting edge coding, check out Rust Embedded (and Real Time For the Masses) on PineTime.
Some PineTime wiring needed
PineTime ships as a Developer Kit… Get ready to do some wiring!
Some newbies find it tricky to connect to the SWD Port inside PineTime, please chat with us online for tips.
I recommend using a Raspberry Pi to remove Flash ROM protection from PineTime (this step is mandatory), also to flash and debug the PineTime firmware.
Advanced firmware coders will find ST-Link V2 more efficient for flashing and debugging the firmware. (Though ST-Link V2 can’t be used for removing Flash ROM protection)
Check out the PineTime Updater for wired flashing
Wireless tools are coming
Programming PineTime the wired way sounds tedious, but we’re heading the wireless way…
After installing the wasp-os or Arduino firmware on PineTime (the wired way), we may update the wasp-os / Arduino firmware wirelessly over Bluetooth LE. (wasp-os also exposes the REPL interface wirelessly)
The PineTime FOSS Community is now extending this wireless capability to other types of PineTime firmware, like FreeRTOS, Mynewt and Zephyr.
We have ported to PineTime the open source MCUBoot Bootloader, and we have to hope to have it preloaded on PineTime watches soon.
The new bootloader will let you switch firmware wirelessly, like from Mynewt to FreeRTOS. Great for trying out all kinds of experimental firmware created by the PineTime FOSS Community!
With firmware updates over Bluetooth LE, PineTime programming will become so much easier!
PineTime Companion App
Today we use a mix of mobile apps for firmware flashing and data syncing with PineTime, like DaFlasher and nRF Connect.
The open source PineTime Companion App is under development now. It will run on Android and iOS (via Flutter) and on Linux phones like PinePhone (via GOTK3). It will probably run on Raspberry Pi and Pinebook Pro too!
The Companion App will update PineTime firmware, sync the date and time, chart your heart rate, push your mobile notifications to PineTime, … And let you control your smart home gadgets with PineTime!
Check out the PineTime Companion App
Building PineTime Firmware in the Cloud
Programming the firmware of our gadgets (like PineTime Smart Watch) has always been cumbersome…
- Get a proper computer (Windows tends to be problematic)
- Install the right tools and libraries to cross-compile our firmware (Depends on our operating system)
- If the build fails, tweak the build scripts (It’s probably just Windows)
- If the build still fails… We’re stuck!
Now we have a new way to build firmware in the Cloud with GitHub Actions…
- Create a fork of the PineTime source code repository in GitHub
- Check in our updated source files to GitHub
- Wait 2 Minutes
- Out comes a piping-hot New Firmware Image for testing on PineTime!
Check out GitHub Actions for PineTime
Programming with PineTime
Assuming that we know C++, the easiest way to start coding is to look at the existing PineTime code and tweak it!
- Follow the instructions in this article…
Build PineTime Firmware in the Cloud with GitHub Actions - Go ahead and create a Fork of the PineTime Source Code in GitHub, as explained in the doc…
Create a Fork - Add the
main.yml
file, like the doc says…
Add GitHub Actions - According to the doc we’ll edit a C++ source file:
Clock.cpp
When we change the message to"LOVE"
, we’re actually changing the PineTime Watch Face, modifying the way it operates…
Modify the Source Code - Study the C++ code inside
Clock.cpp
Ponder, meditate and understand how the Watch Face is rendered.
All functions and objects namedlv_...
come from the LVGL LibraryWe call the LVGL Library to render Widgets on the Watch Face, like Buttons and Labels.
LVGL Documentation - When we’re ready, make some changes to the source code in
Clock.cpp
to create our own PineTime Watch Face.
GitHub will automatically recompile the firmware.
We’ll find the results of the compilation under theActions
section of our GitHub Fork.
Our Firmware Build
This runs all in the Cloud, so we don’t even need a PineTime to create our own Watch Face!
(But of course we’ll need a PineTime to actually see our custom PineTime Watch Face 😀 )
What’s Next
The PineTime FOSS Community has accomplished so much over the past 6 months because we’re all volunteers passionate about PineTime.
You’re welcome to join us and make the open source PineTime software even better!