fix(underglow): Fix racing that led strip get updated again after off

The timer was not being stopped before updating all LEDs to `#000000`.
In boards without a EXT_POWER, this will cause the LEDs being turned on
immediately after they get turned off.

Signed-off-by: XiNGRZ <hi@xingrz.me>
This commit is contained in:
XiNGRZ 2022-08-13 16:49:13 +08:00
parent 408b87ae7b
commit 1c862c5b94

View file

@ -332,15 +332,15 @@ int zmk_rgb_underglow_off() {
} }
#endif #endif
k_timer_stop(&underglow_tick);
state.on = false;
for (int i = 0; i < STRIP_NUM_PIXELS; i++) { for (int i = 0; i < STRIP_NUM_PIXELS; i++) {
pixels[i] = (struct led_rgb){r : 0, g : 0, b : 0}; pixels[i] = (struct led_rgb){r : 0, g : 0, b : 0};
} }
led_strip_update_rgb(led_strip, pixels, STRIP_NUM_PIXELS); led_strip_update_rgb(led_strip, pixels, STRIP_NUM_PIXELS);
k_timer_stop(&underglow_tick);
state.on = false;
return zmk_rgb_underglow_save_state(); return zmk_rgb_underglow_save_state();
} }