aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/pca9533.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/extras/pca9533.py')
-rw-r--r--klippy/extras/pca9533.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/klippy/extras/pca9533.py b/klippy/extras/pca9533.py
index a94e1334..c56ff71c 100644
--- a/klippy/extras/pca9533.py
+++ b/klippy/extras/pca9533.py
@@ -6,11 +6,12 @@
import logging
from . import bus, led
-BACKGROUND_PRIORITY_CLOCK = 0x7fffffff00000000
+BACKGROUND_PRIORITY_CLOCK = 0x7FFFFFFF00000000
+
+PCA9533_PWM0 = 0b010
+PCA9533_PWM1 = 0b100
+PCA9533_PLS0 = 0b101
-PCA9533_PWM0=0b010
-PCA9533_PWM1=0b100
-PCA9533_PLS0=0b101
class PCA9533:
def __init__(self, config):
@@ -19,18 +20,22 @@ class PCA9533:
self.led_helper = led.LEDHelper(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)
+ self.update_leds(self.led_helper.get_status()["color_data"], None)
+
def update_leds(self, led_state, print_time):
rmap = [0, 2, 3, 1, 1]
- red, green, blue, white = [rmap[int(v * 4.)] for v in led_state[0]]
- ls0 = (white<<6) | (blue<<4) | (green<<2) | red
+ red, green, blue, white = [rmap[int(v * 4.0)] for v in led_state[0]]
+ ls0 = (white << 6) | (blue << 4) | (green << 2) | red
minclock = 0
if print_time is not None:
minclock = self.i2c.get_mcu().print_time_to_clock(print_time)
- self.i2c.i2c_write([PCA9533_PLS0, ls0], minclock=minclock,
- reqclock=BACKGROUND_PRIORITY_CLOCK)
+ self.i2c.i2c_write(
+ [PCA9533_PLS0, ls0], minclock=minclock, reqclock=BACKGROUND_PRIORITY_CLOCK
+ )
+
def get_status(self, eventtime):
return self.led_helper.get_status(eventtime)
+
def load_config_prefix(config):
return PCA9533(config)