From 15bac6545ddbe78d681dc4b0015c05341acde3de Mon Sep 17 00:00:00 2001 From: heiso Date: Tue, 3 Dec 2024 22:08:14 +0100 Subject: [PATCH] feat: get cycle duration --- firmware/Core/Inc/keyboard.h | 4 ---- firmware/Core/Src/hid.c | 1 + firmware/Core/Src/keyboard.c | 4 +--- web-app/app/routes/_layout.configurator.tsx | 6 +++++- web-app/app/useDevice.ts | 4 ---- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/firmware/Core/Inc/keyboard.h b/firmware/Core/Inc/keyboard.h index e37104f..3bfd07d 100644 --- a/firmware/Core/Inc/keyboard.h +++ b/firmware/Core/Inc/keyboard.h @@ -18,8 +18,6 @@ #define SPECIAL(X) (0b1000000000000000 | X) -uint32_t keyboard_last_cycle_duration; - struct __attribute__((__packed__)) calibration { uint16_t cycles_count; uint16_t idle_value; @@ -38,8 +36,6 @@ struct __attribute__((__packed__)) state { float filtered_distance; int8_t velocity; uint8_t filtered_distance_8bits; - uint32_t last_update_started_at; - uint32_t last_update_ended_at; }; enum actuation_status { diff --git a/firmware/Core/Src/hid.c b/firmware/Core/Src/hid.c index f9d90a5..fc01828 100644 --- a/firmware/Core/Src/hid.c +++ b/firmware/Core/Src/hid.c @@ -7,6 +7,7 @@ extern uint8_t const desc_ms_os_20[]; extern struct key keyboard_keys[ADC_CHANNEL_COUNT][AMUX_CHANNEL_COUNT]; extern struct user_config keyboard_user_config; +extern uint32_t keyboard_last_cycle_duration; static uint8_t should_send_consumer_report = 0; static uint8_t should_send_keyboard_report = 0; diff --git a/firmware/Core/Src/keyboard.c b/firmware/Core/Src/keyboard.c index 42c3af4..e798ad5 100644 --- a/firmware/Core/Src/keyboard.c +++ b/firmware/Core/Src/keyboard.c @@ -6,6 +6,7 @@ struct key keyboard_keys[ADC_CHANNEL_COUNT][AMUX_CHANNEL_COUNT] = {0}; struct user_config keyboard_user_config = {0}; + uint32_t keyboard_last_cycle_duration = 0; static uint8_t key_triggered = 0; @@ -82,8 +83,6 @@ void init_key(uint8_t adc_channel, uint8_t amux_channel, uint8_t row, uint8_t co uint8_t update_key_state(struct key *key) { struct state state; - state.last_update_started_at = keyboard_get_time(); - // Get a reading state.value = keyboard_read_adc(); @@ -156,7 +155,6 @@ uint8_t update_key_state(struct key *key) { } } - state.last_update_ended_at = keyboard_get_time(); key->state = state; return 1; } diff --git a/web-app/app/routes/_layout.configurator.tsx b/web-app/app/routes/_layout.configurator.tsx index 3740407..40e3b1a 100644 --- a/web-app/app/routes/_layout.configurator.tsx +++ b/web-app/app/routes/_layout.configurator.tsx @@ -166,7 +166,11 @@ export default function Index() { - diff --git a/web-app/app/useDevice.ts b/web-app/app/useDevice.ts index cfc12e6..dc22810 100644 --- a/web-app/app/useDevice.ts +++ b/web-app/app/useDevice.ts @@ -116,8 +116,6 @@ export type Key = { filteredDistance: number // float int32_t ? velocity: number // int8_t filteredDistance8bits: number // uint8_t - lastUpdateStartedAt: number // uint32_t - lastUpdateEndedAt: number // uint32_t } actuation: { direction: (typeof actuationDirections)[number] // uint8_t @@ -182,8 +180,6 @@ function parseKeys(data: DataView): Key[] { filteredDistance: getValue(data, 'float', false), velocity: getValue(data, 8, false), filteredDistance8bits: getValue(data, 8), - lastUpdateStartedAt: getValue(data, 32), - lastUpdateEndedAt: getValue(data, 32), }, actuation: { direction: actuationDirections[getValue(data, 8)],