Skip to content

Commit 627acec

Browse files
author
Greg Smith
committed
Fixed issue with Ext/Int Footswitch handling, where if the Set Preset option was selected, it would always select the preset set by Midi Value 1, and not toggle between Midi value 1 and 2.
1 parent cc270ea commit 627acec

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

source/main/control.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,18 @@ void control_trigger_tap_tempo(void)
12061206
}
12071207
}
12081208

1209+
/****************************************************************************
1210+
* NAME:
1211+
* DESCRIPTION:
1212+
* PARAMETERS:
1213+
* RETURN:
1214+
* NOTES:
1215+
*****************************************************************************/
1216+
uint32_t control_get_current_preset_index(void)
1217+
{
1218+
return ControlData.ConfigData.PresetOrderMappingConfig.PresetOrder[ControlData.PresetIndex];
1219+
}
1220+
12091221
/****************************************************************************
12101222
* NAME:
12111223
* DESCRIPTION:

source/main/control.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ void control_set_preset_order(uint8_t* order);
285285
uint8_t* control_get_preset_order(void);
286286
void control_set_sync_complete(void);
287287
uint8_t control_get_sync_complete(void);
288+
uint32_t control_get_current_preset_index(void);
288289

289290
// config API
290291
void control_set_default_config(void);

source/main/midi_helper.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,14 +1980,27 @@ uint16_t midi_helper_get_param_for_change_num(uint8_t change_num, uint8_t midi_v
19801980

19811981
case 127:
19821982
{
1983-
// Custom case: use CC to change params.
1984-
if (midi_value_1 >= (usb_get_max_presets_for_connected_modeller()))
1983+
uint32_t new_preset;
1984+
uint32_t current_preset = control_get_current_preset_index();
1985+
1986+
if (current_preset == midi_value_1)
1987+
{
1988+
// select midi value 2
1989+
new_preset = midi_value_2;
1990+
}
1991+
else
1992+
{
1993+
// select midi value 1
1994+
new_preset = midi_value_1;
1995+
}
1996+
1997+
if (new_preset >= (usb_get_max_presets_for_connected_modeller()))
19851998
{
1986-
ESP_LOGW(TAG, "Unsupported Midi CC 127 value %d", midi_value_1);
1999+
ESP_LOGW(TAG, "Unsupported Midi CC 127 value %d", new_preset);
19872000
}
19882001
else
19892002
{
1990-
control_request_preset_index(midi_value_1);
2003+
control_request_preset_index(new_preset);
19912004
}
19922005

19932006
// don't set any return param, as this one is already handled and its not a parameter

0 commit comments

Comments
 (0)