aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 26cb41a96..33326fa86 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -658,6 +658,31 @@ static void rgblight_layers_write(void) {
}
}
}
+
+# ifdef RGBLIGHT_LAYER_BLINK
+uint8_t _blinked_layer_mask = 0;
+uint16_t _blink_duration = 0;
+static uint16_t _blink_timer;
+
+void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) {
+ rgblight_set_layer_state(layer, true);
+ _blinked_layer_mask |= 1 << layer;
+ _blink_timer = timer_read();
+ _blink_duration = duration_ms;
+}
+
+void rgblight_unblink_layers(void) {
+ if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) {
+ for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) {
+ if ((_blinked_layer_mask & 1 << layer) != 0) {
+ rgblight_set_layer_state(layer, false);
+ }
+ }
+ _blinked_layer_mask = 0;
+ }
+}
+# endif
+
#endif
__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); }
@@ -909,6 +934,10 @@ void rgblight_task(void) {
# endif
}
}
+
+# ifdef RGBLIGHT_LAYER_BLINK
+ rgblight_unblink_layers();
+# endif
}
#endif /* RGBLIGHT_USE_TIMER */