From 5841c755ae0b5629deb4c139eb535a82437112a2 Mon Sep 17 00:00:00 2001 From: Simon Arlott <70171+nomis@users.noreply.github.com> Date: Sat, 16 Apr 2022 23:02:32 +0100 Subject: rgblight: Add functions to stop blinking one or all but one layer (#16859) --- quantum/rgblight/rgblight.c | 15 +++++++++++++++ quantum/rgblight/rgblight.h | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'quantum/rgblight') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index f4ddb81e92..1f8b68ee59 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -826,6 +826,21 @@ void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t ti _repeat_timer = sync_timer_read() + duration_ms; } +void rgblight_unblink_layer(uint8_t layer) { + rgblight_set_layer_state(layer, false); + _blinking_layer_mask &= ~((rgblight_layer_mask_t)1 << layer); +} + +void rgblight_unblink_all_but_layer(uint8_t layer) { + for (uint8_t i = 0; i < RGBLIGHT_MAX_LAYERS; i++) { + if (i != layer) { + if ((_blinking_layer_mask & (rgblight_layer_mask_t)1 << i) != 0) { + rgblight_unblink_layer(i); + } + } + } +} + void rgblight_blink_layer_repeat_helper(void) { if (_blinking_layer_mask != 0 && timer_expired(sync_timer_read(), _repeat_timer)) { for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index 7076dc41ac..fdab0e987a 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -216,7 +216,25 @@ extern const rgblight_segment_t *const *rgblight_layers; # ifdef RGBLIGHT_LAYER_BLINK # define RGBLIGHT_USE_TIMER void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms); -void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times); +void rgblight_blink_layer_repeat(uint8_t layer, uint16_ duration_ms, uint8_t times); +/** + * \brief Stop blinking on one layer. + * + * Stop a layer that is blinking. If the layer is not blinking it will + * be unaffected. + * + * \param layer Layer number to stop blinking. + */ +void rgblight_unblink_layer(uint8_t layer); +/** + * \brief Stop blinking all layers except one. + * + * Stop all layers that are blinking except for one specific layer. + * Layers that are not blinking are unaffected. + * + * \param layer Layer number to keep blinking. + */ +void rgblight_unblink_all_but_layer(uint8_t layer); # endif #endif -- cgit v1.2.3