Post

FOSSASIA Badge Magic Open Firmware

Google Summer of Code 2024 - Final Submission Report

Project Overview

LED name badges are small matrix LEDs that can be written text, and images, and create animations over Bluetooth or USB connection. The Badge Magic app is an open-source app used to send data to these LED badges. However, the app is still limited and depends on these LED badge features. This project aims to implement an open-source firmware for this type of LED Badge that uses a CH582 microcontroller, adds more features, as a base example for later hacks, and merges it to the badgemagic-firmware repo of FOSSASIA.

Goals

  • Receiving bitmap data from the app over BLE.
  • Receiving bitmap data over USB.
  • Saving bitmap data to flash.
  • Displaying bitmap on screen.
  • Animations: scroll leftwards, scroll , scroll up, scroll down, fixed, “animation”, “snowflake”, “picture”, “laser”.
  • Buttons: turning on, turning off, entering Bluetooth download mode, adjusting brightness.
  • Firmware Optimizing for low-power.
  • Repurposing the LED Badge to an audio visualizer over Bluetooth.
  • Drawing a schematic and creating a BOM list for referencing.
  • Documentation for the firmware.

Accomplishments

The firmware now is capable of:

  • Receiving bitmap data from the app over BLE.
  • Having two 2 USB Composite Devices: HID and CDC-ACM.
  • Receiving bitmap data over USB HID and CDC-ACM.
  • Saving bitmap data to flash.
  • Displaying bitmap on screen.
  • Animations: scroll leftwards, scroll , scroll up, scroll down, fixed, “animation”, “snowflake”, “picture”, “laser”.
  • Additional animations for hardcoded bitmap: scroll up, scroll down, infinite scroll.
  • Animation and display version on charging state.
  • Buttons: turning on, turning off, entering Bluetooth download mode, adjusting brightness.

I designed a open source hardware and a case along the way:

  • Improved its design, made a PCB.
  • Added a microphone to turn the badge to an audio visualizer.
  • Wired the UART logging port to USB-C for a handy debugging instead of opening the case.
  • Made a 3D case design.

Documentation for the firmware.

What’s left

I’ve exceeded designing a open source hardware and a case along the way. But this cost more time and so was not completed the audio visualizer.

Contributions

Community Bonding Period

Coding Period

Phase 1

Phase 2

Other Contributions

Conclusion

What did I learn

Bare-metal USB Device Implementation: At the moment, tinyusb doesn’t support the CH582 chip. I implemented the USB device from the ground up without using any framework, which helped me better understand the USB protocol layer. Implementing a USB device on a bare-metal USB peripheral has always been on my learning list.

USB Device Class Implementation: I had basic experience working with USB HID devices using Obdev V-USB, but only manipulating data at the higher level of the HID layer. Throughout this project, I implemented both a USB HID and a USB CDC-ACM. This required studying the specifications to configure and understand the topology of each class.

BLE GATT and ATT Layer: Before this project, I had worked with BLE in a couple of projects but at a higher abstraction level. However, this project’s bare-metal BLE implementation allowed me to deepen my understanding of the GATT and ATT layers.

Git Force Push: Before joining GSoC for this project, I studied several projects, but they’re using mailing lists. For patches that needed improvements, contributors would resend updated versions to the list. I didn’t know how GitHub’s PR workflow worked until my mentor told me to use git rebase -i and force push.

Communication: Before GSoC, I wasn’t familiar with how to contribute to a GitHub-hosted project, and I was initially hesitant to do so.

Collaboration: I learned how to properly use Scrum. The weekly meetings were highly effective in setting clear goals for the next steps.

Future Work

The work that left: Repurpose the LED Badge to an audio visualizer.

The ideas that came up, while doing this project, some of them were posted on the repo’s issue:

The piece of hardware wating to get used: Using microphone on the badgemagic-hardware to implement the audio spectrum visualizer.

Images

FOSSASIA Badge Magic LED's charging animation Charging animation

FOSSASIA Badge Magic Hardware: First PCB test batch Badge Magic Hardware: first test batch

FOSSASIA Badge Magic Hardware: Second PCB test batch Badge Magic Hardware: second test batch

This post is licensed under CC BY 4.0 by the author.