From 3d22c73ac7493a029fd36d6a4adf09921bf01fc2 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Tue, 2 Dec 2025 10:03:40 +0100 Subject: [PATCH] controller: Increase range for LED value on 2.6 --- controller/light/LM36011.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/controller/light/LM36011.py b/controller/light/LM36011.py index 3216e0eba..78da079dd 100644 --- a/controller/light/LM36011.py +++ b/controller/light/LM36011.py @@ -90,6 +90,15 @@ def set_torch_current(self, current): value = int(current * 0.34) self._write_byte(self.Register.torch, value) + # 0 - 127 + # 0 is ~ 2.4 mA + # 128 is ~ 376 mA + def set_torch_value(self, value: int) -> None: + self._write_byte(self.Register.torch, int(value)) + + def get_torch_value(self) -> int: + return self._read_byte(self.Register.torch) + def get_torch_current(self): return self._read_byte(self.Register.torch) @@ -152,9 +161,9 @@ def deinit() -> None: def get_value() -> float: - return int(round(led.get_torch_current() / 20)) + return led.get_torch_current() / 127 def set_value(value: float) -> None: - led.set_torch_current(int(round(value * 20))) + led.set_torch_value(int(value * 127)) return