dotstar: Allow any number of chips to be daisy chained

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-08-06 22:45:02 -04:00
parent 115b888106
commit 9445e1d555
1 changed files with 5 additions and 3 deletions

View File

@ -22,7 +22,7 @@ class PrinterDotstar:
clock_pin_params['pin']) clock_pin_params['pin'])
self.spi = bus.MCU_SPI(mcu, None, None, 0, 500000, sw_spi_pins) self.spi = bus.MCU_SPI(mcu, None, None, 0, 500000, sw_spi_pins)
# Initial color # Initial color
self.chain_count = config.getint('chain_count', 1, minval=1, maxval=12) self.chain_count = config.getint('chain_count', 1, minval=1)
red = config.getfloat('initial_RED', 0., minval=0., maxval=1.) red = config.getfloat('initial_RED', 0., minval=0., maxval=1.)
green = config.getfloat('initial_GREEN', 0., minval=0., maxval=1.) green = config.getfloat('initial_GREEN', 0., minval=0., maxval=1.)
blue = config.getfloat('initial_BLUE', 0., minval=0., maxval=1.) blue = config.getfloat('initial_BLUE', 0., minval=0., maxval=1.)
@ -38,8 +38,10 @@ class PrinterDotstar:
self.cmd_SET_LED, self.cmd_SET_LED,
desc=self.cmd_SET_LED_help) desc=self.cmd_SET_LED_help)
def send_data(self, minclock=0): def send_data(self, minclock=0):
self.spi.spi_send(self.color_data, minclock=minclock, data = self.color_data
reqclock=BACKGROUND_PRIORITY_CLOCK) for d in [data[i:i+20] for i in range(0, len(data), 20)]:
self.spi.spi_send(d, minclock=minclock,
reqclock=BACKGROUND_PRIORITY_CLOCK)
cmd_SET_LED_help = "Set the color of an LED" cmd_SET_LED_help = "Set the color of an LED"
def cmd_SET_LED(self, params): def cmd_SET_LED(self, params):
# Parse parameters # Parse parameters