neopixel: Use new GCodeCommand wrappers

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-04-24 23:52:49 -04:00
parent 310d583413
commit 0fd12609a6
1 changed files with 9 additions and 11 deletions

View File

@ -30,9 +30,8 @@ class PrinterNeoPixel:
self.update_color_data(red, green, blue) self.update_color_data(red, green, blue)
self.printer.register_event_handler("klippy:connect", self.send_data) self.printer.register_event_handler("klippy:connect", self.send_data)
# Register commands # Register commands
self.gcode = self.printer.lookup_object('gcode') gcode = self.printer.lookup_object('gcode')
self.gcode.register_mux_command("SET_LED", "LED", name, gcode.register_mux_command("SET_LED", "LED", name, self.cmd_SET_LED,
self.cmd_SET_LED,
desc=self.cmd_SET_LED_help) desc=self.cmd_SET_LED_help)
def build_config(self): def build_config(self):
bmt = self.mcu.seconds_to_clock(BIT_MAX_TIME) bmt = self.mcu.seconds_to_clock(BIT_MAX_TIME)
@ -60,14 +59,13 @@ class PrinterNeoPixel:
minclock=minclock, minclock=minclock,
reqclock=BACKGROUND_PRIORITY_CLOCK) 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, gcmd):
# Parse parameters # Parse parameters
red = self.gcode.get_float('RED', params, 0., minval=0., maxval=1.) red = gcmd.get_float('RED', 0., minval=0., maxval=1.)
green = self.gcode.get_float('GREEN', params, 0., minval=0., maxval=1.) green = gcmd.get_float('GREEN', 0., minval=0., maxval=1.)
blue = self.gcode.get_float('BLUE', params, 0., minval=0., maxval=1.) blue = gcmd.get_float('BLUE', 0., minval=0., maxval=1.)
index = self.gcode.get_int('INDEX', params, None, index = gcmd.get_int('INDEX', None, minval=1, maxval=self.chain_count)
minval=1, maxval=self.chain_count) transmit = gcmd.get_int('TRANSMIT', 1)
transmit = self.gcode.get_int('TRANSMIT', params, 1)
self.update_color_data(red, green, blue, index) self.update_color_data(red, green, blue, index)
# Send command # Send command
if not transmit: if not transmit: