diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/process_keycode/process_combo.c | 6 | ||||
-rw-r--r-- | quantum/rgb_matrix.c | 1 | ||||
-rw-r--r-- | quantum/split_common/transport.c | 4 | ||||
-rw-r--r-- | quantum/wpm.c | 39 | ||||
-rw-r--r-- | quantum/wpm.h | 4 |
5 files changed, 25 insertions, 29 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 25a606063..c4e299958 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
@@ -20,8 +20,8 @@ | |||
20 | #ifndef COMBO_VARIABLE_LEN | 20 | #ifndef COMBO_VARIABLE_LEN |
21 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT] = {}; | 21 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT] = {}; |
22 | #else | 22 | #else |
23 | extern combo_t key_combos[]; | 23 | extern combo_t key_combos[]; |
24 | extern int COMBO_LEN; | 24 | extern int COMBO_LEN; |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | __attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {} | 27 | __attribute__((weak)) void process_combo_event(uint8_t combo_index, bool pressed) {} |
@@ -146,7 +146,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
146 | } | 146 | } |
147 | #ifndef COMBO_VARIABLE_LEN | 147 | #ifndef COMBO_VARIABLE_LEN |
148 | for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) { | 148 | for (current_combo_index = 0; current_combo_index < COMBO_COUNT; ++current_combo_index) { |
149 | #else | 149 | #else |
150 | for (current_combo_index = 0; current_combo_index < COMBO_LEN; ++current_combo_index) { | 150 | for (current_combo_index = 0; current_combo_index < COMBO_LEN; ++current_combo_index) { |
151 | #endif | 151 | #endif |
152 | combo_t *combo = &key_combos[current_combo_index]; | 152 | combo_t *combo = &key_combos[current_combo_index]; |
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 1a9cf82e5..3fae9d737 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -111,7 +111,6 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; | |||
111 | # define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2 | 111 | # define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2 |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | |||
115 | bool g_suspend_state = false; | 114 | bool g_suspend_state = false; |
116 | 115 | ||
117 | rgb_config_t rgb_matrix_config; | 116 | rgb_config_t rgb_matrix_config; |
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 3234a3ef5..467ff81a9 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
@@ -85,7 +85,7 @@ bool transport_master(matrix_row_t matrix[]) { | |||
85 | 85 | ||
86 | # ifdef WPM_ENABLE | 86 | # ifdef WPM_ENABLE |
87 | uint8_t current_wpm = get_current_wpm(); | 87 | uint8_t current_wpm = get_current_wpm(); |
88 | if(current_wpm != i2c_buffer->current_wpm) { | 88 | if (current_wpm != i2c_buffer->current_wpm) { |
89 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WPM_START, (void *)¤t_wpm, sizeof(current_wpm), TIMEOUT) >= 0) { | 89 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WPM_START, (void *)¤t_wpm, sizeof(current_wpm), TIMEOUT) >= 0) { |
90 | i2c_buffer->current_wpm = current_wpm; | 90 | i2c_buffer->current_wpm = current_wpm; |
91 | } | 91 | } |
@@ -269,7 +269,7 @@ void transport_slave(matrix_row_t matrix[]) { | |||
269 | # endif | 269 | # endif |
270 | 270 | ||
271 | # ifdef WPM_ENABLE | 271 | # ifdef WPM_ENABLE |
272 | set_current_wpm(serial_m2s_buffer.current_wpm); | 272 | set_current_wpm(serial_m2s_buffer.current_wpm); |
273 | # endif | 273 | # endif |
274 | } | 274 | } |
275 | 275 | ||
diff --git a/quantum/wpm.c b/quantum/wpm.c index d4c971f31..da30bd252 100644 --- a/quantum/wpm.c +++ b/quantum/wpm.c | |||
@@ -17,12 +17,12 @@ | |||
17 | 17 | ||
18 | #include "wpm.h" | 18 | #include "wpm.h" |
19 | 19 | ||
20 | //WPM Stuff | 20 | // WPM Stuff |
21 | static uint8_t current_wpm = 0; | 21 | static uint8_t current_wpm = 0; |
22 | static uint8_t latest_wpm = 0; | 22 | static uint8_t latest_wpm = 0; |
23 | static uint16_t wpm_timer = 0; | 23 | static uint16_t wpm_timer = 0; |
24 | 24 | ||
25 | //This smoothing is 40 keystrokes | 25 | // This smoothing is 40 keystrokes |
26 | static const float wpm_smoothing = 0.0487; | 26 | static const float wpm_smoothing = 0.0487; |
27 | 27 | ||
28 | void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; } | 28 | void set_current_wpm(uint8_t new_wpm) { current_wpm = new_wpm; } |
@@ -34,34 +34,31 @@ bool wpm_keycode(uint16_t keycode) { return wpm_keycode_kb(keycode); } | |||
34 | __attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { return wpm_keycode_user(keycode); } | 34 | __attribute__((weak)) bool wpm_keycode_kb(uint16_t keycode) { return wpm_keycode_user(keycode); } |
35 | 35 | ||
36 | __attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) { | 36 | __attribute__((weak)) bool wpm_keycode_user(uint16_t keycode) { |
37 | |||
38 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { | 37 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { |
39 | keycode = keycode & 0xFF; | 38 | keycode = keycode & 0xFF; |
40 | } else if (keycode > 0xFF) { | 39 | } else if (keycode > 0xFF) { |
41 | keycode = 0; | 40 | keycode = 0; |
42 | } | 41 | } |
43 | if((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) { | 42 | if ((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) { |
44 | return true; | 43 | return true; |
45 | } | 44 | } |
46 | 45 | ||
47 | return false; | 46 | return false; |
48 | } | 47 | } |
49 | 48 | ||
50 | |||
51 | void update_wpm(uint16_t keycode) { | 49 | void update_wpm(uint16_t keycode) { |
52 | if(wpm_keycode(keycode)) { | 50 | if (wpm_keycode(keycode)) { |
53 | if(wpm_timer > 0) { | 51 | if (wpm_timer > 0) { |
54 | latest_wpm = 60000 / timer_elapsed(wpm_timer) / 5; | 52 | latest_wpm = 60000 / timer_elapsed(wpm_timer) / 5; |
55 | current_wpm = (latest_wpm - current_wpm) * wpm_smoothing + current_wpm; | 53 | current_wpm = (latest_wpm - current_wpm) * wpm_smoothing + current_wpm; |
56 | } | 54 | } |
57 | wpm_timer = timer_read(); | 55 | wpm_timer = timer_read(); |
58 | } | 56 | } |
59 | } | 57 | } |
60 | 58 | ||
61 | void decay_wpm(void) { | 59 | void decay_wpm(void) { |
62 | if (timer_elapsed(wpm_timer) > 1000) { | 60 | if (timer_elapsed(wpm_timer) > 1000) { |
63 | current_wpm = (0 - current_wpm) * wpm_smoothing + | 61 | current_wpm = (0 - current_wpm) * wpm_smoothing + current_wpm; |
64 | current_wpm; | 62 | wpm_timer = timer_read(); |
65 | wpm_timer = timer_read(); | 63 | } |
66 | } | ||
67 | } | 64 | } |
diff --git a/quantum/wpm.h b/quantum/wpm.h index fa0b6d128..15ab4ffcd 100644 --- a/quantum/wpm.h +++ b/quantum/wpm.h | |||
@@ -23,8 +23,8 @@ bool wpm_keycode(uint16_t keycode); | |||
23 | bool wpm_keycode_kb(uint16_t keycode); | 23 | bool wpm_keycode_kb(uint16_t keycode); |
24 | bool wpm_keycode_user(uint16_t keycode); | 24 | bool wpm_keycode_user(uint16_t keycode); |
25 | 25 | ||
26 | void set_current_wpm(uint8_t); | 26 | void set_current_wpm(uint8_t); |
27 | uint8_t get_current_wpm(void); | 27 | uint8_t get_current_wpm(void); |
28 | void update_wpm(uint16_t); | 28 | void update_wpm(uint16_t); |
29 | 29 | ||
30 | void decay_wpm(void); | 30 | void decay_wpm(void); |