From 254789f4c570426f589e3cf966dac12a0600b6a5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 15 Dec 2019 23:24:17 -0500 Subject: [PATCH] neopixel: Add support for delaying updates in SET_LED command Signed-off-by: Kevin O'Connor --- docs/G-Codes.md | 17 ++++++++++------- klippy/extras/dotstar.py | 3 +++ klippy/extras/neopixel.py | 3 +++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 4ab3ffc7..a82f1cc9 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -222,13 +222,16 @@ is enabled: The following command is available when "neopixel" or "dotstar" config sections are enabled: -- `SET_LED LED= INDEX= RED= GREEN= - BLUE=`: This sets the LED output. Each color must be - between 0.0 and 1.0. If multiple LED chips are daisy-chained then - one may specify INDEX to alter the color of just the given chip (1 - for the first chip, 2 for the second, etc.). If INDEX is not - provided then all LEDs in the daisy-chain will be set to the - provided color. +- `SET_LED LED= RED= GREEN= BLUE= + [INDEX=] [TRANSMIT=0]`: This sets the LED output. Each color + must be between 0.0 and 1.0. If multiple LED chips are + daisy-chained then one may specify INDEX to alter the color of just + the given chip (1 for the first chip, 2 for the second, etc.). If + INDEX is not provided then all LEDs in the daisy-chain will be set + to the provided color. If TRANSMIT=0 is specified then the color + change will only be made on the next SET_LED command that does not + specify TRANSMIT=0; this may be useful in combination with the INDEX + parameter to batch multiple updates in a daisy-chain. ## Servo Commands diff --git a/klippy/extras/dotstar.py b/klippy/extras/dotstar.py index d5f5d082..352a122c 100644 --- a/klippy/extras/dotstar.py +++ b/klippy/extras/dotstar.py @@ -48,6 +48,7 @@ class PrinterDotstar: red = self.gcode.get_float('RED', params, 0., minval=0., maxval=1.) green = self.gcode.get_float('GREEN', params, 0., minval=0., maxval=1.) blue = self.gcode.get_float('BLUE', params, 0., minval=0., maxval=1.) + transmit = self.gcode.get_int('TRANSMIT', params, 1) red = int(red * 255. + .5) blue = int(blue * 255. + .5) green = int(green * 255. + .5) @@ -59,6 +60,8 @@ class PrinterDotstar: else: self.color_data[4:-4] = color_data * self.chain_count # Send command + if not transmit: + return print_time = self.printer.lookup_object('toolhead').get_last_move_time() self.send_data(self.spi.get_mcu().print_time_to_clock(print_time)) diff --git a/klippy/extras/neopixel.py b/klippy/extras/neopixel.py index abd1c637..320435c5 100644 --- a/klippy/extras/neopixel.py +++ b/klippy/extras/neopixel.py @@ -60,8 +60,11 @@ class PrinterNeoPixel: blue = self.gcode.get_float('BLUE', params, 0., minval=0., maxval=1.) index = self.gcode.get_int('INDEX', params, None, minval=1, maxval=self.chain_count) + transmit = self.gcode.get_int('TRANSMIT', params, 1) self.update_color_data(red, green, blue, index) # Send command + if not transmit: + return print_time = self.printer.lookup_object('toolhead').get_last_move_time() self.send_data(self.mcu.print_time_to_clock(print_time))