adafruit / Adafruit-Raspberry-Pi-Python-Code

Adafruit library code for Raspberry Pi
1.43k stars 686 forks source link

Adafruit_8x8.py - addressing error in the ColorEightByEight class, setPixel() method. #66

Closed hybotics closed 10 years ago

hybotics commented 10 years ago

I found and fixed a problem with the setPixel() method that is fixed by adding the following code just under the line that reads "x %= 8" there. Without this patch, column 0 (x=0) is treated as column 7 (x=7). With this patch, all pixels are addressed correctly, from (0, 0) to (7, 7).

# This modification fixes the pixel addressing error
if (x == 0):
  x = 7
elif (x > 0):
  x = x - 1
# End of modification for the pixel addressing error

--> geekguy on Adafruit forums.

tdicola commented 10 years ago

Thanks for raising the issue and apologies it wasn't reviewed sooner. I tried reproducing the issue, but don't see any problems with the color 8x8 matrix writing to column 0. I modified the example to light each pixel at a time like:

  for x in range(0, 8):
    for y in range(0, 8):
      grid.clear()
      grid.setPixel(x, y, iter % 4 )
      time.sleep(0.5)

When run it appears that all the pixels are lit as expected. I'll close this issue for now, but if you still see problems feel free to add an example that repros it and I can investigate more. Thanks!