Skip to content

Commit 9f75192

Browse files
authored
Merge pull request #6054 from tannewt/funhouse_crash
Don't update status LED color on brightness change
2 parents c9a65af + 7f3f4e4 commit 9f75192

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

shared-bindings/supervisor/__init__.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,15 @@ STATIC mp_obj_t supervisor_disable_autoreload(void) {
7676
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload);
7777

7878
//| def set_rgb_status_brightness(brightness: int) -> None:
79-
//| """Set brightness of status neopixel from 0-255
80-
//| `set_rgb_status_brightness` is called."""
79+
//| """Set brightness of status RGB LED from 0-255. This will take effect
80+
//| after the current code finishes and the status LED is used to show
81+
//| the finish state."""
8182
//| ...
8283
//|
8384
STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl) {
8485
// This must be int. If cast to uint8_t first, will never raise a ValueError.
8586
int brightness_int = mp_obj_get_int(lvl);
86-
if (brightness_int < 0 || brightness_int > 255) {
87-
mp_raise_ValueError(translate("Brightness must be between 0 and 255"));
88-
}
87+
mp_arg_validate_int_range(brightness_int, 0, 255, MP_QSTR_brightness);
8988
set_status_brightness((uint8_t)brightness_int);
9089
return mp_const_none;
9190
}

supervisor/shared/status_leds.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,9 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness) {
324324
void set_status_brightness(uint8_t level) {
325325
#if CIRCUITPY_STATUS_LED
326326
rgb_status_brightness = level;
327-
uint32_t current_color = current_status_color;
328-
// Temporarily change the current color global to force the new_status_color call to update the
329-
// LED. Usually duplicate calls of the same color are ignored without regard to brightness
330-
// changes.
331-
current_status_color = 0;
332-
new_status_color(current_color);
327+
// This is only called by user code and we're never controlling the status
328+
// LED when user code is running. So, we don't need to update the current
329+
// state (there is none.)
333330
#endif
334331
}
335332

0 commit comments

Comments
 (0)