neopixel: Improve timing of gpio bit-banging

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2019-07-17 16:36:28 -04:00
parent 0af5b9ff6d
commit d5cc2a7b7b
2 changed files with 46 additions and 42 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=%u", cq=cmd_queue)
"neopixel_send oid=%c data=%*s", 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, val], minclock=minclock)
self.neopixel_send_cmd.send([self.oid, [green, red, blue]],
minclock=minclock)
def load_config_prefix(config):
return PrinterNeoPixel(config)