[personal profile] chebe
Some time ago I got myself an Adafruit LED Glasses Starter Kit. But other than turning it on and running the example code I hadn't done much with it. Then with the return of Congress I, of course, wanted all the LEDs, so I dug it out. First things first, how am I going to wear this?

The kit comes with lens-less glasses frames, but over my prescription glasses it's a bit too awkward. So I took an old set of overclip sunglasses and (violently) popped the rivets holding the nose-bridge clip in place, and, yes, hot-glued it to the LED front panel. (I also added some blobs in the corners to stop the panel whacking into my lenses too much.)


Back view of the LED front panel with overclip nose-bridge hot-glued in place.

Front panel with overclip nose-bridge hot-glued in place
Photo by [personal profile] chebe



Then what about the driver board? Adafruit's thingiverse has a few ideas. But I opted to go with this LED Glasses Driver BLE Sensor Board case, which I shortened the depth of to remove the space meant to contain a lipo battery. (I did need to acquire this 1cm wide velcro to make it work though.)


View of the lower power-port side of the 3d printed driver case, with board, wires, and velcro attached.

Slimmed down driver case, view of the lower face when worn
Photo by [personal profile] chebe




View of the upper and outside faces of the 3d printed driver case, with board, wires, and velcro attached.

Slimmed down driver case, view of the top and outer faces when worn
Photo by [personal profile] chebe




View, from the wearer's point of view, of my glasses, with the LED front panel attached via overclip nose-bridge, and driver case attached via velcro to the left arm.

Front panel and driver attached to my glasses
Photo by [personal profile] chebe



Okay, it's physically attached! Now, how do we program it? This is a circuit python device (which means using the Mu code editor). There are a lot of good details in the Learn guide. Except, I couldn't find the basic 'make LED blink' instructions, or a map of how to address specific LEDs. So I had to spend my time mapping it all out.

The front panel consists of;
- Two rings of LEDs, one left and one right, of 24 pixels each. Indexed 0-23.
- And one matrix of LEDs, width of 18, height of 5. Indexed [0-17, 0-4].

Note some of the LEDs are shared between the rings and matrix and can be addressed both ways. Also, not all the addresses in the matrix have a physical LED on the panel. I made a table. (I also know tables might not be that helpful in mapping onto the physical panels, so I also annotated a product photo, which you'll find at the end.)

Width (or x) along the top, height (or y) along the side.
'.' means, yep, there is an LED.
'x' means there is no physical LED to be found at that location.
Where LEDs in the matrix are shared with the rings, the ring location is provided. E.g. 'l20' is left 20 as well as [0,1], and 'r4' is right 4 as well as [17,1].

01234567891011121314151617
0xl21....l3....r21....r3x
1l20................r4
2l19......l5..r19......r5
3l18......l6..r18......r6
4l17......l7xxr17......r7


How then do we make the LEDs go in code? Well first you need to understand that the colour values used are packed rgb. Where each channel is 0-255, colour = (red << 16 | green << 8 | blue). (You can also modify the channel values to set brightness by multiplying by 0.0-1.0 before packing.)

There are convenience methods, like setting the entire ring to one colour;
glasses.left_ring.fill(colour)

But to set one LED in a ring, where n = 0-23;
glasses.left_ring[n] = colour
glasses.right_ring[n] = colour


(To mirror the left and right rings, you can always use 23-n for one of the rings.)

And to set one LED in the matrix, where x,y is from the table above;
glasses.pixel(x, y, colour)

And finally, to display your meddling, you need to call show;
glasses.show()

That's all I really had time to figure out at Congress. I do want to try using sprites as animations, and luckily Erin St Blaine has figured that all out for me in the meantime, which I will get to eventually.


Front view of the LED front panel with the ring addressable LEDs highlighted with colours, and the 22, 23, 0, 1, 2 LEDs of both the left and right rings numbered.

Front panel with ring LEDs highlighted
Photo by [personal profile] chebe




Front view of the LED front panel with the matrix addressable LEDs highlighted with colours, and the 0-17 columns and 0-5 rows numbered.

Front panel with matrix LEDs highlighted
Photo by [personal profile] chebe