fix: Debounce preset pattern selection from CV input using last_mapped_slot to prevent redundant updates.

This commit is contained in:
2026-03-18 01:15:34 -07:00
parent ecc6ae01c6
commit 50c551f198

View File

@ -79,6 +79,7 @@ int current_step = 0;
volatile int cv1_val = 0; volatile int cv1_val = 0;
volatile int cv2_val = 0; volatile int cv2_val = 0;
int last_mapped_slot = -1;
// LFSR State for Chaos // LFSR State for Chaos
uint16_t lfsr = 0xACE1; uint16_t lfsr = 0xACE1;
@ -175,11 +176,16 @@ void ProcessSequencerTick(uint32_t tick) {
if (cv1_dest == CV_DEST_PRESET || cv2_dest == CV_DEST_PRESET) { if (cv1_dest == CV_DEST_PRESET || cv2_dest == CV_DEST_PRESET) {
int mapped_slot = constrain(map(preset_cv, 0, 512, 0, 4), 0, 4); int mapped_slot = constrain(map(preset_cv, 0, 512, 0, 4), 0, 4);
if (active_pattern != mapped_slot) { if (mapped_slot != last_mapped_slot) {
active_pattern = mapped_slot; last_mapped_slot = mapped_slot;
selected_slot = mapped_slot + 1; if (active_pattern != mapped_slot) {
needs_redraw = true; active_pattern = mapped_slot;
selected_slot = mapped_slot + 1;
needs_redraw = true;
}
} }
} else {
last_mapped_slot = -1;
} }
PatternState &p = patterns[active_pattern]; PatternState &p = patterns[active_pattern];