Zwiftendo: Zwift + Nintendo ( I know! super witty) is a small Zwift remote that can be attached to your head unit. The idea being, to make a small bar-mounted controller to fully interact with my laptop while riding. I could then pull my bike further away and no longer have my precious laptop and keyboard in the splash zone. When riding indoors, I'm most often doing structured workouts or races and always have Spotify pumping tunes or a very "highbrow" podcast. So functionally, the Zwiftendo needs to be able to:
- Simulate arrow keys to control the Zwift in-game menu, probably using a "blackberry" like trackball input.
- Control laptop media buttons. Play/pause, skip to the next track.
- Run from battery power for 8+ hours ( just in case I ever want to be on Zwift that long :P ).
- Easily mountable on a Garmin like head unit mount.
- A way to cycle through Zwift rider views.
- A way to increase or decrease FTP bias during workout mode ( not sure yet if this will be possible ).
- A simple way to trigger a power-up during a race.
- Open Zwift on my external LCD and start a default Spotify playlist when zwiftendo starts up.
- Be hella sweatproof!
The Current State:
In its current form, a successfully paired Zwiftendo will launch both Zwift and Spotify (primed with a playlist of your choice) when you click the "Start" button. This is currently done via a macOS automator script I wrote which listens for a specific key combination from the Zwiftendo BLE keyboard. We can also control the media keys for PLAY/PAUSE and SKIP track on Spotify. I also wired up two other buttons, one is setup to be able to easily trigger a powerUP in Zwift. I figure this will be pretty useful when doing races. The second allows one to skip a block in a structured workout session. Hopefully won't have to use this one too many times :)
The blackberry style trackball covers a few features. The central RGB led is lit green when the device first powers up and will transition to blue once a bluetooth connection is esstablished with the laptop. The central led is also a button which acts as the "Enter/Return" key to allow us to select things and start riding. Obviously the directional rolling of the trackball maps to arrow keys and allows us to control the menu items in-game. You can checkout how this all works in the short demo ride below:
Finally, the whole thing is powered from a 3.7v 1200mah LiPo battery and its set to light up the nrf52480 onboard neopixel RGB led red when the battery level drops lower than 15%. I also have it periodically updating the bluetooth battery level profile. However, sadly for some reason macOS doesn't appear to display that battery level for most of my BLE devices. The only one that has a reliable battery level indicator is my apple keyboard. So perhaps they are doing something non-standard there...
Issues and UX:
If you watched the demo you might have noticed a few issues. One being that my gears sound a bit janky and yes I definitely need to put some time into sorting that. You also might have noticed that some of the button presses were not detected, I think this is because currently its programmed to be just a dumb loop, scanning through all the buttons each time and then sleeping for a bit of time. So if you happen to press during the sleep portion or while other buttons are being checked, then you are shit out of luck!
Another problem UX wise is with the trackball. It's much more clumsy and difficult to use than I expected. So even though it looks cool and I love the central RGB led, I'm gonna try replace it with something more akin to a thumb controller.
Finally, I also seem to have some sort of heisenbug with the battery level detection and indication. It's a bit of a pain to try debug because it only happens when the battery is low and the serial cable is unplugged (so that its not charging). Some part of that detection occasionally fails and throws the Zwiftendo into a boot loop. I haven't managed to get any logs yet but might have to find a way to persist the logs to the device so I can debug it since I can't use the serial output.
[UPDATE]: For now I have shelved the Zwiftendo project because I am no longer riding on Zwift...