mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-09 23:05:05 -06:00
neopixel: Allow host software to configure neopixel timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a7f7cc5075
commit
0ae20421d1
2 changed files with 23 additions and 11 deletions
|
@ -6,6 +6,9 @@
|
|||
|
||||
BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
|
||||
|
||||
BIT_MAX_TIME=.000004
|
||||
RESET_MIN_TIME=.000050
|
||||
|
||||
class PrinterNeoPixel:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
|
@ -15,8 +18,7 @@ class PrinterNeoPixel:
|
|||
pin_params = ppins.lookup_pin(config.get('pin'))
|
||||
self.mcu = pin_params['chip']
|
||||
self.oid = self.mcu.create_oid()
|
||||
self.mcu.add_config_cmd("config_neopixel oid=%d pin=%s"
|
||||
% (self.oid, pin_params['pin']))
|
||||
self.pin = pin_params['pin']
|
||||
self.mcu.register_config_callback(self.build_config)
|
||||
self.color_order_GRB = config.getboolean("color_order_GRB", True)
|
||||
self.chain_count = config.getint('chain_count', 1, minval=1, maxval=18)
|
||||
|
@ -33,6 +35,11 @@ class PrinterNeoPixel:
|
|||
self.cmd_SET_LED,
|
||||
desc=self.cmd_SET_LED_help)
|
||||
def build_config(self):
|
||||
bmt = self.mcu.seconds_to_clock(BIT_MAX_TIME)
|
||||
rmt = self.mcu.seconds_to_clock(RESET_MIN_TIME)
|
||||
self.mcu.add_config_cmd("config_neopixel oid=%d pin=%s"
|
||||
" bit_max_ticks=%d reset_min_ticks=%d"
|
||||
% (self.oid, self.pin, bmt, rmt))
|
||||
cmd_queue = self.mcu.alloc_command_queue()
|
||||
self.neopixel_send_cmd = self.mcu.lookup_command(
|
||||
"neopixel_send oid=%c data=%*s", cq=cmd_queue)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue