Programming Resources

LED Bitmask Tool

Adafruit sells a variety of popular LED displays that are widely used by the maker community. A few of the most popular displays are:

In addition to the displays, Adafruit provides robust Arduino libraries and a helpful tutorial on how to setup and use the displays in your project. Still, getting the correct segments to light-up requires construction of a bitmask which can be a bit of a chore if you are creating a large number of custom characters or messages in your project.

A LED 'bitmask' is simply a binary number where each bit indicates whether a specific segment of the display is lit or not. The binary number (or sometimes its hexadecimal equivalent) is passed to a library function to drive the display. The different types of displays require a different number bits (8 for the 7-segment, 15 for the alphanumeric, and 64 for the 8x8 matrix) and each has a unique mapping of segments to bits. The diagram below shows the LED segment mapping for these three display types (click for a larger version):

LED segement mapping diagrams

The LED Bitmask Tool is a small Windows and Linux utility to help create custom bitmasks for use with the Adafruit displays and libraries. It lets you toggle the segments on and off and automatically updates the resulting bitmask. A screenshot of the utility is shown below (click for a larger version):

LED Bitmask Tool main screen

Installation

A Windows installer is available below, simply download and run the setup file to install the LED Bitmask Tool on your system. A shortcut for the program will be created in your Start Menu and on your Desktop. Alternatively, and for Linux, the LED Bitmask Tool can be downloaded as a zip file, extracted to a location of your choice, and manually started by executing the LEDBT executable.

How to Use

When started, the tool shows a section with a blank (all segments off) representation of each type of display. The three display sections operate independently of each other. To create a new character or pattern, simply click on a segment to toggle it on or off. As segments are toggled, the bitmask of each type is updated and shown in the text field below the display. The radiobox at the bottom left sets the bitmasks to be in binary, hexadecimal or decimal format.

Export / Import

The button to the right of each bitmask text field exports the bitmask (copying it to the clipboard) in the currently selected format. These values can be utilized directly with the Adafruit libraries for the displays. The button to the left of each bitmask text field imports a bitmask from the clipboard - the format does not need to match the currently selected format.

All Displays

As an aid, each display type has a fill button [F], which turns on all segments, and a clear button [C], which turns off all segments.

8x8 Matrix Display

The section for the 8x8 matrix has a few extra buttons:

In addition, if the Shift key is pressed when a segment is toggled, the entire horizontal line of the matrix will be affected. Likewise, if the Control key is pressed when a segment is toggled, the entire vertical line of the matrix will be affected.

Source

The source code for the LED Bitmask Tool can be obtained from GitHub:

https://github.com/dfgtec/LED-Bitmask-Tool

Note: The utility is written using Xojo, which is a cross platform, rapid development programming language. Why Xojo? I'm an engineer, not a programmer and Xojo allows me to quickly produce utilities without getting hung up on IDEs, tech stacks, frameworks, etc.



License

The source code available from GitHub and resources available from this page are licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

Created: 29 Apr 2022
Last updated: 13 May 2024