mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-03 15:02:47 +00:00
Groundwork for toggling momentum on/off (currently always on)
This commit is contained in:
parent
12fcf80d3d
commit
13f7c9e3a1
@ -1,4 +1,5 @@
|
||||
#include "momentum.h"
|
||||
#include "timer.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
@ -10,6 +11,10 @@
|
||||
#define TYPING_SPEED_MAX_VALUE 200
|
||||
uint8_t typing_speed = 0;
|
||||
|
||||
bool momentum_enabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void momentum_accelerate() {
|
||||
if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100);
|
||||
}
|
||||
|
@ -2,8 +2,9 @@
|
||||
#define MOMENTUM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
bool momentum_enabled(void);
|
||||
void momentum_accelerate(void);
|
||||
void momentum_decay_task(void);
|
||||
uint8_t match_momentum(uint8_t minValue, uint8_t maxValue);
|
||||
|
@ -194,7 +194,7 @@ bool process_record_quantum(keyrecord_t *record) {
|
||||
uint16_t keycode;
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
momentum_accelerate();
|
||||
if (momentum_enabled()) momentum_accelerate();
|
||||
#endif
|
||||
|
||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||
|
@ -571,7 +571,7 @@ void rgblight_task(void) {
|
||||
|
||||
if (rgblight_timer_enabled) {
|
||||
|
||||
momentum_decay_task();
|
||||
if (momentum_enabled()) momentum_decay_task();
|
||||
|
||||
// mode = 1, static light, do nothing here
|
||||
if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
|
||||
@ -605,7 +605,11 @@ void rgblight_effect_breathing(uint8_t interval) {
|
||||
static uint16_t last_timer = 0;
|
||||
float val;
|
||||
|
||||
if (timer_elapsed(last_timer) < match_momentum(1, 100)) {
|
||||
uint8_t interval_time = momentum_enabled()
|
||||
? match_momentum(1, 100)
|
||||
: pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2]);
|
||||
|
||||
if (timer_elapsed(last_timer) < interval_time) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
@ -620,7 +624,11 @@ void rgblight_effect_rainbow_mood(uint8_t interval) {
|
||||
static uint16_t current_hue = 0;
|
||||
static uint16_t last_timer = 0;
|
||||
|
||||
if (timer_elapsed(last_timer) < match_momentum(5, 100)) {
|
||||
uint8_t interval_time = momentum_enabled()
|
||||
? match_momentum(5, 100)
|
||||
: pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval]);
|
||||
|
||||
if (timer_elapsed(last_timer) < interval_time) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
@ -633,7 +641,11 @@ void rgblight_effect_rainbow_swirl(uint8_t interval) {
|
||||
uint16_t hue;
|
||||
uint8_t i;
|
||||
|
||||
if (timer_elapsed(last_timer) < match_momentum(1, 100)) {
|
||||
uint8_t interval_time = momentum_enabled()
|
||||
? match_momentum(1, 100)
|
||||
: pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2]);
|
||||
|
||||
if (timer_elapsed(last_timer) < interval_time) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
@ -662,7 +674,12 @@ void rgblight_effect_snake(uint8_t interval) {
|
||||
if (interval % 2) {
|
||||
increment = -1;
|
||||
}
|
||||
if (timer_elapsed(last_timer) < match_momentum(1, 200)) {
|
||||
|
||||
uint8_t interval_time = momentum_enabled()
|
||||
? match_momentum(1, 200)
|
||||
: pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2]);
|
||||
|
||||
if (timer_elapsed(last_timer) < interval_time) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
@ -693,7 +710,12 @@ void rgblight_effect_snake(uint8_t interval) {
|
||||
}
|
||||
void rgblight_effect_knight(uint8_t interval) {
|
||||
static uint16_t last_timer = 0;
|
||||
if (timer_elapsed(last_timer) < match_momentum(5, 100)) {
|
||||
|
||||
uint8_t interval_time = momentum_enabled()
|
||||
? match_momentum(5, 100)
|
||||
: pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval]);
|
||||
|
||||
if (timer_elapsed(last_timer) < interval_time) {
|
||||
return;
|
||||
}
|
||||
last_timer = timer_read();
|
||||
|
Loading…
Reference in New Issue
Block a user