From 0324a851a57d172cc0509f87923500f712831ac0 Mon Sep 17 00:00:00 2001 From: Jacek Fedorynski Date: Thu, 14 Nov 2024 22:21:30 +0100 Subject: [PATCH] Set defaults for digipot values On custom board v7, Analog 0/1 and 2/3 are meant for sticks and 4 and 5 for triggers, so hardwire the default values according to that. Worry about making it generic later. --- firmware/src/remapper.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/firmware/src/remapper.cc b/firmware/src/remapper.cc index eb67399..30f009c 100644 --- a/firmware/src/remapper.cc +++ b/firmware/src/remapper.cc @@ -654,6 +654,17 @@ void set_mapping_from_config() { } } } + if ((target == (DIGIPOT_USAGE_PAGE | 0)) || + (target == (DIGIPOT_USAGE_PAGE | 1)) || + (target == (DIGIPOT_USAGE_PAGE | 2)) || + (target == (DIGIPOT_USAGE_PAGE | 3))) { + rev_map.default_value = 128; + for (auto const& source : sources) { + if (!source.sticky && !source.tap && !source.hold && (source.scaling == 1000)) { + *(source.input_state) = 128; + } + } + } if ((target & 0xFFFF0000) == GPIO_USAGE_PAGE) { rev_map.our_usages.push_back((out_usage_def_t){ .data = gpio_out_state, @@ -1127,7 +1138,12 @@ void process_mapping(bool auto_repeat) { } memcpy(input_state + PREV_STATE_OFFSET, input_state, used_state_slots * sizeof(input_state[0])); - memset(digipot_state, 0, sizeof(digipot_state)); + digipot_state[0] = 128; + digipot_state[1] = 128; + digipot_state[2] = 128; + digipot_state[3] = 128; + digipot_state[4] = 0; + digipot_state[5] = 0; for (auto& rev_map : reverse_mapping) { uint32_t target = rev_map.target;