summaryrefslogtreecommitdiffstats
path: root/quantum/split_common/transport.c
diff options
context:
space:
mode:
authorbrickbots <rich@brickbots.com>2020-03-22 06:06:16 -0700
committerGitHub <noreply@github.com>2020-03-23 00:06:16 +1100
commitbfb2f8e0a8f809374fdec102eb02c3bce46a14ee (patch)
tree2bab982f9b1cc9184b58ca9764d1ba09e133335c /quantum/split_common/transport.c
parentd8f3c28a3786e7888fe3157c173845107c3ccc95 (diff)
Add Word Per Minute calculation feature (#8054)
* Add Word Per Minute calculation feature * Fix copyright info * Remove header from quantum.c, setup overloadable keycode inclusion for WPM, update docs * Simplify logic for keycode filtering * Adding link from summary to wpm_feature info * Update docs/feature_wpm.md Typo in function prototype example in docs Co-Authored-By: James Young <18669334+noroadsleft@users.noreply.github.com> * Add WPM transport via i2c Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Diffstat (limited to 'quantum/split_common/transport.c')
-rw-r--r--quantum/split_common/transport.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index ab421adc4a..3234a3ef55 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -35,6 +35,9 @@ typedef struct _I2C_slave_buffer_t {
# ifdef ENCODER_ENABLE
uint8_t encoder_state[NUMBER_OF_ENCODERS];
# endif
+# ifdef WPM_ENABLE
+ uint8_t current_wpm;
+# endif
} I2C_slave_buffer_t;
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
@@ -43,6 +46,7 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
+# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
# define TIMEOUT 100
@@ -79,6 +83,14 @@ bool transport_master(matrix_row_t matrix[]) {
encoder_update_raw(i2c_buffer->encoder_state);
# endif
+# ifdef WPM_ENABLE
+ uint8_t current_wpm = get_current_wpm();
+ if(current_wpm != i2c_buffer->current_wpm) {
+ if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WPM_START, (void *)&current_wpm, sizeof(current_wpm), TIMEOUT) >= 0) {
+ i2c_buffer->current_wpm = current_wpm;
+ }
+ }
+# endif
return true;
}
@@ -102,6 +114,10 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef ENCODER_ENABLE
encoder_state_raw(i2c_buffer->encoder_state);
# endif
+
+# ifdef WPM_ENABLE
+ set_current_wpm(i2c_buffer->current_wpm);
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -126,6 +142,9 @@ typedef struct _Serial_m2s_buffer_t {
# ifdef BACKLIGHT_ENABLE
uint8_t backlight_level;
# endif
+# ifdef WPM_ENABLE
+ uint8_t current_wpm;
+# endif
} Serial_m2s_buffer_t;
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
@@ -228,6 +247,10 @@ bool transport_master(matrix_row_t matrix[]) {
encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state);
# endif
+# ifdef WPM_ENABLE
+ // Write wpm to slave
+ serial_m2s_buffer.current_wpm = get_current_wpm();
+# endif
return true;
}
@@ -244,6 +267,10 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef ENCODER_ENABLE
encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state);
# endif
+
+# ifdef WPM_ENABLE
+ set_current_wpm(serial_m2s_buffer.current_wpm);
+# endif
}
#endif