Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
QMK Bot 2021-08-03 21:40:39 +00:00
commit c48d9c2b2a
1 changed files with 12 additions and 2 deletions

View File

@ -17,6 +17,8 @@
#include "wpm.h"
#include <math.h>
// WPM Stuff
static uint8_t current_wpm = 0;
static uint16_t wpm_timer = 0;
@ -69,14 +71,22 @@ __attribute__((weak)) uint8_t wpm_regress_count(uint16_t keycode) {
void update_wpm(uint16_t keycode) {
if (wpm_keycode(keycode)) {
if (wpm_timer > 0) {
current_wpm += ((60000 / timer_elapsed(wpm_timer) / WPM_ESTIMATED_WORD_SIZE) - current_wpm) * wpm_smoothing;
uint16_t latest_wpm = 60000 / timer_elapsed(wpm_timer) / WPM_ESTIMATED_WORD_SIZE;
if (latest_wpm > UINT8_MAX) {
latest_wpm = UINT8_MAX;
}
current_wpm += ceilf((latest_wpm - current_wpm) * wpm_smoothing);
}
wpm_timer = timer_read();
}
#ifdef WPM_ALLOW_COUNT_REGRESSION
uint8_t regress = wpm_regress_count(keycode);
if (regress) {
if (current_wpm < regress) {
current_wpm = 0;
} else {
current_wpm -= regress;
}
wpm_timer = timer_read();
}
#endif