Skip to content

Commit

Permalink
feat: get cycle duration
Browse files Browse the repository at this point in the history
  • Loading branch information
heiso committed Dec 3, 2024
1 parent b988f38 commit c37fcde
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
20 changes: 10 additions & 10 deletions assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions firmware/Core/Inc/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions firmware/Core/Src/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions firmware/Core/Src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion web-app/app/routes/_layout.configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ export default function Index() {
<Button onClick={loadUserConfig}>Load Config</Button>
<Button onClick={persistUserConfig}>Save Config</Button>
<Button onClick={() => write('VENDOR_REQUEST_RESET_CONFIG')}>Reset Config</Button>
<Button onClick={async () => console.log(await read('VENDOR_REQUEST_CYCLE_DURATION'))}>
<Button
onClick={async () =>
console.log((await read('VENDOR_REQUEST_CYCLE_DURATION')).getInt32(0, true))
}
>
Get cycle duration (in console)
</Button>
<Button onClick={() => write('VENDOR_REQUEST_DFU_MODE')}>DFU Mode</Button>
Expand Down
4 changes: 0 additions & 4 deletions web-app/app/useDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)],
Expand Down

0 comments on commit c37fcde

Please sign in to comment.