Skip to content

Commit

Permalink
fix pixel functions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjgibson committed Nov 9, 2012
1 parent d7789e6 commit d092276
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lightingPi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def __str__(self):
ret += "DMX Channel (start): %d\n" % self.dmx_channel_start
ret += "DMX Channel (end): %d\n" % self.dmx_channel_end
ret += "Num Leds: %d\n" % self.num_leds
ret += "Leds per channel: %d\n" % self.leds_per_channel
if self.type == 'rbg_pixel':
ret += "Leds per channel: %d\n" % self.leds_per_channel
return ret

def default_handler(self,data):
Expand All @@ -105,7 +106,7 @@ def rgb_pixel_chase_handler(self, dmx_data):
data.append(WHITE)
for i in range(self.num_leds - position):
data.append(BLACK)
controller.send_spi(data)
self.send_spi(data)

def rgb_pixel_chase_fill_handler(self, dmx_data):
data = []
Expand All @@ -116,7 +117,7 @@ def rgb_pixel_chase_fill_handler(self, dmx_data):
data.append(WHITE)
for i in range(self.num_leds - position):
data.append(BLACK)
controller.send_spi(data)
self.send_spi(data)

def calculateGamma(self):
# Calculate gamma correction table. This includes
Expand Down Expand Up @@ -165,7 +166,7 @@ def send_spi(self, data):
if controller.verbose:
print "sending ",data
bytedata = self.getBytes(data)
pixels_in_buffer = len(data) / PIXEL_SIZE
pixels_in_buffer = len(data)
pixels = bytearray(pixels_in_buffer * PIXEL_SIZE)
for pixel_index in range(pixels_in_buffer):
pixel_to_adjust = bytearray(bytedata[(pixel_index * PIXEL_SIZE):((pixel_index * PIXEL_SIZE) + PIXEL_SIZE)])
Expand Down Expand Up @@ -214,15 +215,15 @@ def parseConfigFile(self, configFile):
new_fixture.mode = config.get(fixture_name, 'mode')
new_fixture.spi_bus = config.get(fixture_name, 'spi_bus')
new_fixture.chip_type = config.get(fixture_name, 'chip_type')
new_fixture.leds_per_channel = config.getint(fixture_name, 'leds_per_channel')
new_fixture.num_leds = config.getint(fixture_name, 'num_leds')
new_fixture.dmx_channel_start = config.getint(fixture_name, 'dmx_channel_start')
new_fixture.dmx_channel_end = config.getint(fixture_name, 'dmx_channel_end')
if new_fixture.mode == 'dimmer':
new_fixture.leds_per_channel = config.getint(fixture_name, 'leds_per_channel')
new_fixture.handler = new_fixture.rgb_pixel_handler
if new_fixture.mode == 'chase':
new_fixture.handler = new_fixture.rgb_pixel_chase_handler
if new_fixture.mode == 'chase':
if new_fixture.mode == 'chase_fill':
new_fixture.handler = new_fixture.rgb_pixel_chase_fill_handler
new_fixture.calculateGamma()
if type == 'pca9685':
Expand Down

0 comments on commit d092276

Please sign in to comment.