Sound-programmable e-paper badge with USB serial programming and 125 kHz RFID emulation

Oct 10, 2023

Project update 7 of 8

Extending and Customizing GGtag

by Radoslav Gerganov

Greetings, everyone!

In this week’s update, we will dive into a bit of how GGtag works and how you can extend it for your own needs.

Project Structure

The project is split into several directories:

Component Diagram

Notice how we reuse the same source code for the device and the web interface. This is possible thanks to the Emscripten compiler which allows us to compile C code into WebAssembly and JavaScript.

Data Protocol

GGtag uses the same data protocol for sound and USB programming. The protocol encodes a series of commands into binary stream which is prefixed by two bytes which specify the size of the stream. The entire payload has the following format:

[SIZE (2 bytes)] [CMD1] [CMD2] [CMD3] ... [CMDn]

The SIZE is encoded as a big-endian, 16-bit unsigned integer. At most SIZE bytes follow which represent the commands.


Each command has the following format:

[CMD_CODE (4 bits)] [ARG1] [ARG2] ... [ARGn]
0000TEXT_CMDDraw text
0001RECT_CMDDraw rectangle
0010FILL_RECT_CMDDraw filled rectangle
0011CIRCLE_CMDDraw circle
0100FILL_CIRCLE_CMDDraw filled circle
0101LINE_CMDDraw line
0110QRCODE_CMDDraw QR code
0111IMAGE_CMDDraw image
1000ICON_CMDDraw icon
1001RFID_CMDProgram RFID
1010RLE_IMAGE_CMDDraw RLE image

The commands are executed in the order they are received. The display is cleared before the first command is executed.

You can find the full protocol documentation in our GitHub repo.

Extending the Protocol

Let’s say we want to add a new command for drawing an ellipse. It will have CMD_CODE=11 (or 1011 in binary) and the following arguments:

ARG#DescriptionSize (bits)
1center X coordinate9
2center Y coordinate8
3X Radius7
4Y Radius7

The complete implementation of this new command is less than 150 lines of code. You can find it in the ellipse branch of the repository. Here is a short summary of the changes:

Finally, you’ll need to rebuild everything by following the instructions in the README and flashing the new firmware to the device.

Happy hacking!

Should you have any questions, please feel free to reach out to us using the "Ask a technical question" link on our campaign page or participate in our GitHub discussions! And, if you haven’t claimed your own GGtag yet, there’s still time while our campaign is live!

Until next time!

Sign up to receive future updates for GGtag.

GGtag is part of Microchip Get Launched

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects