Skip to content

Commit

Permalink
FIX ALL THE ERRORS
Browse files Browse the repository at this point in the history
  • Loading branch information
cibomahto committed May 12, 2012
1 parent d267b3e commit 2f06080
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
45 changes: 22 additions & 23 deletions host/LedStrips.py
Expand Up @@ -29,28 +29,29 @@ def RgbRowToStrips(self, data):

output = ''

# Blue byte

# Green byte
output += '\xFF'
for bit_index in range(7, 0, -1):
c = 0x00
for pixel_index in range(0, 8):
c |= (ord(data[2+3*pixel_index]) >> bit_index & 1) << pixel_index
c |= (ord(data[1+3*pixel_index]) >> bit_index & 1) << pixel_index
output += chr(c)

# Green byte
# Red byte
output += '\xFF'
for bit_index in range(7, 0, -1):
c = 0x00
for pixel_index in range(0, 8):
c |= (ord(data[1+3*pixel_index]) >> bit_index & 1) << pixel_index
c |= (ord(data[3*pixel_index]) >> bit_index & 1) << pixel_index
output += chr(c)

# Red byte
# Blue byte
output += '\xFF'
for bit_index in range(7, 0, -1):
c = 0x00
for pixel_index in range(0, 8):
c |= (ord(data[3*pixel_index]) >> bit_index & 1) << pixel_index
c |= (ord(data[2+3*pixel_index]) >> bit_index & 1) << pixel_index
output += chr(c)


Expand Down Expand Up @@ -100,23 +101,21 @@ def draw(self, data, width):
data = ''
for row in range (0, options.strip_length):
for col in range (0, image_width):
if j == 0:
data += chr(0x0) # B
data += chr(0x0) # B
data += chr(0x0) # B
else:
if ((row+j)%3 == 0):
data += chr(j) # B
data += chr(0) # B
data += chr(0) # B
if ((row+j)%3 == 1):
data += chr(0) # B
data += chr(j) # B
data += chr(0) # B
if ((row+j)%3 == 2):
data += chr(0) # B
data += chr(0) # B
data += chr(j) # B
if ((row+j)%3 == 0):
data += chr(0xFF) # B
data += chr(0) # B
data += chr(0) # B
if ((row+j)%3 == 1):
data += chr(0) # B
data += chr(0xFF) # B
data += chr(0) # B
if ((row+j)%3 == 2):
data += chr(0) # B
data += chr(0) # B
data += chr(0xFF) # B
# data += chr(0xFF) # B
# data += chr(0xFF) # B
# data += chr(0xFF) # B

i = (i+1)%20
if i == 0:
Expand Down
2 changes: 1 addition & 1 deletion host/domelistener.py
Expand Up @@ -33,7 +33,7 @@ def __init__(self, port_name, offset):
def run(self):
while True:
command = self.q.get()
self.strip.draw(data,image_width)
self.strip.draw(command,image_width)
self.q.task_done()


Expand Down

0 comments on commit 2f06080

Please sign in to comment.