forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Velocikey: Match RGB animation speed to typing speed (qmk#3754)
* Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes qmk#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 qmk#5) (qmk#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 qmk#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 qmk#5) (qmk#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 e123ff5, reversing changes made to df111a5. * Move velocikey EECONFIG definition to depend on VELOCIKEY_ENABLE * Rename decay_task function to decelerate * Apply suggestions from code review Co-Authored-By: chrislewisdev <[email protected]> * 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
- Loading branch information
1 parent
9f1d781
commit c1c5922
Showing
11 changed files
with
158 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Velocikey | ||
|
||
Velocikey is a feature that lets you control the speed of lighting effects (like the Rainbow Swirl effect) with the speed of your typing. The faster you type, the faster the lights will go! | ||
|
||
## Usage | ||
For Velocikey to take effect, there are two steps. First, when compiling your keyboard, you'll need to set `VELOCIKEY_ENABLE=yes` in `rules.mk`, e.g.: | ||
|
||
``` | ||
BOOTMAGIC_ENABLE = no | ||
MOUSEKEY_ENABLE = no | ||
STENO_ENABLE = no | ||
EXTRAKEY_ENABLE = yes | ||
VELOCIKEY_ENABLE = yes | ||
``` | ||
|
||
Then, while using your keyboard, you need to also turn it on with the VLK_TOG keycode, which toggles the feature on and off. | ||
|
||
The following light effects will all be controlled by Velocikey when it is enabled: | ||
- RGB Breathing | ||
- RGB Rainbow Mood | ||
- RGB Rainbow Swirl | ||
- RGB Snake | ||
- RGB Knight | ||
|
||
Support for LED breathing effects is planned but not available yet. | ||
|
||
As long as Velocikey is enabled, it will control the speed regardless of any other speed setting that your RGB lights are currently on. | ||
|
||
## Configuration | ||
Velocikey doesn't currently support any configuration via keyboard settings. If you want to adjust something like the speed increase or decay rate, you would need to edit `velocikey.c` and adjust the values there to achieve the kinds of speeds that you like. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "velocikey.h" | ||
#include "timer.h" | ||
#include "eeconfig.h" | ||
#include "eeprom.h" | ||
|
||
#ifndef MIN | ||
#define MIN(a,b) (((a)<(b))?(a):(b)) | ||
#endif | ||
#ifndef MAX | ||
#define MAX(a,b) (((a)>(b))?(a):(b)) | ||
#endif | ||
|
||
#define TYPING_SPEED_MAX_VALUE 200 | ||
uint8_t typing_speed = 0; | ||
|
||
bool velocikey_enabled(void) { | ||
return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1; | ||
} | ||
|
||
void velocikey_toggle(void) { | ||
if (velocikey_enabled()) | ||
eeprom_update_byte(EECONFIG_VELOCIKEY, 0); | ||
else | ||
eeprom_update_byte(EECONFIG_VELOCIKEY, 1); | ||
} | ||
|
||
void velocikey_accelerate(void) { | ||
if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100); | ||
} | ||
|
||
void velocikey_decelerate(void) { | ||
static uint16_t decay_timer = 0; | ||
|
||
if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) { | ||
if (typing_speed > 0) typing_speed -= 1; | ||
//Decay a little faster at half of max speed | ||
if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1; | ||
//Decay even faster at 3/4 of max speed | ||
if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2; | ||
decay_timer = timer_read(); | ||
} | ||
} | ||
|
||
uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { | ||
return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef VELOCIKEY_H | ||
#define VELOCIKEY_H | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
bool velocikey_enabled(void); | ||
void velocikey_toggle(void); | ||
void velocikey_accelerate(void); | ||
void velocikey_decelerate(void); | ||
uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters