From 9a405e337fe1470337489ad82423d86a6b5b4470 Mon Sep 17 00:00:00 2001 From: heiso Date: Tue, 3 Dec 2024 22:08:14 +0100 Subject: [PATCH] feat: get cycle duration --- README.md | 8 ++++---- assets/logo.svg | 20 ++++++++++---------- 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 ---- 7 files changed, 21 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index f9c7248..5357c83 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ I use the two prototypes shown above as my daily drivers for both coding and gam - [Onshape - Low profile MX keycaps](https://cad.onshape.com/documents/93ff700fd3fbb6e9cde6f6e3) - [Rev 1.0 Schema](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25201.0%2Fmacrolev.kicad_sch) - [Rev 1.0 Pcb](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25201.0%2Fmacrolev.kicad_pcb) -- [WIP Rev 2.0 Schema](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Flayout_board%2Flayout_board.kicad_sch) -- [WIP Rev 2.0 Pcb](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Flayout_board%2Flayout_board.kicad_pcb) -- [WIP Rev 2.0 Schema (daughter board)](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Fdaughter_board%2Fdaughter_board.kicad_sch) -- [WIP Rev 2.0 Pcb (daughter board)](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Fdaughter_board%2Fdaughter_board.kicad_pcb) +- [Rev 2.0 Schema](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Flayout_board%2Flayout_board.kicad_sch) +- [Rev 2.0 Pcb](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Flayout_board%2Flayout_board.kicad_pcb) +- [Rev 2.0 Schema (daughter board)](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Fdaughter_board%2Fdaughter_board.kicad_sch) +- [Rev 2.0 Pcb (daughter board)](https://kicanvas.org/?github=https%3A%2F%2Fgithub.com%2Fheiso%2Fmacrolev%2Fblob%2Fmain%2Fkicad%2FRev%25202.0%2Fdaughter_board%2Fdaughter_board.kicad_pcb) - [Web Configurator](https://heiso.github.io/macrolev/) ## Misc diff --git a/assets/logo.svg b/assets/logo.svg index 8a94214..fbeb88b 100644 --- a/assets/logo.svg +++ b/assets/logo.svg @@ -1,12 +1,12 @@ - - - - - - - - - - + + + + + + + + + + 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)],