mirror of https://github.com/Desuuuu/klipper.git
led: Remove has_white check from LEDHelper
There is no harm in checking for a white config setting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
630d3b3444
commit
53a7f1dd76
|
@ -11,7 +11,7 @@ RENDER_TIME = 0.500
|
|||
|
||||
# Helper code for common LED initialization and control
|
||||
class LEDHelper:
|
||||
def __init__(self, config, update_func, led_count=1, has_white=False):
|
||||
def __init__(self, config, update_func, led_count=1):
|
||||
self.printer = config.get_printer()
|
||||
self.update_func = update_func
|
||||
self.led_count = led_count
|
||||
|
@ -20,8 +20,6 @@ class LEDHelper:
|
|||
red = config.getfloat('initial_RED', 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.)
|
||||
white = 0.
|
||||
if has_white:
|
||||
white = config.getfloat('initial_WHITE', 0., minval=0., maxval=1.)
|
||||
self.led_state = [(red, green, blue, white)] * led_count
|
||||
# Register commands
|
||||
|
@ -93,8 +91,8 @@ class PrinterLED:
|
|||
gcode = self.printer.lookup_object('gcode')
|
||||
gcode.register_command("SET_LED_TEMPLATE", self.cmd_SET_LED_TEMPLATE,
|
||||
desc=self.cmd_SET_LED_TEMPLATE_help)
|
||||
def setup_helper(self, config, update_func, led_count=1, has_white=False):
|
||||
led_helper = LEDHelper(config, update_func, led_count, has_white)
|
||||
def setup_helper(self, config, update_func, led_count=1):
|
||||
led_helper = LEDHelper(config, update_func, led_count)
|
||||
name = config.get_name().split()[-1]
|
||||
self.led_helpers[name] = led_helper
|
||||
return led_helper
|
||||
|
@ -208,7 +206,7 @@ class PrinterPWMLED:
|
|||
self.last_print_time = 0.
|
||||
# Initialize color data
|
||||
pled = printer.load_object(config, "led")
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1, True)
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
|
||||
self.prev_color = color = self.led_helper.get_status()['color_data'][0]
|
||||
for idx, mcu_pin in self.pins:
|
||||
mcu_pin.setup_start_value(color[idx], 0.)
|
||||
|
|
|
@ -38,7 +38,7 @@ class PrinterNeoPixel:
|
|||
# Initialize color data
|
||||
pled = printer.load_object(config, "led")
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds,
|
||||
self.chain_count, elem_size==4)
|
||||
self.chain_count)
|
||||
self.color_data = bytearray(self.chain_count * elem_size)
|
||||
self.update_color_data(self.led_helper.get_status()['color_data'])
|
||||
self.old_color_data = bytearray([d ^ 1 for d in self.color_data])
|
||||
|
|
|
@ -17,7 +17,7 @@ class PCA9533:
|
|||
self.printer = config.get_printer()
|
||||
self.i2c = bus.MCU_I2C_from_config(config, default_addr=98)
|
||||
pled = self.printer.load_object(config, "led")
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1, True)
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
|
||||
self.i2c.i2c_write([PCA9533_PWM0, 85])
|
||||
self.i2c.i2c_write([PCA9533_PWM1, 170])
|
||||
self.update_leds(self.led_helper.get_status()['color_data'], None)
|
||||
|
|
|
@ -35,7 +35,7 @@ class PCA9632:
|
|||
self.color_map = [color_order.index(c) for c in "RGBW"]
|
||||
self.prev_regs = {}
|
||||
pled = printer.load_object(config, "led")
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1, True)
|
||||
self.led_helper = pled.setup_helper(config, self.update_leds, 1)
|
||||
printer.register_event_handler("klippy:connect", self.handle_connect)
|
||||
def reg_write(self, reg, val, minclock=0):
|
||||
if self.prev_regs.get(reg) == val:
|
||||
|
|
Loading…
Reference in New Issue