aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/neopixel.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-04-15 13:28:54 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-04-15 13:29:43 -0400
commit0ae20421d18bd53ee98e03e825a0b2a468fa5639 (patch)
tree03c5a9a4a8b9c5fa8efc683c048a3711fa4c7748 /klippy/extras/neopixel.py
parenta7f7cc507547758879890b206030e508ac8dbdb0 (diff)
downloadkutter-0ae20421d18bd53ee98e03e825a0b2a468fa5639.tar.gz
kutter-0ae20421d18bd53ee98e03e825a0b2a468fa5639.tar.xz
kutter-0ae20421d18bd53ee98e03e825a0b2a468fa5639.zip
neopixel: Allow host software to configure neopixel timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/neopixel.py')
-rw-r--r--klippy/extras/neopixel.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/klippy/extras/neopixel.py b/klippy/extras/neopixel.py
index 320435c5..fd473987 100644
--- a/klippy/extras/neopixel.py
+++ b/klippy/extras/neopixel.py
@@ -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)