Project update 7 of 7
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.
The project is split into several directories:
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]
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]
|Draw filled rectangle|
|Draw filled circle|
|Draw QR code|
|Draw 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.
Let’s say we want to add a new command for drawing an ellipse. It will have
1011 in binary) and the following arguments:
|1||center X coordinate||9|
|2||center Y coordinate||8|
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:
docs/...- trivial changes to the web interface
host/src/ggtag.cpp- parsing the text command into the binary protocol
shared/include/protocol.h- adding the new command
shared/src/GUI_Paint.c- drawing an ellipse
shared/src/protocol.cpp- parsing the binary protocol
Finally, you’ll need to rebuild everything by following the instructions in the README and flashing the new firmware to the device.
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!
GGtag is part of Microchip Get Launched