Skip to content

Commit d3f50ea

Browse files
committed
Fix color cycle example
Use correct updated parameter name Correctly pack color
1 parent e158ea5 commit d3f50ea

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

examples/color_led_deck/color_led_cycle.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ def cycle_colors(step: int) -> rgbw:
6161
return hsv_to_rgbw(hsv(h, s, v))
6262

6363

64-
def rgbw_to_rgbwuint32(input: rgbw) -> int:
65-
return (input.r << 24) | (input.g << 16) | (input.b << 8) | input.w
64+
def pack_rgbw(input: rgbw) -> int:
65+
"""Pack RGBW values into uint32 format: 0xWWRRGGBB"""
66+
return (input.w << 24) | (input.r << 16) | (input.g << 8) | input.b
6667

6768

6869
if __name__ == '__main__':
@@ -74,15 +75,15 @@ def rgbw_to_rgbwuint32(input: rgbw) -> int:
7475

7576
# Thermal status callback
7677
def thermal_status_callback(timestamp, data, logconf):
77-
throttle_pct = data['hprgbw.throttlePct']
78+
throttle_pct = data['colorled.throttlePct']
7879
if throttle_pct > 0:
79-
temp = data['hprgbw.deckTemp']
80+
temp = data['colorled.deckTemp']
8081
print(f'WARNING: Thermal throttling active! Temp: {temp}°C, Throttle: {throttle_pct}%')
8182

8283
# Setup log configuration for thermal monitoring
8384
log_conf = LogConfig(name='ThermalStatus', period_in_ms=100)
84-
log_conf.add_variable('hprgbw.deckTemp', 'uint8_t')
85-
log_conf.add_variable('hprgbw.throttlePct', 'uint8_t')
85+
log_conf.add_variable('colorled.deckTemp', 'uint8_t')
86+
log_conf.add_variable('colorled.throttlePct', 'uint8_t')
8687

8788
cf.log.add_config(log_conf)
8889
log_conf.data_received_cb.add_callback(thermal_status_callback)
@@ -91,19 +92,19 @@ def thermal_status_callback(timestamp, data, logconf):
9192
# Brightness correction: balances luminance across R/G/B/W channels
9293
# Set to 1 (enabled, default) for perceptually uniform colors
9394
# Set to 0 (disabled) for maximum brightness per channel
94-
cf.param.set_value('hprgbw.brightnessCorr', 1)
95+
cf.param.set_value('colorled.brightnessCorr', 1)
9596
time.sleep(0.1)
9697

9798
try:
9899
print('Cycling through colors. Press Ctrl-C to stop.')
99100
while True:
100101
for i in range(0, 360, 1):
101-
color = cycle_colors(i)
102+
color: rgbw = cycle_colors(i)
102103
# print(color.r, color.g, color.b)
103-
color_uint32 = rgbw_to_rgbwuint32(color)
104-
cf.param.set_value('hprgbw.rgbw8888', str(color_uint32))
104+
color_uint32 = pack_rgbw(color)
105+
cf.param.set_value('colorled.rgbw8888', str(color_uint32))
105106
time.sleep(0.01)
106107
except KeyboardInterrupt:
107108
print('\nStopping and turning off LED...')
108-
cf.param.set_value('hprgbw.rgbw8888', '0')
109+
cf.param.set_value('colorled.rgbw8888', '0')
109110
time.sleep(0.1)

0 commit comments

Comments
 (0)