Small things because fuck sd cards
Build, push image, and notify Watchtower / build-image (push) Successful in 3m22s
Build, push image, and notify Watchtower / notify (push) Successful in 1m24s

This commit is contained in:
2026-08-25 19:16:50 +02:00
parent 688fd26db8
commit 3753f57041
12 changed files with 139 additions and 94 deletions
+12 -10
View File
@@ -1,6 +1,6 @@
import time
import sys
from sensors.lock import grove_lock
from sensors.lock import safe_grove_access
if sys.platform == 'uwp':
import winrt_smbus as smbus
@@ -18,7 +18,6 @@ else:
DISPLAY_RGB_ADDR = 0x62
DISPLAY_TEXT_ADDR = 0x3e
def setRGB(r, g, b, brightness=1.0):
"""Set backlight to (R,G,B) with optional brightness level (0.0 to 1.0)."""
brightness = max(0.0, min(1.0, float(brightness)))
@@ -27,7 +26,9 @@ def setRGB(r, g, b, brightness=1.0):
g_scaled = int(max(0, min(255, g * brightness)))
b_scaled = int(max(0, min(255, b * brightness)))
with grove_lock:
with safe_grove_access(timeout=1.0) as acquired:
if not acquired:
return
try:
bus.write_byte_data(DISPLAY_RGB_ADDR, 0, 0)
bus.write_byte_data(DISPLAY_RGB_ADDR, 1, 0)
@@ -38,15 +39,15 @@ def setRGB(r, g, b, brightness=1.0):
except OSError:
pass
def textCommand(cmd):
"""Send command to display (internal use)."""
bus.write_byte_data(DISPLAY_TEXT_ADDR, 0x80, cmd)
def setText(text):
"""Set display text (\n for second line or auto wrap)."""
with grove_lock:
with safe_grove_access(timeout=1.5) as acquired:
if not acquired:
return
try:
textCommand(0x01) # Clear display
time.sleep(0.05)
@@ -67,14 +68,15 @@ def setText(text):
continue
count += 1
bus.write_byte_data(DISPLAY_TEXT_ADDR, 0x40, ord(c))
time.sleep(0.001) # Small pacing delay to prevent LCD buffer overflow
time.sleep(0.001)
except OSError:
pass
def setText_norefresh(text):
"""Update display text without full screen erase."""
with grove_lock:
with safe_grove_access(timeout=1.5) as acquired:
if not acquired:
return
try:
textCommand(0x02) # Return home
time.sleep(0.05)
@@ -97,6 +99,6 @@ def setText_norefresh(text):
continue
count += 1
bus.write_byte_data(DISPLAY_TEXT_ADDR, 0x40, ord(c))
time.sleep(0.001) # Small pacing delay to prevent LCD buffer overflow
time.sleep(0.001)
except OSError:
pass