Adding functionality to the python Glowbit library

Hey Guys,

First post here, I’m working on expanding the functions of the Glowbit library to address neopixel’s on the 8x8 and 16x16 matrix’s (also the 8 x 32) that are wired in serpentine fashion.

As I’m impressed with the ease of use the library provides for addressing individual neo pixels to do pixel art. Plus I want to avoid using a WLED controller and JSON calls to address the matrix’s as the Glowbit library is a far more efficient way to address neo pixels on a Raspberry Pi so have decided to expand it.

The reason I’m doing this is so I can use them to have an animated banner for an Arcade I am building. I’ll be doing a video over the changes to the library so others can use it to do pixel art on the Pi and with other Neo Pixel matrix’s

You can find my channel here Paul's Engineering Space - YouTube

So Talk Soon, and Please be kind and Subscribe, I could do with the Support!


Hey Paul,

Glad to hear you are finding our library and matrixes to be useful for your project! It sounds like an awesome use of those components and I cant wait to see how it turns out!


1 Like

Hi Paul! Welcome to the forums :smiley:
It’s great to hear you’re having a good time with the GlowBit libraries, and we always welcome contributions to the repo.

The GlowBit library supports custom mapping already! You just need to provide a map function during initialisation using the mapFunction argument, eg:

matrix = glowbit.matrix4x4(pin = 18, mapFunction = my_map)

You need to define a map function that accepts arguments (x,y) and return the LED index that correlates to those coordinates.

For example, a zig-zag or serpentine 4x4 LED matrix would have the X-Y → Index map that looks like this diagram:

and you might choose to initialise this mapping in the following way:

def zig_zag_4x4(x,y):
    if y == 0: return 0 + x
    elif y == 1: return 7 - x
    elif y == 2: return 8 + x
    elif y == 3: return 15 - x
matrix = glowbit.matrix4x4(pin = 18, mapFunction = zig_zag_4x4)

now the setPixelXY() function ought to map correctly to the physical X-Y LED :slight_smile:

This will work with the existing 4x4 and 8x8 and should give you a flying start on working with other matrix dimensions. GlowBit doesn’t yet have a class for matrices of arbitrary dimensions… We just baked fixed classes for the two products that we produce in an attempt to make things simple for beginners.

Let us know how you go!
Happy making

PS the arcade HAT on your channel looks great! Do keep us posted on your progress :smiley:


Thanks for the more detailed explanation, I could not find this in the documentation that came with the library. But I’ll still work on updating the library, my best mate, is giving me a hand, and he knows python very well as my code language of choice is C/C++.

But I might focus my efforts by increasing the flexibility of the class definition so you only need to pass a few key variables.

On another note, I found some assist documents written for use with WLED and in the process of adapting it to work with the Glowbit Library to do pixel art


Some pics of the Arcade HAT build So far I’ll have a video dropping in the coming days


I have the build video uploaded Arcade HAT Build - YouTube


So I got an offer out of the blue from a Representative of PCBWay, and has offered me free PCB manufacture of my next project, as they were apparently impressed with my Circuit design skills and Soldering. I’m only a small channel at the moment.

What do you guys think?


Hi Paul,

I haven’t used PCBWay myself so I can’t speak from personal experience to their PCB milling however I have noticed a few very niche combat robotics youtube channels are getting sponsorship from them lately. Ultimately only you will know if accepting sponsorship is the right fit for what you want to achieve with your channel but it is certainly an interesting opportunity.
Always good to know someone likes your designs and soldering at the very least :slight_smile:


So an update, I was testing the board, and found an error in the board manufacture is affecting its operation and the D Type flip-flops where not functioning as intended, not to mention the 1MHz clock from a 555timer ended up running at 230kHz instead of 1MHz

So considering ATMega328’s are back in stock, I’m adjusting the design to go back to using the MCU and I’m also adding an additional screw header to allow easy connection of neo pixels

I have PCB Way making the new boards for me, but by going back to a MCU I can limit the design to a double sided board


I just finished speaking with PCB Way once I have the project working and finialised, it will be available as a kit from there website.

I did ask my representative at PCB Way if core (if they wanted to) wanted to look into stocking the kit, they are welcome to place a bulk order, once it becomes available, or access the details on my github.


So I’ve been working on trying to get my banner working on the Arcade but I’m running into a syntax error when i go to run the script in the cmdline, as I will eventually have it running in the background

But I’m having a hard time understanding the syntax error its throwing as im still learning python when my language of choice is C.

Syntax error as follows from the SSH cmdline

pi@retropie:~/RetroPie/banner $ python
Traceback (most recent call last):
  File "", line 1, in <module>
    import glowbit
  File "/home/pi/RetroPie/banner/", line 59
    def wheel(self, pos: int) -> int:
SyntaxError: invalid syntax

Could I get some feedback as to what error I am running into so I can correct it.

And move forward with writing the script to run the arcade banner. See picture attached of arcade with banner

oh here is my code just incase it helps
banner code (17.5 KB)

1 Like

Hi @Celcius1 - i’m sorry this post seemed to have slipped through the cracks.

Did you ever resolve this?
try executing python3 instead to guarantee that Python3 is being used instead of Python2.7

you may also need to execute with sudo if prompted

Hi Michael,

I never did, been focusing on trying to resolve the controller input, with retropie