Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
19d3630
Add GRID_MUX_UNUSED macro and improve module mux handling
SukuWc Feb 1, 2026
ffb29fe
SUKU refactor mux_overflow to mux_positions_bm bitmask
SukuWc Feb 1, 2026
05751c7
SUKU add platform-agnostic ADC macros and refactor D51 module drivers
SukuWc Feb 2, 2026
4fbdaab
SUKU munx_init and mux_update platform function implemented
SukuWc Feb 2, 2026
12e3fb6
SUKU calibration removed from BU16, makes no difference
SukuWc Feb 2, 2026
bb105ec
SUKU refactor D51 module drivers with 2D lookup tables and consistent…
SukuWc Feb 2, 2026
fe851af
SUKU refactor ESP32 PO16 driver with 2D lookup and consistent signal …
SukuWc Feb 2, 2026
088a50b
SUKU refactor ESP32 BU16, EF44, PBF4 drivers with 2D lookup and consi…
SukuWc Feb 3, 2026
bc0d089
SUKU add ASC to D51 drivers and refactor grid_asc_process to use elem…
SukuWc Feb 3, 2026
254690f
SUKU refactor store_input functions to use ui model and element_index
SukuWc Feb 3, 2026
9be3471
SUKU remove unused elements pointer from module drivers
SukuWc Feb 3, 2026
ed033ba
SUKU D51 module drivers use dynamic allocation for UI state
SukuWc Feb 3, 2026
0ab4ccc
SUKU embed UI state in element structs via primary_state/secondary_state
SukuWc Feb 4, 2026
29a206e
SUKU refactor store_input interfaces with sample structs and state-st…
SukuWc Feb 6, 2026
a16ab62
SUKU refactor TEK2 module and PBF4 assert consistency
SukuWc Feb 6, 2026
8d62ba3
SUKU refactor TEK1 module: merge variant functions, remove legacy ana…
SukuWc Feb 6, 2026
c67aa89
SUKU rename module element count defines for consistency
SukuWc Feb 6, 2026
8ca6f62
SUKU rename tek1/tek2 modules to unified vsnx driver
SukuWc Feb 7, 2026
20ed83b
SUKU simplify vsnx_lcd_init with helper function
SukuWc Feb 7, 2026
b04030a
SUKU d51 init functions separated
SukuWc Feb 11, 2026
54fe133
SUKU extract D51 ADC and encoder abstractions, fold mux_init into adc…
SukuWc Feb 13, 2026
d256f54
SUKU unify state_init interfaces to use (ui, element_index) convention
SukuWc Feb 14, 2026
6979213
SUKU unify ADC/encoder callback types and remove platform-specific do…
SukuWc Feb 14, 2026
11cc526
custom length SPI transaction for D51 encoder driver, remove unused T…
SukuWc Feb 15, 2026
4675935
SUKU replace encoder divider/hardcoded baud with explicit clock_rate …
SukuWc Feb 15, 2026
eaa581d
SUKU unify mux bit extraction to (index >> n) & 1 across all platforms
SukuWc Feb 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .vscode/c_cpp_properties.json

This file was deleted.

241 changes: 0 additions & 241 deletions .vscode/settings.json

This file was deleted.

33 changes: 33 additions & 0 deletions grid_common/grid_ain.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@
#include <stdbool.h>
#include <stdint.h>

#define GRID_MUX_UNUSED ((uint8_t)-1)

#define GRID_AIN_INTERNAL_RESOLUTION 12

#define GRID_ADC_MAX 4095
#define GRID_POTMETER_DEADZONE 128
#define GRID_POTMETER_CENTER 2192

struct grid_adc_result {
uint8_t channel;
uint8_t mux_state;
uint16_t value;
};

typedef void (*grid_process_analog_t)(struct grid_adc_result* result);

#define GRID_ADC_INVERT_COND(value, element_index, invert_bm) ((value) ^ (GRID_ADC_MAX * (((invert_bm) >> (element_index)) & 1)))

// Find first valid mux position based on bitmask
#define GRID_MUX_FIRST_VALID(index, mask) \
do { \
(index) = 0; \
while (!((mask) & (1 << (index)))) { \
(index)++; \
} \
} while (0)

// Advance mux index to next valid position based on bitmask
#define GRID_MUX_INCREMENT(index, mask) \
do { \
(index) = ((index) + 1) % 8; \
} while (!((mask) & (1 << (index))))

struct ain_chan_t {

uint16_t capa;
Expand Down
14 changes: 8 additions & 6 deletions grid_common/grid_asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ void grid_asc_array_set_factors(struct grid_asc* asc, size_t capacity, uint8_t s
}
}

bool grid_asc_process(struct grid_asc* asc, uint16_t rx, uint16_t* tx) {
bool grid_asc_process(struct grid_asc* asc, uint8_t index, uint16_t rx, uint16_t* tx) {

asc->sum += rx;
struct grid_asc* entry = &asc[index];

*tx = asc->sum / (asc->count + 1);
entry->sum += rx;

asc->count = (asc->count + 1) % asc->factor;
*tx = entry->sum / (entry->count + 1);

asc->sum *= asc->count != 0;
entry->count = (entry->count + 1) % entry->factor;

return asc->count == 0;
entry->sum *= entry->count != 0;

return entry->count == 0;
}
2 changes: 1 addition & 1 deletion grid_common/grid_asc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ struct grid_asc {
};

void grid_asc_array_set_factors(struct grid_asc* asc, size_t capacity, uint8_t start, uint8_t length, uint8_t factor);
bool grid_asc_process(struct grid_asc* ads, uint16_t rx, uint16_t* tx);
bool grid_asc_process(struct grid_asc* asc, uint8_t index, uint16_t rx, uint16_t* tx);

#endif /* GRID_ASC_H */
4 changes: 4 additions & 0 deletions grid_common/grid_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ extern void grid_platform_lcd_set_backlight(uint8_t backlight);

extern uint8_t grid_platform_get_adc_bit_depth();

extern void grid_platform_mux_init(uint8_t mux_positions_bm);

extern void grid_platform_mux_write(uint8_t index);

#endif /* GRID_PLATFORM_H */
3 changes: 3 additions & 0 deletions grid_common/grid_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ struct grid_ui_element* grid_ui_element_model_init(struct grid_ui_model* parent,
ele->timer_event_helper = 0;
ele->timer_source_is_midi = 0;

ele->primary_state = NULL;
ele->secondary_state = NULL;

return ele;
}

Expand Down
3 changes: 3 additions & 0 deletions grid_common/grid_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ struct grid_ui_element {

uint8_t event_list_length;
struct grid_ui_event* event_list;

void* primary_state;
void* secondary_state;
};

enum grid_ui_bulk_status_t {
Expand Down
Loading