Read Pixel Colour on Unicorn

Can I find the colour value of a pixel - is the state of the matrix stored somewhere?


Yes, it’s stored in a buffer in C. And I don’t believe I’ve exposed a “read” method- but it shouldn’t be too difficult to add one since I believe it’s already available in the ws2812 Python library which Unicornhat wraps.

If you clone the code from GitHub, find

Then stick this after the set_pixel method:

def get_pixel(x, y,):
  index = get_index_from_xy(x, y)
  if index != None:
    return ws2812.getPixelColor(index)

Then install!

I’ll test this and get it into the library properly, anyway.


Ta very much

As requested by @ukscone I’ve added a get_pixels method for… well… getting all the pixels!