diff options
| author | Joshua Diamond <josh@windowoffire.com> | 2020-05-09 04:38:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-09 01:38:33 -0700 |
| commit | e0f548085cc9c29e85122d393e74143eb5de1d4d (patch) | |
| tree | 0a881564362e8966376611da7b0db6e5bd6e597d /quantum/rgblight.c | |
| parent | 94fc32f43135ac4afb14849c7fb5e99f95455078 (diff) | |
| download | qmk_firmware-e0f548085cc9c29e85122d393e74143eb5de1d4d.tar.gz qmk_firmware-e0f548085cc9c29e85122d393e74143eb5de1d4d.zip | |
Add ability to blink lighting layer for a specified duration (#8760)
* Implement momentarily blink of lighting layers
* Refactor spidey3 userspace to use rgb layer blink
* Remove un-necessary line from example in documentation
* Revert "Refactor spidey3 userspace to use rgb layer blink"
This reverts commit 831649bb680c41c6d663ae6fa86d13f4f8bebdd8.
* Adds a missing bit of documentation about lighting layer blink
* Update docs/feature_rgblight.md per suggestions
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update docs/feature_rgblight.md per suggestions
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update docs/feature_rgblight.md per suggestions
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* cformat, as suggested
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Diffstat (limited to 'quantum/rgblight.c')
| -rw-r--r-- | quantum/rgblight.c | 29 |
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) { | |||
| 658 | } | 658 | } |
| 659 | } | 659 | } |
| 660 | } | 660 | } |
| 661 | |||
| 662 | # ifdef RGBLIGHT_LAYER_BLINK | ||
| 663 | uint8_t _blinked_layer_mask = 0; | ||
| 664 | uint16_t _blink_duration = 0; | ||
| 665 | static uint16_t _blink_timer; | ||
| 666 | |||
| 667 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { | ||
| 668 | rgblight_set_layer_state(layer, true); | ||
| 669 | _blinked_layer_mask |= 1 << layer; | ||
| 670 | _blink_timer = timer_read(); | ||
| 671 | _blink_duration = duration_ms; | ||
| 672 | } | ||
| 673 | |||
| 674 | void rgblight_unblink_layers(void) { | ||
| 675 | if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { | ||
| 676 | for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { | ||
| 677 | if ((_blinked_layer_mask & 1 << layer) != 0) { | ||
| 678 | rgblight_set_layer_state(layer, false); | ||
| 679 | } | ||
| 680 | } | ||
| 681 | _blinked_layer_mask = 0; | ||
| 682 | } | ||
| 683 | } | ||
| 684 | # endif | ||
| 685 | |||
| 661 | #endif | 686 | #endif |
| 662 | 687 | ||
| 663 | __attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); } | 688 | __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) { | |||
| 909 | # endif | 934 | # endif |
| 910 | } | 935 | } |
| 911 | } | 936 | } |
| 937 | |||
| 938 | # ifdef RGBLIGHT_LAYER_BLINK | ||
| 939 | rgblight_unblink_layers(); | ||
| 940 | # endif | ||
| 912 | } | 941 | } |
| 913 | 942 | ||
| 914 | #endif /* RGBLIGHT_USE_TIMER */ | 943 | #endif /* RGBLIGHT_USE_TIMER */ |
