diff options
| author | Chris Lewis <chris@chrislewisdev.com> | 2019-02-22 02:22:46 +1100 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-02-21 07:22:46 -0800 |
| commit | c1c5922aae7b60b7c7d13d3769350eed9dda17ab (patch) | |
| tree | 7c3805d9b949ef2d802bd3df4e9238662a5cdc0b /quantum/rgblight.c | |
| parent | 9f1d781fcb7129a07e671a46461e501e3f1ae59d (diff) | |
| download | qmk_firmware-c1c5922aae7b60b7c7d13d3769350eed9dda17ab.tar.gz qmk_firmware-c1c5922aae7b60b7c7d13d3769350eed9dda17ab.zip | |
Velocikey: Match RGB animation speed to typing speed (#3754)
* Draft commit of typing speed RGB control
* More information in the readme
* Support all RGB animation modes (Fixes #1)
* Added support for all RGB light modes to use typing speed
Except christmas lights because that is seizure-inducing at high speeds!
* Introduced a value range specific to each RGB mode
Because some modes are a little too much when running at full speed!
* Update readme.md
* Update readme.md
* Re-arrange typing_speed definitions (Fixes #5) (#6)
* Re-arrange variable definitions to avoid including quantum.h from rgblight.c
* Fix a compilation error when trying to run make test:all
* Tweaks to the typing speed decay rate
* Renamed to momentum; moved implementation into dedicated files
* Groundwork for toggling momentum on/off (currently always on)
* Add EEPROM toggle for momentum-matching
* Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic
* Move momentum decay task out of rgblight_task()
* Fix missing momentum.h in lufa.c
* Experimental LED support (untested)
* Draft commit of typing speed RGB control
* More information in the readme
* Support all RGB animation modes (Fixes #1)
* Added support for all RGB light modes to use typing speed
Except christmas lights because that is seizure-inducing at high speeds!
* Introduced a value range specific to each RGB mode
Because some modes are a little too much when running at full speed!
* Update readme.md
* Update readme.md
* Re-arrange typing_speed definitions (Fixes #5) (#6)
* Re-arrange variable definitions to avoid including quantum.h from rgblight.c
* Fix a compilation error when trying to run make test:all
* Tweaks to the typing speed decay rate
* Renamed to momentum; moved implementation into dedicated files
* Groundwork for toggling momentum on/off (currently always on)
* Add EEPROM toggle for momentum-matching
* Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic
* Move momentum decay task out of rgblight_task()
* Fix missing momentum.h in lufa.c
* Added documentation
* Renamed feature to velocikey
* Reverted readme to original state
* Correct the readme title
* Updated feature name in the docs
* Update EECONFIG name
* Add compile-time toggles for velocikey
* Update feature documentation
* Revert "Merge branch 'led-support' into master"
This reverts commit e123ff5febf61639b9a9020748e1c2e2313460ff, reversing
changes made to df111a55b9d4929182e16108b1c0ead15b16df97.
* Move velocikey EECONFIG definition to depend on VELOCIKEY_ENABLE
* Rename decay_task function to decelerate
* Apply suggestions from code review
Co-Authored-By: chrislewisdev <chris@chrislewisdev.com>
* Re-order eeconfig definitions
* Apply coding conventions
* Apply #ifdef check in lufa.c
* Refactored interval time checks into one functionc
* Small rename
* Fix unused function error for layouts not using all rgb effects
* Only update EEPROM if Velocikey is enabled
* Incorporate code review feedback
* Small adjustment to top-end decay rate
* Add Velocikey documentation to table of contents
* Bring tetris:default keymap size down by disabling audio
Diffstat (limited to 'quantum/rgblight.c')
| -rw-r--r-- | quantum/rgblight.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 45d521786..57de56df7 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -30,6 +30,9 @@ | |||
| 30 | #include "rgblight.h" | 30 | #include "rgblight.h" |
| 31 | #include "debug.h" | 31 | #include "debug.h" |
| 32 | #include "led_tables.h" | 32 | #include "led_tables.h" |
| 33 | #ifdef VELOCIKEY_ENABLE | ||
| 34 | #include "velocikey.h" | ||
| 35 | #endif | ||
| 33 | 36 | ||
| 34 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, | 37 | #define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_ ## sym, |
| 35 | #define _RGBM_SINGLE_DYNAMIC(sym) | 38 | #define _RGBM_SINGLE_DYNAMIC(sym) |
| @@ -607,6 +610,19 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { | |||
| 607 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | 610 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); |
| 608 | } | 611 | } |
| 609 | 612 | ||
| 613 | #if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) \ | ||
| 614 | || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) | ||
| 615 | |||
| 616 | static uint8_t get_interval_time(const uint8_t* default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { | ||
| 617 | return | ||
| 618 | #ifdef VELOCIKEY_ENABLE | ||
| 619 | velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : | ||
| 620 | #endif | ||
| 621 | pgm_read_byte(default_interval_address); | ||
| 622 | } | ||
| 623 | |||
| 624 | #endif | ||
| 625 | |||
| 610 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { | 626 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { |
| 611 | if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; } | 627 | if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; } |
| 612 | 628 | ||
| @@ -707,6 +723,7 @@ void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { | |||
| 707 | } | 723 | } |
| 708 | 724 | ||
| 709 | void rgblight_task(void) { | 725 | void rgblight_task(void) { |
| 726 | |||
| 710 | if (rgblight_timer_enabled) { | 727 | if (rgblight_timer_enabled) { |
| 711 | // static light mode, do nothing here | 728 | // static light mode, do nothing here |
| 712 | if ( 1 == 0 ) { //dummy | 729 | if ( 1 == 0 ) { //dummy |
| @@ -778,7 +795,9 @@ void rgblight_effect_breathing(uint8_t interval) { | |||
| 778 | static uint16_t last_timer = 0; | 795 | static uint16_t last_timer = 0; |
| 779 | float val; | 796 | float val; |
| 780 | 797 | ||
| 781 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) { | 798 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2], 1, 100); |
| 799 | |||
| 800 | if (timer_elapsed(last_timer) < interval_time) { | ||
| 782 | return; | 801 | return; |
| 783 | } | 802 | } |
| 784 | last_timer = timer_read(); | 803 | last_timer = timer_read(); |
| @@ -798,7 +817,9 @@ void rgblight_effect_rainbow_mood(uint8_t interval) { | |||
| 798 | static uint16_t current_hue = 0; | 817 | static uint16_t current_hue = 0; |
| 799 | static uint16_t last_timer = 0; | 818 | static uint16_t last_timer = 0; |
| 800 | 819 | ||
| 801 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) { | 820 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[interval], 5, 100); |
| 821 | |||
| 822 | if (timer_elapsed(last_timer) < interval_time) { | ||
| 802 | return; | 823 | return; |
| 803 | } | 824 | } |
| 804 | last_timer = timer_read(); | 825 | last_timer = timer_read(); |
| @@ -820,7 +841,10 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) { | |||
| 820 | static uint16_t last_timer = 0; | 841 | static uint16_t last_timer = 0; |
| 821 | uint16_t hue; | 842 | uint16_t hue; |
| 822 | uint8_t i; | 843 | uint8_t i; |
| 823 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) { | 844 | |
| 845 | uint8_t interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2], 1, 100); | ||
| 846 | |||
| 847 | if (timer_elapsed(last_timer) < interval_time) { | ||
| 824 | return; | 848 | return; |
| 825 | } | 849 | } |
| 826 | last_timer = timer_read(); | 850 | last_timer = timer_read(); |
| @@ -855,7 +879,10 @@ void rgblight_effect_snake(uint8_t interval) { | |||
| 855 | if (interval % 2) { | 879 | if (interval % 2) { |
| 856 | increment = -1; | 880 | increment = -1; |
| 857 | } | 881 | } |
| 858 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) { | 882 | |
| 883 | uint8_t interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[interval / 2], 1, 200); | ||
| 884 | |||
| 885 | if (timer_elapsed(last_timer) < interval_time) { | ||
| 859 | return; | 886 | return; |
| 860 | } | 887 | } |
| 861 | last_timer = timer_read(); | 888 | last_timer = timer_read(); |
| @@ -892,7 +919,10 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | |||
| 892 | 919 | ||
| 893 | void rgblight_effect_knight(uint8_t interval) { | 920 | void rgblight_effect_knight(uint8_t interval) { |
| 894 | static uint16_t last_timer = 0; | 921 | static uint16_t last_timer = 0; |
| 895 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | 922 | |
| 923 | uint8_t interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[interval], 5, 100); | ||
| 924 | |||
| 925 | if (timer_elapsed(last_timer) < interval_time) { | ||
| 896 | return; | 926 | return; |
| 897 | } | 927 | } |
| 898 | last_timer = timer_read(); | 928 | last_timer = timer_read(); |
