Draft commit of typing speed RGB control

This commit is contained in:
Chris Lewis
2018-08-23 22:05:12 +10:00
parent 6d1536db1d
commit 48a222de4e
4 changed files with 39 additions and 4 deletions
+3
View File
@@ -190,12 +190,15 @@ static uint16_t scs_timer[2] = {0, 0};
*/
static bool grave_esc_was_shifted = false;
uint8_t typing_speed = 0;
bool process_record_quantum(keyrecord_t *record) {
/* This gets the keycode from the key pressed */
keypos_t key = record->event.key;
uint16_t keycode;
if (typing_speed < 100) typing_speed += 1;
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
/* TODO: Use store_or_get_action() or a similar function. */
if (!disable_action_cache) {
+2
View File
@@ -56,6 +56,8 @@
#include "suspend.h"
extern uint32_t default_layer_state;
//Used in rgblight.c to match RGB animation to typing speed
extern uint8_t typing_speed;
#ifndef NO_ACTION_LAYER
extern uint32_t layer_state;
+15 -3
View File
@@ -24,13 +24,15 @@
#include "rgblight.h"
#include "debug.h"
#include "led_tables.h"
#include "quantum.h"
#ifndef RGBLIGHT_LIMIT_VAL
#define RGBLIGHT_LIMIT_VAL 255
#endif
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
//These conflict with a chained include that comes from including quantum.h
// #define MIN(a,b) (((a)<(b))?(a):(b))
// #define MAX(a,b) (((a)>(b))?(a):(b))
__attribute__ ((weak))
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
@@ -631,7 +633,17 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) {
static uint16_t last_timer = 0;
uint16_t hue;
uint8_t i;
if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) {
//Improvement: move this code into rgblight_task() so that the typing_speed can be used across all RGB effects, not just swirl
static uint16_t decay_timer = 0;
if (timer_elapsed(decay_timer) > 250 || decay_timer == 0) {
if (typing_speed > 0) typing_speed -= 1;
//Improvement(?): decay by a greater rate depending on how big typing_speed is, so you can't reach max speed just by outpacing the regular decay
decay_timer = timer_read();
}
//Improvement: make the usage of typing speed more easily configurable, either with a pre-processor toggle or with real-time key toggles
if (timer_elapsed(last_timer) < MAX(1, 100 - typing_speed)) {
return;
}
last_timer = timer_read();