I recently purchased the Bicolor LED matrix with i2c backpack for my raspberry pi, but it cannot get it to work properly. I run the ex_8x8_pixels.py file, but the coordinates aren't quite right. The x coords from left to right are 1-7 then the last column is 0 (zero).
Also the Adafruit Learning System explains the bicolors are controlled as an 8x16 matrix. I've tried setting both coordinates in range 0 - 16 but only the green LEDs light up.
Any suggestions?
Raspberry PI and Bicolor Matrix
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- tacoma
- Posts: 15
- Joined: Fri Nov 30, 2012 9:27 pm
Re: Raspberry PI and Bicolor Matrix
Well I solved the problem. The setPixel function in the Adafruit_8x8.py wasn't completely compatible so I wrote a setBicolorPixel() function.
Here is the code for anyone who wants it:
#color: 0=clear 1=green 2=red 3=orange
def setBicolorPixel(self, x, y, color=1)
if(x >=8):
return
if(y >= :
return
buffer = self.disp.getBuffer()
rowBuffer = buffer[y]
if color == 0:
rowBuffer &= ~(1 << x)
if color == 1:
rowBuffer |= 1 << x
if color == 2:
rowBuffer &= ~(1 << x)
x += 8
rowBuffer |= 1 << x
if color == 3:
rowBuffer |= 1 << x
x += 8
rowBuffer |= 1 << x
self.disp.setBufferRow(y, rowBuffer)
Here is the code for anyone who wants it:
#color: 0=clear 1=green 2=red 3=orange
def setBicolorPixel(self, x, y, color=1)
if(x >=8):
return
if(y >= :
return
buffer = self.disp.getBuffer()
rowBuffer = buffer[y]
if color == 0:
rowBuffer &= ~(1 << x)
if color == 1:
rowBuffer |= 1 << x
if color == 2:
rowBuffer &= ~(1 << x)
x += 8
rowBuffer |= 1 << x
if color == 3:
rowBuffer |= 1 << x
x += 8
rowBuffer |= 1 << x
self.disp.setBufferRow(y, rowBuffer)
-
- Posts: 2
- Joined: Wed Dec 05, 2012 3:28 am
Re: Raspberry PI and Bicolor Matrix
Maybe this is due to these 2 lines in the function setPixel(self, x, y, color=1) of the class EightByEight (possibly a remnant of the rotation support in the arduino Adafruit_LEDBackpack library , method Adafruit_8x8matrix::drawPixel() )reddakota wrote:...
I run the ex_8x8_pixels.py file, but the coordinates aren't quite right. The x coords from left to right are 1-7 then the last column is 0 (zero).
...
Any suggestions?
Code: Select all
x += 7
x %= 8
- tacoma
- Posts: 15
- Joined: Fri Nov 30, 2012 9:27 pm
Re: Raspberry PI and Bicolor Matrix
I created a git fork of Adafruits code. Fixed a bug with the code I posted above. I will upload a bicolor_8x8_ex.py soon for anyone interested.
https://github.com/reddakota/Adafruit-R ... ython-Code
https://github.com/reddakota/Adafruit-R ... ython-Code
Please be positive and constructive with your questions and comments.