mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 12:51:47 +00:00
Draft commit of typing speed RGB control
This commit is contained in:
parent
9ce35e823b
commit
2d3fbc5d0a
@ -187,12 +187,15 @@ static uint16_t scs_timer[2] = {0, 0};
|
|||||||
*/
|
*/
|
||||||
static bool grave_esc_was_shifted = false;
|
static bool grave_esc_was_shifted = false;
|
||||||
|
|
||||||
|
uint8_t typing_speed = 0;
|
||||||
bool process_record_quantum(keyrecord_t *record) {
|
bool process_record_quantum(keyrecord_t *record) {
|
||||||
|
|
||||||
/* This gets the keycode from the key pressed */
|
/* This gets the keycode from the key pressed */
|
||||||
keypos_t key = record->event.key;
|
keypos_t key = record->event.key;
|
||||||
uint16_t keycode;
|
uint16_t keycode;
|
||||||
|
|
||||||
|
if (typing_speed < 100) typing_speed += 1;
|
||||||
|
|
||||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||||
/* TODO: Use store_or_get_action() or a similar function. */
|
/* TODO: Use store_or_get_action() or a similar function. */
|
||||||
if (!disable_action_cache) {
|
if (!disable_action_cache) {
|
||||||
|
@ -55,6 +55,8 @@
|
|||||||
#include "send_string_keycodes.h"
|
#include "send_string_keycodes.h"
|
||||||
|
|
||||||
extern uint32_t default_layer_state;
|
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
|
#ifndef NO_ACTION_LAYER
|
||||||
extern uint32_t layer_state;
|
extern uint32_t layer_state;
|
||||||
|
@ -24,13 +24,15 @@
|
|||||||
#include "rgblight.h"
|
#include "rgblight.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "led_tables.h"
|
#include "led_tables.h"
|
||||||
|
#include "quantum.h"
|
||||||
|
|
||||||
#ifndef RGBLIGHT_LIMIT_VAL
|
#ifndef RGBLIGHT_LIMIT_VAL
|
||||||
#define RGBLIGHT_LIMIT_VAL 255
|
#define RGBLIGHT_LIMIT_VAL 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
//These conflict with a chained include that comes from including quantum.h
|
||||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
// #define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
|
// #define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
|
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
|
||||||
@ -628,7 +630,17 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) {
|
|||||||
static uint16_t last_timer = 0;
|
static uint16_t last_timer = 0;
|
||||||
uint16_t hue;
|
uint16_t hue;
|
||||||
uint8_t i;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
last_timer = timer_read();
|
last_timer = timer_read();
|
||||||
|
20
readme.md
20
readme.md
@ -1,4 +1,22 @@
|
|||||||
# Quantum Mechanical Keyboard Firmware
|
# Quantum Mechanical Keyboard Firmware - chrislewisdev fork
|
||||||
|
|
||||||
|
## Typing Speed -> RGB Animation Control
|
||||||
|
|
||||||
|
This fork of qmk_firmware contains the code I whipped up to make your keyboard's RGB animation speed match your typing speed. As of writing, this is a "first draft" version, aka the simplest implementation I could think of with the quickest/hackiest code. Beware hard-coding :)
|
||||||
|
|
||||||
|
Regardless, I'm happy to share the code and discuss improvements with anyone who'd like to contribute. I'll do my best to facilitate it in my spare time.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
My entire change amounts to several lines in `quantum.h`, `quantum.c` and `rgblight.c`. To see the details it's probably easiest if you look at my first commit to this fork which contains all the changes.
|
||||||
|
|
||||||
|
I've left a couple of "Improvement:" comments around the code to indicate what I think would make it better or more "production"-ready. These could be good places to start for anyone interested in contributing.
|
||||||
|
|
||||||
|
To test it, I've just been using my DZ60 keyboard, building the firmware with `make dz60:default` and flashing with qmk_toolbox.
|
||||||
|
|
||||||
|
Below is the original QMK readme:
|
||||||
|
|
||||||
|
# QMK
|
||||||
|
|
||||||
[](https://github.com/qmk/qmk_firmware/tags)
|
[](https://github.com/qmk/qmk_firmware/tags)
|
||||||
[](https://travis-ci.org/qmk/qmk_firmware)
|
[](https://travis-ci.org/qmk/qmk_firmware)
|
||||||
|
Loading…
Reference in New Issue
Block a user