neopixel: Optimize the update loop

Optimize the transmit code so it can run on some slower ARM cpus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-07-12 23:39:00 -04:00
parent b7bc96c3b2
commit be2d0abbab
2 changed files with 42 additions and 46 deletions

View file

@ -25,7 +25,7 @@ class PrinterNeoPixel:
def build_config(self):
cmd_queue = self.mcu.alloc_command_queue()
self.neopixel_send_cmd = self.mcu.lookup_command(
"neopixel_send oid=%c data=%*s", cq=cmd_queue)
"neopixel_send oid=%c data=%u", cq=cmd_queue)
cmd_SET_NEOPIXEL_help = "Set the color of a neopixel led"
def cmd_SET_NEOPIXEL(self, params):
# Parse parameters
@ -35,11 +35,11 @@ class PrinterNeoPixel:
red = int(red * 255. + .5)
blue = int(blue * 255. + .5)
green = int(green * 255. + .5)
val = (green << 16) | (red << 8) | blue
# Send command
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
minclock = self.mcu.print_time_to_clock(print_time)
self.neopixel_send_cmd.send([self.oid, [green, red, blue]],
minclock=minclock)
self.neopixel_send_cmd.send([self.oid, val], minclock=minclock)
def load_config_prefix(config):
return PrinterNeoPixel(config)