From d1e39ee359ea790d3b85258bb739ced73cab4b59 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 14 May 2020 09:51:11 +0200 Subject: [PATCH] Using a global instance_id for holging last selected instance. --- MicroDexed.ino | 1 + UI.hpp | 1015 ++++++++++++++++++++---------------------------- 2 files changed, 428 insertions(+), 588 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 8e1ee53..7c004ea 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -206,6 +206,7 @@ char sd_string[LCD_cols + 1]; char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; char receive_bank_filename[FILENAME_LEN]; +uint8_t selected_instance_id = 0; #if defined(USE_FX) // Allocate the delay lines for chorus diff --git a/UI.hpp b/UI.hpp index d482d98..5fda699 100644 --- a/UI.hpp +++ b/UI.hpp @@ -56,7 +56,7 @@ extern void eeprom_update_sys(void); extern void eeprom_update_performance(void); extern void eeprom_update_fx(void); extern void eeprom_update_dexed(uint8_t instance_id); -//extern float pseudo_log_curve(float value, bool type); +extern uint8_t selected_instance_id; #ifdef DISPLAY_LCD_SPI extern void change_disp_sd(bool d); @@ -998,17 +998,15 @@ void UI_func_reverb_level(uint8_t param) void UI_func_chorus_frequency(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_float("Chorus Frq.", configuration.fx.chorus_frequency[instance_id], 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, true); + lcd_display_bar_float("Chorus Frq.", configuration.fx.chorus_frequency[selected_instance_id], 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1022,14 +1020,14 @@ void UI_func_chorus_frequency(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.chorus_frequency[instance_id] = constrain(configuration.fx.chorus_frequency[instance_id] + ENCODER[ENC_R].speed(), CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); + configuration.fx.chorus_frequency[selected_instance_id] = constrain(configuration.fx.chorus_frequency[selected_instance_id] + ENCODER[ENC_R].speed(), CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.chorus_frequency[instance_id] = constrain(configuration.fx.chorus_frequency[instance_id] - ENCODER[ENC_R].speed(), CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); + configuration.fx.chorus_frequency[selected_instance_id] = constrain(configuration.fx.chorus_frequency[selected_instance_id] - ENCODER[ENC_R].speed(), CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1037,9 +1035,9 @@ void UI_func_chorus_frequency(uint8_t param) } #endif } - lcd_display_bar_float("Chorus Frq.", configuration.fx.chorus_frequency[instance_id], 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, false); + lcd_display_bar_float("Chorus Frq.", configuration.fx.chorus_frequency[selected_instance_id], 0.1, CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX, 2, 1, false, false, false, false); - chorus_modulator[instance_id]->frequency(configuration.fx.chorus_frequency[instance_id] / 10.0); + chorus_modulator[selected_instance_id]->frequency(configuration.fx.chorus_frequency[selected_instance_id] / 10.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1055,8 +1053,6 @@ void UI_func_chorus_frequency(uint8_t param) void UI_func_chorus_waveform(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -1065,7 +1061,7 @@ void UI_func_chorus_waveform(uint8_t param) lcd.print(F("Chorus Waveform")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1076,14 +1072,14 @@ void UI_func_chorus_waveform(uint8_t param) if (LCDML.FUNC_loop()) // ****** LOOP ********* { if (LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) - configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id] + 1, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); + configuration.fx.chorus_waveform[selected_instance_id] = constrain(configuration.fx.chorus_waveform[selected_instance_id] + 1, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); else if (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) - configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id] - 1, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); + configuration.fx.chorus_waveform[selected_instance_id] = constrain(configuration.fx.chorus_waveform[selected_instance_id] - 1, CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1092,18 +1088,18 @@ void UI_func_chorus_waveform(uint8_t param) #endif lcd.setCursor(0, 1); - switch (configuration.fx.chorus_waveform[instance_id]) + switch (configuration.fx.chorus_waveform[selected_instance_id]) { case 0: - chorus_modulator[instance_id]->begin(WAVEFORM_TRIANGLE); + chorus_modulator[selected_instance_id]->begin(WAVEFORM_TRIANGLE); lcd.print(F("[TRIANGLE]")); break; case 1: - chorus_modulator[instance_id]->begin(WAVEFORM_SINE); + chorus_modulator[selected_instance_id]->begin(WAVEFORM_SINE); lcd.print(F("[SINE ]")); break; default: - chorus_modulator[instance_id]->begin(WAVEFORM_TRIANGLE); + chorus_modulator[selected_instance_id]->begin(WAVEFORM_TRIANGLE); lcd.print(F("[TRIANGLE]")); break; } @@ -1121,17 +1117,15 @@ void UI_func_chorus_waveform(uint8_t param) void UI_func_chorus_depth(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Chorus Dpt.", configuration.fx.chorus_depth[instance_id], 1.0, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 3, false, false, false, true); + lcd_display_bar_int("Chorus Dpt.", configuration.fx.chorus_depth[selected_instance_id], 1.0, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1144,14 +1138,14 @@ void UI_func_chorus_depth(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id] + ENCODER[ENC_R].speed(), CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); + configuration.fx.chorus_depth[selected_instance_id] = constrain(configuration.fx.chorus_depth[selected_instance_id] + ENCODER[ENC_R].speed(), CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id] - ENCODER[ENC_R].speed(), CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); + configuration.fx.chorus_depth[selected_instance_id] = constrain(configuration.fx.chorus_depth[selected_instance_id] - ENCODER[ENC_R].speed(), CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1160,9 +1154,9 @@ void UI_func_chorus_depth(uint8_t param) #endif } - lcd_display_bar_int("Chorus Dpt.", configuration.fx.chorus_depth[instance_id], 1.0, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 3, false, false, false, false); + lcd_display_bar_int("Chorus Dpt.", configuration.fx.chorus_depth[selected_instance_id], 1.0, CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX, 3, false, false, false, false); - chorus_modulator[instance_id]->amplitude(configuration.fx.chorus_depth[instance_id] / 100.0); + chorus_modulator[selected_instance_id]->amplitude(configuration.fx.chorus_depth[selected_instance_id] / 100.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1178,17 +1172,15 @@ void UI_func_chorus_depth(uint8_t param) void UI_func_chorus_level(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Chorus Lvl.", configuration.fx.chorus_level[instance_id], 1.0, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 3, false, false, false, true); + lcd_display_bar_int("Chorus Lvl.", configuration.fx.chorus_level[selected_instance_id], 1.0, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1201,14 +1193,14 @@ void UI_func_chorus_level(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.chorus_level[instance_id] = constrain(configuration.fx.chorus_level[instance_id] + ENCODER[ENC_R].speed(), CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); + configuration.fx.chorus_level[selected_instance_id] = constrain(configuration.fx.chorus_level[selected_instance_id] + ENCODER[ENC_R].speed(), CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.chorus_level[instance_id] = constrain(configuration.fx.chorus_level[instance_id] - ENCODER[ENC_R].speed(), CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); + configuration.fx.chorus_level[selected_instance_id] = constrain(configuration.fx.chorus_level[selected_instance_id] - ENCODER[ENC_R].speed(), CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1217,12 +1209,12 @@ void UI_func_chorus_level(uint8_t param) #endif } - lcd_display_bar_int("Chorus Lvl.", configuration.fx.chorus_level[instance_id], 1.0, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 3, false, false, false, false); + lcd_display_bar_int("Chorus Lvl.", configuration.fx.chorus_level[selected_instance_id], 1.0, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 3, false, false, false, false); - //chorus_mixer[instance_id]->gain(0, 1.0 - pseudo_log_curve(mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0), true)); - //chorus_mixer[instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0), true)); - //chorus_mixer[instance_id]->gain(0, 1.0 - mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)); - chorus_mixer[instance_id]->gain(1, mapfloat(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)); + //chorus_mixer[selected_instance_id]->gain(0, 1.0 - pseudo_log_curve(mapfloat(configuration.fx.chorus_level[selected_instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0), true)); + //chorus_mixer[selected_instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.chorus_level[selected_instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0), true)); + //chorus_mixer[selected_instance_id]->gain(0, 1.0 - mapfloat(configuration.fx.chorus_level[selected_instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)); + chorus_mixer[selected_instance_id]->gain(1, mapfloat(configuration.fx.chorus_level[selected_instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1238,17 +1230,15 @@ void UI_func_chorus_level(uint8_t param) void UI_func_delay_time(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1261,14 +1251,14 @@ void UI_func_delay_time(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id] + ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); + configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] + ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id] - ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); + configuration.fx.delay_time[selected_instance_id] = constrain(configuration.fx.delay_time[selected_instance_id] - ENCODER[ENC_R].speed(), DELAY_TIME_MIN, DELAY_TIME_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1277,9 +1267,9 @@ void UI_func_delay_time(uint8_t param) #endif } - lcd_display_bar_int("Delay Time", configuration.fx.delay_time[instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, false, true); + lcd_display_bar_int("Delay Time", configuration.fx.delay_time[selected_instance_id], 10.0, DELAY_TIME_MIN, DELAY_TIME_MAX, 3, false, false, false, true); - delay_fx[instance_id]->delay(0, configuration.fx.delay_time[instance_id] * 10); + delay_fx[selected_instance_id]->delay(0, configuration.fx.delay_time[selected_instance_id] * 10); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1295,17 +1285,15 @@ void UI_func_delay_time(uint8_t param) void UI_func_delay_feedback(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Delay Feedb.", configuration.fx.delay_feedback[instance_id], 1.0, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 3, false, false, false, true); + lcd_display_bar_int("Delay Feedb.", configuration.fx.delay_feedback[selected_instance_id], 1.0, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1318,14 +1306,14 @@ void UI_func_delay_feedback(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id] + ENCODER[ENC_R].speed(), DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); + configuration.fx.delay_feedback[selected_instance_id] = constrain(configuration.fx.delay_feedback[selected_instance_id] + ENCODER[ENC_R].speed(), DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id] - ENCODER[ENC_R].speed(), DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); + configuration.fx.delay_feedback[selected_instance_id] = constrain(configuration.fx.delay_feedback[selected_instance_id] - ENCODER[ENC_R].speed(), DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1334,9 +1322,9 @@ void UI_func_delay_feedback(uint8_t param) #endif } - lcd_display_bar_int("Delay Feedb.", configuration.fx.delay_feedback[instance_id], 1.0, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 3, false, false, false, false); + lcd_display_bar_int("Delay Feedb.", configuration.fx.delay_feedback[selected_instance_id], 1.0, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 3, false, false, false, false); - delay_fb_mixer[instance_id]->gain(1, configuration.fx.delay_feedback[instance_id] / 100.0); // amount of feedback + delay_fb_mixer[selected_instance_id]->gain(1, configuration.fx.delay_feedback[selected_instance_id] / 100.0); // amount of feedback } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1352,17 +1340,15 @@ void UI_func_delay_feedback(uint8_t param) void UI_func_delay_level(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Delay Lvl.", configuration.fx.delay_level[instance_id], 1.0, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 3, false, false, false, true); + lcd_display_bar_int("Delay Lvl.", configuration.fx.delay_level[selected_instance_id], 1.0, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1375,14 +1361,14 @@ void UI_func_delay_level(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id] + ENCODER[ENC_R].speed(), DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); + configuration.fx.delay_level[selected_instance_id] = constrain(configuration.fx.delay_level[selected_instance_id] + ENCODER[ENC_R].speed(), DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id] - ENCODER[ENC_R].speed(), DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); + configuration.fx.delay_level[selected_instance_id] = constrain(configuration.fx.delay_level[selected_instance_id] - ENCODER[ENC_R].speed(), DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1391,9 +1377,9 @@ void UI_func_delay_level(uint8_t param) #endif } - lcd_display_bar_int("Delay Lvl.", configuration.fx.delay_level[instance_id], 1.0, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 3, false, false, false, false); + lcd_display_bar_int("Delay Lvl.", configuration.fx.delay_level[selected_instance_id], 1.0, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 3, false, false, false, false); - delay_mixer[instance_id]->gain(1, mapfloat(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + delay_mixer[selected_instance_id]->gain(1, mapfloat(configuration.fx.delay_level[selected_instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1409,17 +1395,15 @@ void UI_func_delay_level(uint8_t param) void UI_func_reverb_send(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Reverb Send", configuration.fx.reverb_send[instance_id], 1.0, REVERB_SEND_MIN, REVERB_SEND_MAX, 3, false, false, false, true); + lcd_display_bar_int("Reverb Send", configuration.fx.reverb_send[selected_instance_id], 1.0, REVERB_SEND_MIN, REVERB_SEND_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1432,14 +1416,14 @@ void UI_func_reverb_send(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id] + ENCODER[ENC_R].speed(), REVERB_SEND_MIN, REVERB_SEND_MAX); + configuration.fx.reverb_send[selected_instance_id] = constrain(configuration.fx.reverb_send[selected_instance_id] + ENCODER[ENC_R].speed(), REVERB_SEND_MIN, REVERB_SEND_MAX); else if (LCDML.BT_checkUp()) - configuration.fx.reverb_send[instance_id] = constrain(configuration.fx.reverb_send[instance_id] - ENCODER[ENC_R].speed(), REVERB_SEND_MIN, REVERB_SEND_MAX); + configuration.fx.reverb_send[selected_instance_id] = constrain(configuration.fx.reverb_send[selected_instance_id] - ENCODER[ENC_R].speed(), REVERB_SEND_MIN, REVERB_SEND_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1448,10 +1432,10 @@ void UI_func_reverb_send(uint8_t param) #endif } - lcd_display_bar_int("Reverb Send", configuration.fx.reverb_send[instance_id], 1.0, REVERB_SEND_MIN, REVERB_SEND_MAX, 3, false, false, false, false); + lcd_display_bar_int("Reverb Send", configuration.fx.reverb_send[selected_instance_id], 1.0, REVERB_SEND_MIN, REVERB_SEND_MAX, 3, false, false, false, false); - reverb_mixer_r.gain(instance_id, configuration.fx.reverb_send[instance_id] / 100.0); - reverb_mixer_l.gain(instance_id, configuration.fx.reverb_send[instance_id] / 100.0); + reverb_mixer_r.gain(selected_instance_id, configuration.fx.reverb_send[selected_instance_id] / 100.0); + reverb_mixer_l.gain(selected_instance_id, configuration.fx.reverb_send[selected_instance_id] / 100.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1467,17 +1451,15 @@ void UI_func_reverb_send(uint8_t param) void UI_func_filter_cutoff(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Filter Cut", configuration.dexed[instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false, true); + lcd_display_bar_int("Filter Cut", configuration.dexed[selected_instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1490,14 +1472,14 @@ void UI_func_filter_cutoff(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff + ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.dexed[selected_instance_id].filter_cutoff = constrain(configuration.dexed[selected_instance_id].filter_cutoff + ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff - ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.dexed[selected_instance_id].filter_cutoff = constrain(configuration.dexed[selected_instance_id].filter_cutoff - ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1506,9 +1488,9 @@ void UI_func_filter_cutoff(uint8_t param) #endif } - lcd_display_bar_int("Filter Cut", configuration.dexed[instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false, false); + lcd_display_bar_int("Filter Cut", configuration.dexed[selected_instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false, false); - MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); + MicroDexed[selected_instance_id]->fx.Cutoff = mapfloat(configuration.dexed[selected_instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1524,17 +1506,15 @@ void UI_func_filter_cutoff(uint8_t param) void UI_func_filter_resonance(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Filter Res", configuration.dexed[instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false, true); + lcd_display_bar_int("Filter Res", configuration.dexed[selected_instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1547,14 +1527,14 @@ void UI_func_filter_resonance(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance + ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + configuration.dexed[selected_instance_id].filter_resonance = constrain(configuration.dexed[selected_instance_id].filter_resonance + ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance - ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + configuration.dexed[selected_instance_id].filter_resonance = constrain(configuration.dexed[selected_instance_id].filter_resonance - ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1563,9 +1543,9 @@ void UI_func_filter_resonance(uint8_t param) #endif } - lcd_display_bar_int("Filter Res", configuration.dexed[instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false, false); + lcd_display_bar_int("Filter Res", configuration.dexed[selected_instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false, false); - MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); + MicroDexed[selected_instance_id]->fx.Reso = mapfloat(configuration.dexed[selected_instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1582,17 +1562,15 @@ void UI_func_filter_resonance(uint8_t param) void UI_func_transpose(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(METERBAR); - lcd_display_meter_int("Transpose", configuration.dexed[instance_id].transpose, 1.0, -24.0, TRANSPOSE_MIN, TRANSPOSE_MAX, 3, false, false, true, true); + lcd_display_meter_int("Transpose", configuration.dexed[selected_instance_id].transpose, 1.0, -24.0, TRANSPOSE_MIN, TRANSPOSE_MAX, 3, false, false, true, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1605,14 +1583,14 @@ void UI_func_transpose(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose + ENCODER[ENC_R].speed(), TRANSPOSE_MIN, TRANSPOSE_MAX); + configuration.dexed[selected_instance_id].transpose = constrain(configuration.dexed[selected_instance_id].transpose + ENCODER[ENC_R].speed(), TRANSPOSE_MIN, TRANSPOSE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose - ENCODER[ENC_R].speed(), TRANSPOSE_MIN, TRANSPOSE_MAX); + configuration.dexed[selected_instance_id].transpose = constrain(configuration.dexed[selected_instance_id].transpose - ENCODER[ENC_R].speed(), TRANSPOSE_MIN, TRANSPOSE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1621,10 +1599,10 @@ void UI_func_transpose(uint8_t param) #endif } - lcd_display_meter_int("Transpose", configuration.dexed[instance_id].transpose, 1.0, -24.0, TRANSPOSE_MIN, TRANSPOSE_MAX, 3, false, false, true, true); + lcd_display_meter_int("Transpose", configuration.dexed[selected_instance_id].transpose, 1.0, -24.0, TRANSPOSE_MIN, TRANSPOSE_MAX, 3, false, false, true, true); - MicroDexed[instance_id]->data[DEXED_VOICE_OFFSET + DEXED_TRANSPOSE] = configuration.dexed[instance_id].transpose; - MicroDexed[instance_id]->notesOff(); + MicroDexed[selected_instance_id]->data[DEXED_VOICE_OFFSET + DEXED_TRANSPOSE] = configuration.dexed[selected_instance_id].transpose; + MicroDexed[selected_instance_id]->notesOff(); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1640,17 +1618,15 @@ void UI_func_transpose(uint8_t param) void UI_func_tune(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(METERBAR); - lcd_display_meter_int("Fine Tune", configuration.dexed[instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, true); + lcd_display_meter_int("Fine Tune", configuration.dexed[selected_instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1663,14 +1639,14 @@ void UI_func_tune(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune + ENCODER[ENC_R].speed(), TUNE_MIN, TUNE_MAX); + configuration.dexed[selected_instance_id].tune = constrain(configuration.dexed[selected_instance_id].tune + ENCODER[ENC_R].speed(), TUNE_MIN, TUNE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].tune = constrain(configuration.dexed[instance_id].tune - ENCODER[ENC_R].speed(), TUNE_MIN, TUNE_MAX); + configuration.dexed[selected_instance_id].tune = constrain(configuration.dexed[selected_instance_id].tune - ENCODER[ENC_R].speed(), TUNE_MIN, TUNE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1679,10 +1655,10 @@ void UI_func_tune(uint8_t param) #endif } - lcd_display_meter_int("Fine Tune", configuration.dexed[instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, false); + lcd_display_meter_int("Fine Tune", configuration.dexed[selected_instance_id].tune, 1.0, -100.0, TUNE_MIN, TUNE_MAX, 3, false, false, true, false); - MicroDexed[instance_id]->controllers.masterTune = (int((configuration.dexed[instance_id].tune - 100) / 100.0 * 0x4000) << 11) * (1.0 / 12); - MicroDexed[instance_id]->doRefreshVoice(); + MicroDexed[selected_instance_id]->controllers.masterTune = (int((configuration.dexed[selected_instance_id].tune - 100) / 100.0 * 0x4000) << 11) * (1.0 / 12); + MicroDexed[selected_instance_id]->doRefreshVoice(); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1698,8 +1674,6 @@ void UI_func_tune(uint8_t param) void UI_func_midi_channel(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -1708,7 +1682,7 @@ void UI_func_midi_channel(uint8_t param) lcd.print(F("MIDI Channel")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1719,14 +1693,14 @@ void UI_func_midi_channel(uint8_t param) if (LCDML.FUNC_loop()) // ****** LOOP ********* { if (LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) - configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel + ENCODER[ENC_R].speed(), MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); + configuration.dexed[selected_instance_id].midi_channel = constrain(configuration.dexed[selected_instance_id].midi_channel + ENCODER[ENC_R].speed(), MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); else if (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) - configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel - ENCODER[ENC_R].speed(), MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); + configuration.dexed[selected_instance_id].midi_channel = constrain(configuration.dexed[selected_instance_id].midi_channel - ENCODER[ENC_R].speed(), MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1735,13 +1709,13 @@ void UI_func_midi_channel(uint8_t param) #endif lcd.setCursor(0, 1); - if (configuration.dexed[instance_id].midi_channel == 0) + if (configuration.dexed[selected_instance_id].midi_channel == 0) { lcd.print(F("[OMNI]")); } else { - lcd_display_int(configuration.dexed[instance_id].midi_channel, 4, false, true, false); + lcd_display_int(configuration.dexed[selected_instance_id].midi_channel, 4, false, true, false); } } @@ -1767,14 +1741,13 @@ void getNoteName(char* noteName, uint8_t noteNumber) void UI_func_lowest_note(uint8_t param) { - static uint8_t instance_id; char note_name[4]; if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); - getNoteName(note_name, configuration.dexed[instance_id].lowest_note); + getNoteName(note_name, configuration.dexed[selected_instance_id].lowest_note); lcd.setCursor(0, 0); lcd.print(F("Lowest Note")); lcd.setCursor(0, 1); @@ -1783,7 +1756,7 @@ void UI_func_lowest_note(uint8_t param) lcd.print(F("]")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1796,14 +1769,14 @@ void UI_func_lowest_note(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].lowest_note = constrain(configuration.dexed[instance_id].lowest_note + ENCODER[ENC_R].speed(), INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); + configuration.dexed[selected_instance_id].lowest_note = constrain(configuration.dexed[selected_instance_id].lowest_note + ENCODER[ENC_R].speed(), INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].lowest_note = constrain(configuration.dexed[instance_id].lowest_note - ENCODER[ENC_R].speed(), INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); + configuration.dexed[selected_instance_id].lowest_note = constrain(configuration.dexed[selected_instance_id].lowest_note - ENCODER[ENC_R].speed(), INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1812,7 +1785,7 @@ void UI_func_lowest_note(uint8_t param) #endif } - getNoteName(note_name, configuration.dexed[instance_id].lowest_note); + getNoteName(note_name, configuration.dexed[selected_instance_id].lowest_note); lcd.setCursor(1, 1); lcd.print(note_name); } @@ -1829,14 +1802,13 @@ void UI_func_lowest_note(uint8_t param) void UI_func_highest_note(uint8_t param) { - static uint8_t instance_id; char note_name[4]; if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); - getNoteName(note_name, configuration.dexed[instance_id].highest_note); + getNoteName(note_name, configuration.dexed[selected_instance_id].highest_note); lcd.setCursor(0, 0); lcd.print(F("Highest Note")); lcd.setCursor(0, 1); @@ -1845,7 +1817,7 @@ void UI_func_highest_note(uint8_t param) lcd.print(F("]")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1858,14 +1830,14 @@ void UI_func_highest_note(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].highest_note = constrain(configuration.dexed[instance_id].highest_note + ENCODER[ENC_R].speed(), INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); + configuration.dexed[selected_instance_id].highest_note = constrain(configuration.dexed[selected_instance_id].highest_note + ENCODER[ENC_R].speed(), INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].highest_note = constrain(configuration.dexed[instance_id].highest_note - ENCODER[ENC_R].speed(), INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); + configuration.dexed[selected_instance_id].highest_note = constrain(configuration.dexed[selected_instance_id].highest_note - ENCODER[ENC_R].speed(), INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1874,7 +1846,7 @@ void UI_func_highest_note(uint8_t param) #endif } - getNoteName(note_name, configuration.dexed[instance_id].highest_note); + getNoteName(note_name, configuration.dexed[selected_instance_id].highest_note); lcd.setCursor(1, 1); lcd.print(note_name); } @@ -1891,17 +1863,15 @@ void UI_func_highest_note(uint8_t param) void UI_func_sound_intensity(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Voice Level", configuration.dexed[instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, true); + lcd_display_bar_int("Voice Level", configuration.dexed[selected_instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1916,14 +1886,14 @@ void UI_func_sound_intensity(uint8_t param) encoderDir[ENC_R].reset(); if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity + ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); + configuration.dexed[selected_instance_id].sound_intensity = constrain(configuration.dexed[selected_instance_id].sound_intensity + ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity - ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); + configuration.dexed[selected_instance_id].sound_intensity = constrain(configuration.dexed[selected_instance_id].sound_intensity - ENCODER[ENC_R].speed(), SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1932,8 +1902,8 @@ void UI_func_sound_intensity(uint8_t param) #endif } - lcd_display_bar_int("Voice Level", configuration.dexed[instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, false); - dexed_level[instance_id]->gain(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX)); + lcd_display_bar_int("Voice Level", configuration.dexed[selected_instance_id].sound_intensity, 1.0, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 3, false, false, false, false); + dexed_level[selected_instance_id]->gain(mapfloat(configuration.dexed[selected_instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX)); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1949,8 +1919,6 @@ void UI_func_sound_intensity(uint8_t param) void UI_func_panorama(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -1964,10 +1932,10 @@ void UI_func_panorama(uint8_t param) return; } lcd_special_chars(METERBAR); - lcd_display_meter_float("Panorama", configuration.dexed[instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, true); + lcd_display_meter_float("Panorama", configuration.dexed[selected_instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1978,14 +1946,14 @@ void UI_func_panorama(uint8_t param) if (LCDML.FUNC_loop()) // ****** LOOP ********* { if (LCDML.BT_checkDown() && encoderDir[ENC_R].Down() && configuration.sys.mono == 0) - configuration.dexed[instance_id].pan = constrain(configuration.dexed[instance_id].pan + ENCODER[ENC_R].speed(), PANORAMA_MIN, PANORAMA_MAX); + configuration.dexed[selected_instance_id].pan = constrain(configuration.dexed[selected_instance_id].pan + ENCODER[ENC_R].speed(), PANORAMA_MIN, PANORAMA_MAX); else if (LCDML.BT_checkUp() && encoderDir[ENC_R].Up() && configuration.sys.mono == 0) - configuration.dexed[instance_id].pan = constrain(configuration.dexed[instance_id].pan - ENCODER[ENC_R].speed(), PANORAMA_MIN, PANORAMA_MAX); + configuration.dexed[selected_instance_id].pan = constrain(configuration.dexed[selected_instance_id].pan - ENCODER[ENC_R].speed(), PANORAMA_MIN, PANORAMA_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -1995,8 +1963,8 @@ void UI_func_panorama(uint8_t param) if (configuration.sys.mono == 0) { - lcd_display_meter_float("Panorama", configuration.dexed[instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, false); - mono2stereo[instance_id]->panorama(mapfloat(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); + lcd_display_meter_float("Panorama", configuration.dexed[selected_instance_id].pan, 0.05, -20.0, PANORAMA_MIN, PANORAMA_MAX, 3, 1, false, false, true, false); + mono2stereo[selected_instance_id]->panorama(mapfloat(configuration.dexed[selected_instance_id].pan, PANORAMA_MIN, PANORAMA_MAX, -1.0, 1.0)); } } @@ -2078,20 +2046,17 @@ void UI_func_stereo_mono(uint8_t param) } } -//#if NUM_DEXED == 1 void UI_func_polyphony(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Polyphony", configuration.dexed[instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 3, false, false, false, true); + lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 3, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2104,26 +2069,26 @@ void UI_func_polyphony(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony + ENCODER[ENC_R].speed(), POLYPHONY_MIN, POLYPHONY_MAX); + configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony + ENCODER[ENC_R].speed(), POLYPHONY_MIN, POLYPHONY_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].polyphony = constrain(configuration.dexed[instance_id].polyphony - ENCODER[ENC_R].speed(), POLYPHONY_MIN, POLYPHONY_MAX); + configuration.dexed[selected_instance_id].polyphony = constrain(configuration.dexed[selected_instance_id].polyphony - ENCODER[ENC_R].speed(), POLYPHONY_MIN, POLYPHONY_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); lcd.write(6); } #endif - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); } - lcd_display_bar_int("Polyphony", configuration.dexed[instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 3, false, false, false, false); + lcd_display_bar_int("Polyphony", configuration.dexed[selected_instance_id].polyphony, 1.0, POLYPHONY_MIN, POLYPHONY_MAX, 3, false, false, false, false); - MicroDexed[instance_id]->setMaxNotes(configuration.dexed[instance_id].polyphony); + MicroDexed[selected_instance_id]->setMaxNotes(configuration.dexed[selected_instance_id].polyphony); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2136,92 +2101,9 @@ void UI_func_polyphony(uint8_t param) #endif } } -/* - #else - void UI_func_polyphony(uint8_t param) - { - char poly_value_string[3]; - static uint8_t poly_instance_id; - - if (LCDML.FUNC_setup()) // ****** SETUP ********* - { - encoderDir[ENC_R].reset(); - - if (LCDML.FUNC_getID() > MENU_ID_OF_INSTANCE_2) - poly_instance_id = 1; - else - poly_instance_id = 0; - - lcd.show(0, 0, 16, "Polyphony"); - if (poly_instance_id == 0) - lcd.show(1, 0, 16, "1:[ ] 2:"); - else - lcd.show(1, 0, 16, "1: 2:[ ]"); - - sprintf(poly_value_string, "%2d", configuration.dexed[0].polyphony); - lcd.show(1, 3, 2, poly_value_string); - sprintf(poly_value_string, "%2d", configuration.dexed[1].polyphony); - lcd.show(1, 13, 2, poly_value_string); - } - - if (LCDML.FUNC_loop()) // ****** LOOP ********* - { - if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) - { - if (LCDML.BT_checkDown()) - { - if (configuration.dexed[0].polyphony + configuration.dexed[1].polyphony + 1 <= POLYPHONY_MAX) - configuration.dexed[poly_instance_id].polyphony = constrain(configuration.dexed[poly_instance_id].polyphony + 1, POLYPHONY_MIN, POLYPHONY_MAX); - } - else if (LCDML.BT_checkUp()) - { - if (configuration.dexed[poly_instance_id].polyphony - 1 < 0) - configuration.dexed[poly_instance_id].polyphony = 0; - else - configuration.dexed[poly_instance_id].polyphony = constrain(configuration.dexed[poly_instance_id].polyphony - 1, POLYPHONY_MIN - 1, POLYPHONY_MAX); - } - else if (LCDML.BT_checkEnter()) - { - poly_instance_id = !poly_instance_id; - if (poly_instance_id == 0) - lcd.show(1, 0, 16, "1:[ ] 2:"); - else - lcd.show(1, 0, 16, "1: 2:[ ]"); - sprintf(poly_value_string, "%2d", configuration.dexed[0].polyphony); - lcd.show(1, 3, 2, poly_value_string); - sprintf(poly_value_string, "%2d", configuration.dexed[1].polyphony); - lcd.show(1, 13, 2, poly_value_string); - } - } - - if (poly_instance_id == 0) - { - MicroDexed[0]->setMaxNotes(configuration.dexed[0].polyphony); - sprintf(poly_value_string, "%2d", configuration.dexed[0].polyphony); - lcd.show(1, 3, 2, poly_value_string); - } - else - { - MicroDexed[1]->setMaxNotes(configuration.dexed[1].polyphony); - sprintf(poly_value_string, "%2d", configuration.dexed[1].polyphony); - lcd.show(1, 13, 2, poly_value_string); - } - } - - if (LCDML.FUNC_close()) // ****** STABLE END ********* - { - encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].polyphony), configuration.dexed[0].polyphony); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1].polyphony), configuration.dexed[1].polyphony); - } - } - #endif -*/ void UI_func_engine(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2230,7 +2112,7 @@ void UI_func_engine(uint8_t param) lcd.print(F("Engine")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2243,14 +2125,14 @@ void UI_func_engine(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].engine = constrain(configuration.dexed[instance_id].engine + 1, ENGINE_MIN, ENGINE_MAX); + configuration.dexed[selected_instance_id].engine = constrain(configuration.dexed[selected_instance_id].engine + 1, ENGINE_MIN, ENGINE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].engine = constrain(configuration.dexed[instance_id].engine - 1, ENGINE_MIN, ENGINE_MAX); + configuration.dexed[selected_instance_id].engine = constrain(configuration.dexed[selected_instance_id].engine - 1, ENGINE_MIN, ENGINE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2259,10 +2141,10 @@ void UI_func_engine(uint8_t param) #endif } - MicroDexed[instance_id]->setEngineType(configuration.dexed[instance_id].engine); + MicroDexed[selected_instance_id]->setEngineType(configuration.dexed[selected_instance_id].engine); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].engine) + switch (configuration.dexed[selected_instance_id].engine) { case 0: lcd.print(F("[MODERN]")); @@ -2288,8 +2170,6 @@ void UI_func_engine(uint8_t param) void UI_func_mono_poly(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2298,7 +2178,7 @@ void UI_func_mono_poly(uint8_t param) lcd.print(F("Mono/Polyphonic")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2311,27 +2191,27 @@ void UI_func_mono_poly(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].monopoly = constrain(configuration.dexed[instance_id].monopoly + 1, MONOPOLY_MIN, MONOPOLY_MAX); + configuration.dexed[selected_instance_id].monopoly = constrain(configuration.dexed[selected_instance_id].monopoly + 1, MONOPOLY_MIN, MONOPOLY_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].monopoly = constrain(configuration.dexed[instance_id].monopoly - 1, MONOPOLY_MIN, MONOPOLY_MAX); + configuration.dexed[selected_instance_id].monopoly = constrain(configuration.dexed[selected_instance_id].monopoly - 1, MONOPOLY_MIN, MONOPOLY_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); lcd.write(6); } #endif - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); } - MicroDexed[instance_id]->setMonoMode(!configuration.dexed[instance_id].monopoly); + MicroDexed[selected_instance_id]->setMonoMode(!configuration.dexed[selected_instance_id].monopoly); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].monopoly) + switch (configuration.dexed[selected_instance_id].monopoly) { case 0: lcd.print(F("[MONOPHONIC]")); @@ -2354,8 +2234,6 @@ void UI_func_mono_poly(uint8_t param) void UI_func_note_refresh(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2364,7 +2242,7 @@ void UI_func_note_refresh(uint8_t param) lcd.print(F("Note Refresh")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2377,14 +2255,14 @@ void UI_func_note_refresh(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].note_refresh = constrain(configuration.dexed[instance_id].note_refresh + 1, NOTE_REFRESH_MIN, NOTE_REFRESH_MAX); + configuration.dexed[selected_instance_id].note_refresh = constrain(configuration.dexed[selected_instance_id].note_refresh + 1, NOTE_REFRESH_MIN, NOTE_REFRESH_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].note_refresh = constrain(configuration.dexed[instance_id].note_refresh - 1, NOTE_REFRESH_MIN, NOTE_REFRESH_MAX); + configuration.dexed[selected_instance_id].note_refresh = constrain(configuration.dexed[selected_instance_id].note_refresh - 1, NOTE_REFRESH_MIN, NOTE_REFRESH_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2393,10 +2271,10 @@ void UI_func_note_refresh(uint8_t param) #endif } - MicroDexed[instance_id]->setRefreshMode(configuration.dexed[instance_id].note_refresh); + MicroDexed[selected_instance_id]->setRefreshMode(configuration.dexed[selected_instance_id].note_refresh); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].note_refresh) + switch (configuration.dexed[selected_instance_id].note_refresh) { case 0: lcd.print(F("[NORMAL ]")); @@ -2419,17 +2297,15 @@ void UI_func_note_refresh(uint8_t param) void UI_func_pb_range(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("PB Range", configuration.dexed[instance_id].pb_range, 1.0, PB_RANGE_MIN, PB_RANGE_MAX, 2, false, false, false, true); + lcd_display_bar_int("PB Range", configuration.dexed[selected_instance_id].pb_range, 1.0, PB_RANGE_MIN, PB_RANGE_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2442,14 +2318,14 @@ void UI_func_pb_range(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].pb_range = constrain(configuration.dexed[instance_id].pb_range + ENCODER[ENC_R].speed(), PB_RANGE_MIN, PB_RANGE_MAX); + configuration.dexed[selected_instance_id].pb_range = constrain(configuration.dexed[selected_instance_id].pb_range + ENCODER[ENC_R].speed(), PB_RANGE_MIN, PB_RANGE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].pb_range = constrain(configuration.dexed[instance_id].pb_range - ENCODER[ENC_R].speed(), PB_RANGE_MIN, PB_RANGE_MAX); + configuration.dexed[selected_instance_id].pb_range = constrain(configuration.dexed[selected_instance_id].pb_range - ENCODER[ENC_R].speed(), PB_RANGE_MIN, PB_RANGE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2458,9 +2334,9 @@ void UI_func_pb_range(uint8_t param) #endif } - lcd_display_bar_int("PB Range", configuration.dexed[instance_id].pb_range, 1.0, PB_RANGE_MIN, PB_RANGE_MAX, 2, false, false, false, false); + lcd_display_bar_int("PB Range", configuration.dexed[selected_instance_id].pb_range, 1.0, PB_RANGE_MIN, PB_RANGE_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setPBController(configuration.dexed[instance_id].pb_range, configuration.dexed[instance_id].pb_step); + MicroDexed[selected_instance_id]->setPBController(configuration.dexed[selected_instance_id].pb_range, configuration.dexed[selected_instance_id].pb_step); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2476,17 +2352,15 @@ void UI_func_pb_range(uint8_t param) void UI_func_pb_step(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("PB Step", configuration.dexed[instance_id].pb_step, 1.0, PB_STEP_MIN, PB_STEP_MAX, 2, false, false, false, true); + lcd_display_bar_int("PB Step", configuration.dexed[selected_instance_id].pb_step, 1.0, PB_STEP_MIN, PB_STEP_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2499,14 +2373,14 @@ void UI_func_pb_step(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].pb_step = constrain(configuration.dexed[instance_id].pb_step + ENCODER[ENC_R].speed(), PB_STEP_MIN, PB_STEP_MAX); + configuration.dexed[selected_instance_id].pb_step = constrain(configuration.dexed[selected_instance_id].pb_step + ENCODER[ENC_R].speed(), PB_STEP_MIN, PB_STEP_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].pb_step = constrain(configuration.dexed[instance_id].pb_step - ENCODER[ENC_R].speed(), PB_STEP_MIN, PB_STEP_MAX); + configuration.dexed[selected_instance_id].pb_step = constrain(configuration.dexed[selected_instance_id].pb_step - ENCODER[ENC_R].speed(), PB_STEP_MIN, PB_STEP_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2515,9 +2389,9 @@ void UI_func_pb_step(uint8_t param) #endif } - lcd_display_bar_int("PB Step", configuration.dexed[instance_id].pb_step, 1.0, PB_STEP_MIN, PB_STEP_MAX, 2, false, false, false, false); + lcd_display_bar_int("PB Step", configuration.dexed[selected_instance_id].pb_step, 1.0, PB_STEP_MIN, PB_STEP_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setPBController(configuration.dexed[instance_id].pb_range, configuration.dexed[instance_id].pb_step); + MicroDexed[selected_instance_id]->setPBController(configuration.dexed[selected_instance_id].pb_range, configuration.dexed[selected_instance_id].pb_step); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2533,17 +2407,15 @@ void UI_func_pb_step(uint8_t param) void UI_func_mw_range(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("MW Range", configuration.dexed[instance_id].mw_range, 1.0, MW_RANGE_MIN, MW_RANGE_MAX, 2, false, false, false, true); + lcd_display_bar_int("MW Range", configuration.dexed[selected_instance_id].mw_range, 1.0, MW_RANGE_MIN, MW_RANGE_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2556,14 +2428,14 @@ void UI_func_mw_range(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].mw_range = constrain(configuration.dexed[instance_id].mw_range + ENCODER[ENC_R].speed(), MW_RANGE_MIN, MW_RANGE_MAX); + configuration.dexed[selected_instance_id].mw_range = constrain(configuration.dexed[selected_instance_id].mw_range + ENCODER[ENC_R].speed(), MW_RANGE_MIN, MW_RANGE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].mw_range = constrain(configuration.dexed[instance_id].mw_range - ENCODER[ENC_R].speed(), MW_RANGE_MIN, MW_RANGE_MAX); + configuration.dexed[selected_instance_id].mw_range = constrain(configuration.dexed[selected_instance_id].mw_range - ENCODER[ENC_R].speed(), MW_RANGE_MIN, MW_RANGE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2572,9 +2444,9 @@ void UI_func_mw_range(uint8_t param) #endif } - lcd_display_bar_int("MW Range", configuration.dexed[instance_id].mw_range, 1.0, MW_RANGE_MIN, MW_RANGE_MAX, 2, false, false, false, false); + lcd_display_bar_int("MW Range", configuration.dexed[selected_instance_id].mw_range, 1.0, MW_RANGE_MIN, MW_RANGE_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setMWController(configuration.dexed[instance_id].mw_range, configuration.dexed[instance_id].mw_assign, configuration.dexed[instance_id].mw_mode); + MicroDexed[selected_instance_id]->setMWController(configuration.dexed[selected_instance_id].mw_range, configuration.dexed[selected_instance_id].mw_assign, configuration.dexed[selected_instance_id].mw_mode); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2590,8 +2462,6 @@ void UI_func_mw_range(uint8_t param) void UI_func_mw_assign(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2600,7 +2470,7 @@ void UI_func_mw_assign(uint8_t param) lcd.print(F("MW Assign")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2613,14 +2483,14 @@ void UI_func_mw_assign(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].mw_assign = constrain(configuration.dexed[instance_id].mw_assign + 1, MW_ASSIGN_MIN, MW_ASSIGN_MAX); + configuration.dexed[selected_instance_id].mw_assign = constrain(configuration.dexed[selected_instance_id].mw_assign + 1, MW_ASSIGN_MIN, MW_ASSIGN_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].mw_assign = constrain(configuration.dexed[instance_id].mw_assign - 1, MW_ASSIGN_MIN, MW_ASSIGN_MAX); + configuration.dexed[selected_instance_id].mw_assign = constrain(configuration.dexed[selected_instance_id].mw_assign - 1, MW_ASSIGN_MIN, MW_ASSIGN_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2629,10 +2499,10 @@ void UI_func_mw_assign(uint8_t param) #endif } - MicroDexed[instance_id]->setMWController(configuration.dexed[instance_id].mw_range, configuration.dexed[instance_id].mw_assign, configuration.dexed[instance_id].mw_mode); + MicroDexed[selected_instance_id]->setMWController(configuration.dexed[selected_instance_id].mw_range, configuration.dexed[selected_instance_id].mw_assign, configuration.dexed[selected_instance_id].mw_mode); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].mw_assign) + switch (configuration.dexed[selected_instance_id].mw_assign) { case 0: lcd.print(F("[ NONE ]")); @@ -2673,8 +2543,6 @@ void UI_func_mw_assign(uint8_t param) void UI_func_mw_mode(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2683,7 +2551,7 @@ void UI_func_mw_mode(uint8_t param) lcd.print(F("MW Mode")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2696,14 +2564,14 @@ void UI_func_mw_mode(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].mw_mode = constrain(configuration.dexed[instance_id].mw_mode + 1, MW_MODE_MIN, MW_MODE_MAX); + configuration.dexed[selected_instance_id].mw_mode = constrain(configuration.dexed[selected_instance_id].mw_mode + 1, MW_MODE_MIN, MW_MODE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].mw_mode = constrain(configuration.dexed[instance_id].mw_mode - 1, MW_MODE_MIN, MW_MODE_MAX); + configuration.dexed[selected_instance_id].mw_mode = constrain(configuration.dexed[selected_instance_id].mw_mode - 1, MW_MODE_MIN, MW_MODE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2712,11 +2580,11 @@ void UI_func_mw_mode(uint8_t param) #endif } - MicroDexed[instance_id]->setMWController(configuration.dexed[instance_id].mw_range, configuration.dexed[instance_id].mw_assign, configuration.dexed[instance_id].mw_mode); - MicroDexed[instance_id]->controllers.refresh(); + MicroDexed[selected_instance_id]->setMWController(configuration.dexed[selected_instance_id].mw_range, configuration.dexed[selected_instance_id].mw_assign, configuration.dexed[selected_instance_id].mw_mode); + MicroDexed[selected_instance_id]->controllers.refresh(); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].mw_mode) + switch (configuration.dexed[selected_instance_id].mw_mode) { case 0: lcd.print(F("[LINEAR ]")); @@ -2742,17 +2610,15 @@ void UI_func_mw_mode(uint8_t param) void UI_func_fc_range(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("FC Range", configuration.dexed[instance_id].fc_range, 1.0, FC_RANGE_MIN, FC_RANGE_MAX, 2, false, false, false, true); + lcd_display_bar_int("FC Range", configuration.dexed[selected_instance_id].fc_range, 1.0, FC_RANGE_MIN, FC_RANGE_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2766,14 +2632,14 @@ void UI_func_fc_range(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].fc_range = constrain(configuration.dexed[instance_id].fc_range + ENCODER[ENC_R].speed(), FC_RANGE_MIN, FC_RANGE_MAX); + configuration.dexed[selected_instance_id].fc_range = constrain(configuration.dexed[selected_instance_id].fc_range + ENCODER[ENC_R].speed(), FC_RANGE_MIN, FC_RANGE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].fc_range = constrain(configuration.dexed[instance_id].fc_range - ENCODER[ENC_R].speed(), FC_RANGE_MIN, FC_RANGE_MAX); + configuration.dexed[selected_instance_id].fc_range = constrain(configuration.dexed[selected_instance_id].fc_range - ENCODER[ENC_R].speed(), FC_RANGE_MIN, FC_RANGE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2782,9 +2648,9 @@ void UI_func_fc_range(uint8_t param) #endif } - lcd_display_bar_int("FC Range", configuration.dexed[instance_id].fc_range, 1.0, FC_RANGE_MIN, FC_RANGE_MAX, 2, false, false, false, false); + lcd_display_bar_int("FC Range", configuration.dexed[selected_instance_id].fc_range, 1.0, FC_RANGE_MIN, FC_RANGE_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setFCController(configuration.dexed[instance_id].fc_range, configuration.dexed[instance_id].fc_assign, configuration.dexed[instance_id].fc_mode); + MicroDexed[selected_instance_id]->setFCController(configuration.dexed[selected_instance_id].fc_range, configuration.dexed[selected_instance_id].fc_assign, configuration.dexed[selected_instance_id].fc_mode); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -2800,8 +2666,6 @@ void UI_func_fc_range(uint8_t param) void UI_func_fc_assign(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2810,7 +2674,7 @@ void UI_func_fc_assign(uint8_t param) lcd.print(F("FC Assign")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2823,14 +2687,14 @@ void UI_func_fc_assign(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].fc_assign = constrain(configuration.dexed[instance_id].fc_assign + 1, FC_ASSIGN_MIN, FC_ASSIGN_MAX); + configuration.dexed[selected_instance_id].fc_assign = constrain(configuration.dexed[selected_instance_id].fc_assign + 1, FC_ASSIGN_MIN, FC_ASSIGN_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].fc_assign = constrain(configuration.dexed[instance_id].fc_assign - 1, FC_ASSIGN_MIN, FC_ASSIGN_MAX); + configuration.dexed[selected_instance_id].fc_assign = constrain(configuration.dexed[selected_instance_id].fc_assign - 1, FC_ASSIGN_MIN, FC_ASSIGN_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2839,10 +2703,10 @@ void UI_func_fc_assign(uint8_t param) #endif } - MicroDexed[instance_id]->setFCController(configuration.dexed[instance_id].fc_range, configuration.dexed[instance_id].fc_assign, configuration.dexed[instance_id].fc_mode); + MicroDexed[selected_instance_id]->setFCController(configuration.dexed[selected_instance_id].fc_range, configuration.dexed[selected_instance_id].fc_assign, configuration.dexed[selected_instance_id].fc_mode); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].fc_assign) + switch (configuration.dexed[selected_instance_id].fc_assign) { case 0: lcd.print(F("[ NONE ]")); @@ -2883,8 +2747,6 @@ void UI_func_fc_assign(uint8_t param) void UI_func_fc_mode(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -2893,7 +2755,7 @@ void UI_func_fc_mode(uint8_t param) lcd.print(F("FC Mode")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2906,14 +2768,14 @@ void UI_func_fc_mode(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].fc_mode = constrain(configuration.dexed[instance_id].fc_mode + 1, FC_MODE_MIN, FC_MODE_MAX); + configuration.dexed[selected_instance_id].fc_mode = constrain(configuration.dexed[selected_instance_id].fc_mode + 1, FC_MODE_MIN, FC_MODE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].fc_mode = constrain(configuration.dexed[instance_id].fc_mode - 1, FC_MODE_MIN, FC_MODE_MAX); + configuration.dexed[selected_instance_id].fc_mode = constrain(configuration.dexed[selected_instance_id].fc_mode - 1, FC_MODE_MIN, FC_MODE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2922,11 +2784,11 @@ void UI_func_fc_mode(uint8_t param) #endif } - MicroDexed[instance_id]->setFCController(configuration.dexed[instance_id].fc_range, configuration.dexed[instance_id].fc_assign, configuration.dexed[instance_id].fc_mode); - MicroDexed[instance_id]->controllers.refresh(); + MicroDexed[selected_instance_id]->setFCController(configuration.dexed[selected_instance_id].fc_range, configuration.dexed[selected_instance_id].fc_assign, configuration.dexed[selected_instance_id].fc_mode); + MicroDexed[selected_instance_id]->controllers.refresh(); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].fc_mode) + switch (configuration.dexed[selected_instance_id].fc_mode) { case 0: lcd.print(F("[LINEAR ]")); @@ -2952,17 +2814,15 @@ void UI_func_fc_mode(uint8_t param) void UI_func_bc_range(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("BC Range", configuration.dexed[instance_id].bc_range, 1.0, BC_RANGE_MIN, BC_RANGE_MAX, 2, false, false, false, true); + lcd_display_bar_int("BC Range", configuration.dexed[selected_instance_id].bc_range, 1.0, BC_RANGE_MIN, BC_RANGE_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2975,14 +2835,14 @@ void UI_func_bc_range(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].bc_range = constrain(configuration.dexed[instance_id].bc_range + ENCODER[ENC_R].speed(), BC_RANGE_MIN, BC_RANGE_MAX); + configuration.dexed[selected_instance_id].bc_range = constrain(configuration.dexed[selected_instance_id].bc_range + ENCODER[ENC_R].speed(), BC_RANGE_MIN, BC_RANGE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].bc_range = constrain(configuration.dexed[instance_id].bc_range - ENCODER[ENC_R].speed(), BC_RANGE_MIN, BC_RANGE_MAX); + configuration.dexed[selected_instance_id].bc_range = constrain(configuration.dexed[selected_instance_id].bc_range - ENCODER[ENC_R].speed(), BC_RANGE_MIN, BC_RANGE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -2991,9 +2851,9 @@ void UI_func_bc_range(uint8_t param) #endif } - lcd_display_bar_int("BC Range", configuration.dexed[instance_id].bc_range, 1.0, BC_RANGE_MIN, BC_RANGE_MAX, 2, false, false, false, false); + lcd_display_bar_int("BC Range", configuration.dexed[selected_instance_id].bc_range, 1.0, BC_RANGE_MIN, BC_RANGE_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setBCController(configuration.dexed[instance_id].bc_range, configuration.dexed[instance_id].bc_assign, configuration.dexed[instance_id].bc_mode); + MicroDexed[selected_instance_id]->setBCController(configuration.dexed[selected_instance_id].bc_range, configuration.dexed[selected_instance_id].bc_assign, configuration.dexed[selected_instance_id].bc_mode); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3009,8 +2869,6 @@ void UI_func_bc_range(uint8_t param) void UI_func_bc_assign(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3019,7 +2877,7 @@ void UI_func_bc_assign(uint8_t param) lcd.print(F("BC Assign")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3032,14 +2890,14 @@ void UI_func_bc_assign(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].bc_assign = constrain(configuration.dexed[instance_id].bc_assign + 1, BC_ASSIGN_MIN, BC_ASSIGN_MAX); + configuration.dexed[selected_instance_id].bc_assign = constrain(configuration.dexed[selected_instance_id].bc_assign + 1, BC_ASSIGN_MIN, BC_ASSIGN_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].bc_assign = constrain(configuration.dexed[instance_id].bc_assign - 1, BC_ASSIGN_MIN, BC_ASSIGN_MAX); + configuration.dexed[selected_instance_id].bc_assign = constrain(configuration.dexed[selected_instance_id].bc_assign - 1, BC_ASSIGN_MIN, BC_ASSIGN_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3048,10 +2906,10 @@ void UI_func_bc_assign(uint8_t param) #endif } - MicroDexed[instance_id]->setBCController(configuration.dexed[instance_id].bc_range, configuration.dexed[instance_id].bc_assign, configuration.dexed[instance_id].bc_mode); + MicroDexed[selected_instance_id]->setBCController(configuration.dexed[selected_instance_id].bc_range, configuration.dexed[selected_instance_id].bc_assign, configuration.dexed[selected_instance_id].bc_mode); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].bc_assign) + switch (configuration.dexed[selected_instance_id].bc_assign) { case 0: lcd.print(F("[ NONE ]")); @@ -3092,8 +2950,6 @@ void UI_func_bc_assign(uint8_t param) void UI_func_bc_mode(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3102,7 +2958,7 @@ void UI_func_bc_mode(uint8_t param) lcd.print(F("BC Mode")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3115,14 +2971,14 @@ void UI_func_bc_mode(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].bc_mode = constrain(configuration.dexed[instance_id].bc_mode + 1, BC_MODE_MIN, BC_MODE_MAX); + configuration.dexed[selected_instance_id].bc_mode = constrain(configuration.dexed[selected_instance_id].bc_mode + 1, BC_MODE_MIN, BC_MODE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].bc_mode = constrain(configuration.dexed[instance_id].bc_mode - 1, BC_MODE_MIN, BC_MODE_MAX); + configuration.dexed[selected_instance_id].bc_mode = constrain(configuration.dexed[selected_instance_id].bc_mode - 1, BC_MODE_MIN, BC_MODE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3131,11 +2987,11 @@ void UI_func_bc_mode(uint8_t param) #endif } - MicroDexed[instance_id]->setBCController(configuration.dexed[instance_id].bc_range, configuration.dexed[instance_id].bc_assign, configuration.dexed[instance_id].bc_mode); - MicroDexed[instance_id]->controllers.refresh(); + MicroDexed[selected_instance_id]->setBCController(configuration.dexed[selected_instance_id].bc_range, configuration.dexed[selected_instance_id].bc_assign, configuration.dexed[selected_instance_id].bc_mode); + MicroDexed[selected_instance_id]->controllers.refresh(); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].bc_mode) + switch (configuration.dexed[selected_instance_id].bc_mode) { case 0: lcd.print(F("[LINEAR ]")); @@ -3161,17 +3017,15 @@ void UI_func_bc_mode(uint8_t param) void UI_func_at_range(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("AT Range", configuration.dexed[instance_id].at_range, 1.0, AT_RANGE_MIN, AT_RANGE_MAX, 2, false, false, false, true); + lcd_display_bar_int("AT Range", configuration.dexed[selected_instance_id].at_range, 1.0, AT_RANGE_MIN, AT_RANGE_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3184,14 +3038,14 @@ void UI_func_at_range(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].at_range = constrain(configuration.dexed[instance_id].at_range + ENCODER[ENC_R].speed(), AT_RANGE_MIN, AT_RANGE_MAX); + configuration.dexed[selected_instance_id].at_range = constrain(configuration.dexed[selected_instance_id].at_range + ENCODER[ENC_R].speed(), AT_RANGE_MIN, AT_RANGE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].at_range = constrain(configuration.dexed[instance_id].at_range - ENCODER[ENC_R].speed(), AT_RANGE_MIN, AT_RANGE_MAX); + configuration.dexed[selected_instance_id].at_range = constrain(configuration.dexed[selected_instance_id].at_range - ENCODER[ENC_R].speed(), AT_RANGE_MIN, AT_RANGE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3200,9 +3054,9 @@ void UI_func_at_range(uint8_t param) #endif } - lcd_display_bar_int("AT Range", configuration.dexed[instance_id].at_range, 1.0, AT_RANGE_MIN, AT_RANGE_MAX, 2, false, false, false, false); + lcd_display_bar_int("AT Range", configuration.dexed[selected_instance_id].at_range, 1.0, AT_RANGE_MIN, AT_RANGE_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setATController(configuration.dexed[instance_id].at_range, configuration.dexed[instance_id].at_assign, configuration.dexed[instance_id].at_mode); + MicroDexed[selected_instance_id]->setATController(configuration.dexed[selected_instance_id].at_range, configuration.dexed[selected_instance_id].at_assign, configuration.dexed[selected_instance_id].at_mode); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3218,8 +3072,6 @@ void UI_func_at_range(uint8_t param) void UI_func_at_assign(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3228,7 +3080,7 @@ void UI_func_at_assign(uint8_t param) lcd.print(F("AT Assign")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3241,14 +3093,14 @@ void UI_func_at_assign(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].at_assign = constrain(configuration.dexed[instance_id].at_assign + 1, AT_ASSIGN_MIN, AT_ASSIGN_MAX); + configuration.dexed[selected_instance_id].at_assign = constrain(configuration.dexed[selected_instance_id].at_assign + 1, AT_ASSIGN_MIN, AT_ASSIGN_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].at_assign = constrain(configuration.dexed[instance_id].at_assign - 1, AT_ASSIGN_MIN, AT_ASSIGN_MAX); + configuration.dexed[selected_instance_id].at_assign = constrain(configuration.dexed[selected_instance_id].at_assign - 1, AT_ASSIGN_MIN, AT_ASSIGN_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3257,10 +3109,10 @@ void UI_func_at_assign(uint8_t param) #endif } - MicroDexed[instance_id]->setATController(configuration.dexed[instance_id].at_range, configuration.dexed[instance_id].at_assign, configuration.dexed[instance_id].at_mode); + MicroDexed[selected_instance_id]->setATController(configuration.dexed[selected_instance_id].at_range, configuration.dexed[selected_instance_id].at_assign, configuration.dexed[selected_instance_id].at_mode); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].at_assign) + switch (configuration.dexed[selected_instance_id].at_assign) { case 0: lcd.print(F("[ NONE ]")); @@ -3301,8 +3153,6 @@ void UI_func_at_assign(uint8_t param) void UI_func_at_mode(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3311,7 +3161,7 @@ void UI_func_at_mode(uint8_t param) lcd.print(F("AT Mode")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3324,14 +3174,14 @@ void UI_func_at_mode(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].at_mode = constrain(configuration.dexed[instance_id].at_mode + 1, AT_MODE_MIN, AT_MODE_MAX); + configuration.dexed[selected_instance_id].at_mode = constrain(configuration.dexed[selected_instance_id].at_mode + 1, AT_MODE_MIN, AT_MODE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].at_mode = constrain(configuration.dexed[instance_id].at_mode - 1, AT_MODE_MIN, AT_MODE_MAX); + configuration.dexed[selected_instance_id].at_mode = constrain(configuration.dexed[selected_instance_id].at_mode - 1, AT_MODE_MIN, AT_MODE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3340,11 +3190,11 @@ void UI_func_at_mode(uint8_t param) #endif } - MicroDexed[instance_id]->setATController(configuration.dexed[instance_id].at_range, configuration.dexed[instance_id].at_assign, configuration.dexed[instance_id].at_mode); - MicroDexed[instance_id]->controllers.refresh(); + MicroDexed[selected_instance_id]->setATController(configuration.dexed[selected_instance_id].at_range, configuration.dexed[selected_instance_id].at_assign, configuration.dexed[selected_instance_id].at_mode); + MicroDexed[selected_instance_id]->controllers.refresh(); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].at_mode) + switch (configuration.dexed[selected_instance_id].at_mode) { case 0: lcd.print(F("[LINEAR ]")); @@ -3370,8 +3220,6 @@ void UI_func_at_mode(uint8_t param) void UI_func_portamento_mode(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3380,7 +3228,7 @@ void UI_func_portamento_mode(uint8_t param) lcd.print(F("Portamento Mode")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3393,14 +3241,14 @@ void UI_func_portamento_mode(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].portamento_mode = constrain(configuration.dexed[instance_id].portamento_mode + 1, PORTAMENTO_MODE_MIN, PORTAMENTO_MODE_MAX); + configuration.dexed[selected_instance_id].portamento_mode = constrain(configuration.dexed[selected_instance_id].portamento_mode + 1, PORTAMENTO_MODE_MIN, PORTAMENTO_MODE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].portamento_mode = constrain(configuration.dexed[instance_id].portamento_mode - 1, PORTAMENTO_MODE_MIN, PORTAMENTO_MODE_MAX); + configuration.dexed[selected_instance_id].portamento_mode = constrain(configuration.dexed[selected_instance_id].portamento_mode - 1, PORTAMENTO_MODE_MIN, PORTAMENTO_MODE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3409,19 +3257,19 @@ void UI_func_portamento_mode(uint8_t param) #endif } - MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); + MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].portamento_mode) + switch (configuration.dexed[selected_instance_id].portamento_mode) { case 0: - if (configuration.dexed[instance_id].monopoly == 1) + if (configuration.dexed[selected_instance_id].monopoly == 1) lcd.print(F("[RETAIN ]")); else lcd.print(F("[FINGERED]")); break; case 1: - if (configuration.dexed[instance_id].monopoly == 1) + if (configuration.dexed[selected_instance_id].monopoly == 1) lcd.print(F("[FOLLOW ]")); else lcd.print(F("[FULL ]")); @@ -3441,8 +3289,6 @@ void UI_func_portamento_mode(uint8_t param) void UI_func_portamento_glissando(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -3451,7 +3297,7 @@ void UI_func_portamento_glissando(uint8_t param) lcd.print(F("Portam. Gliss.")); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3464,14 +3310,14 @@ void UI_func_portamento_glissando(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].portamento_glissando = constrain(configuration.dexed[instance_id].portamento_glissando + 1, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); + configuration.dexed[selected_instance_id].portamento_glissando = constrain(configuration.dexed[selected_instance_id].portamento_glissando + 1, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].portamento_glissando = constrain(configuration.dexed[instance_id].portamento_glissando - 1, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); + configuration.dexed[selected_instance_id].portamento_glissando = constrain(configuration.dexed[selected_instance_id].portamento_glissando - 1, PORTAMENTO_GLISSANDO_MIN, PORTAMENTO_GLISSANDO_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3480,10 +3326,10 @@ void UI_func_portamento_glissando(uint8_t param) #endif } - MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); + MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); lcd.setCursor(0, 1); - switch (configuration.dexed[instance_id].portamento_glissando) + switch (configuration.dexed[selected_instance_id].portamento_glissando) { case 0: lcd.print(F("[OFF]")); @@ -3506,17 +3352,15 @@ void UI_func_portamento_glissando(uint8_t param) void UI_func_portamento_time(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Portam. Time", configuration.dexed[instance_id].portamento_time, 1.0, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX, 2, false, false, false, true); + lcd_display_bar_int("Portam. Time", configuration.dexed[selected_instance_id].portamento_time, 1.0, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX, 2, false, false, false, true); #if NUM_DEXED > 1 - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3529,14 +3373,14 @@ void UI_func_portamento_time(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time + ENCODER[ENC_R].speed(), PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); + configuration.dexed[selected_instance_id].portamento_time = constrain(configuration.dexed[selected_instance_id].portamento_time + ENCODER[ENC_R].speed(), PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time - ENCODER[ENC_R].speed(), PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); + configuration.dexed[selected_instance_id].portamento_time = constrain(configuration.dexed[selected_instance_id].portamento_time - ENCODER[ENC_R].speed(), PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { - instance_id = !instance_id; - lcd_active_instance_number(instance_id); + selected_instance_id = !selected_instance_id; + lcd_active_instance_number(selected_instance_id); lcd.setCursor(15, 0); lcd.write(5); lcd.setCursor(15, 1); @@ -3545,9 +3389,9 @@ void UI_func_portamento_time(uint8_t param) #endif } - lcd_display_bar_int("Portam. Time", configuration.dexed[instance_id].portamento_time, 1.0, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX, 2, false, false, false, false); + lcd_display_bar_int("Portam. Time", configuration.dexed[selected_instance_id].portamento_time, 1.0, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX, 2, false, false, false, false); - MicroDexed[instance_id]->setPortamentoMode(configuration.dexed[instance_id].portamento_mode, configuration.dexed[instance_id].portamento_glissando, configuration.dexed[instance_id].portamento_time); + MicroDexed[selected_instance_id]->setPortamentoMode(configuration.dexed[selected_instance_id].portamento_mode, configuration.dexed[selected_instance_id].portamento_glissando, configuration.dexed[selected_instance_id].portamento_time); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3563,49 +3407,49 @@ void UI_func_portamento_time(uint8_t param) void UI_func_OP1(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 0, instance_id); + UI_handle_OP(param, 0, selected_instance_id); } void UI_func_OP2(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 1, instance_id); + UI_handle_OP(param, 1, selected_instance_id); } void UI_func_OP3(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 2, instance_id); + UI_handle_OP(param, 2, selected_instance_id); } void UI_func_OP4(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 3, instance_id); + UI_handle_OP(param, 3, selected_instance_id); } void UI_func_OP5(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 4, instance_id); + UI_handle_OP(param, 4, selected_instance_id); } void UI_func_OP6(uint8_t param) { - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; - UI_handle_OP(param, 5, instance_id); + UI_handle_OP(param, 5, selected_instance_id); } -void UI_handle_OP(uint8_t param, uint8_t op, uint8_t instance_id) +void UI_handle_OP(uint8_t param, uint8_t op, uint8_t selected_instance_id) { - bool state = bitRead(configuration.dexed[instance_id].op_enabled, op); + bool state = bitRead(configuration.dexed[selected_instance_id].op_enabled, op); if (LCDML.FUNC_setup()) // ****** SETUP ********* { @@ -3629,12 +3473,12 @@ void UI_handle_OP(uint8_t param, uint8_t op, uint8_t instance_id) { if (LCDML.BT_checkUp() && state == true) { - bitClear(configuration.dexed[instance_id].op_enabled, op); + bitClear(configuration.dexed[selected_instance_id].op_enabled, op); state = false; } else if (LCDML.BT_checkDown() && state == false) { - bitSet(configuration.dexed[instance_id].op_enabled, op); + bitSet(configuration.dexed[selected_instance_id].op_enabled, op); state = true; } @@ -3651,14 +3495,14 @@ void UI_handle_OP(uint8_t param, uint8_t op, uint8_t instance_id) } } - MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); - MicroDexed[instance_id]->doRefreshVoice(); + MicroDexed[selected_instance_id]->setOPs(configuration.dexed[selected_instance_id].op_enabled); + MicroDexed[selected_instance_id]->doRefreshVoice(); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { encoderDir[ENC_R].reset(); - if (instance_id == 0) + if (selected_instance_id == 0) EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].op_enabled), configuration.dexed[0].op_enabled); #if NUM_DEXED > 1 else @@ -3736,14 +3580,12 @@ void UI_func_midi_soft_thru(uint8_t param) void UI_func_velocity_level(uint8_t param) { - static uint8_t instance_id; - if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Velocity Lvl", configuration.dexed[instance_id].velocity_level, 1.0, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX, 3, false, false, false, true); + lcd_display_bar_int("Velocity Lvl", configuration.dexed[selected_instance_id].velocity_level, 1.0, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX, 3, false, false, false, true); } if (LCDML.FUNC_loop()) // ****** LOOP ********* @@ -3751,19 +3593,19 @@ void UI_func_velocity_level(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) { if (LCDML.BT_checkDown()) - configuration.dexed[instance_id].velocity_level = constrain(configuration.dexed[instance_id].velocity_level + ENCODER[ENC_R].speed(), VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX); + configuration.dexed[selected_instance_id].velocity_level = constrain(configuration.dexed[selected_instance_id].velocity_level + ENCODER[ENC_R].speed(), VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[instance_id].velocity_level = constrain(configuration.dexed[instance_id].velocity_level - ENCODER[ENC_R].speed(), VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX); + configuration.dexed[selected_instance_id].velocity_level = constrain(configuration.dexed[selected_instance_id].velocity_level - ENCODER[ENC_R].speed(), VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX); } - lcd_display_bar_int("Velocity Lvl", configuration.dexed[instance_id].velocity_level, 1.0, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX, 3, false, false, false, false); + lcd_display_bar_int("Velocity Lvl", configuration.dexed[selected_instance_id].velocity_level, 1.0, VELOCITY_LEVEL_MIN, VELOCITY_LEVEL_MAX, 3, false, false, false, false); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - if (instance_id == 0) + if (selected_instance_id == 0) EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].velocity_level), configuration.dexed[0].velocity_level); #if NUM_DEXED > 1 else @@ -3835,25 +3677,24 @@ void UI_func_eeprom_reset(uint8_t param) void UI_func_voice_select(uint8_t param) { - static uint8_t instance_id; static uint8_t menu_voice_select = MENU_VOICE_SOUND; if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); char bank_name[BANK_NAME_LEN]; char voice_name[VOICE_NAME_LEN]; - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); - if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); - lcd.show(0, 0, 2, configuration.performance.bank[instance_id]); - lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); lcd.show(0, 4, 10, bank_name); lcd.show(1, 4, 10, voice_name); @@ -3896,37 +3737,37 @@ void UI_func_voice_select(uint8_t param) switch (menu_voice_select) { case MENU_VOICE_BANK: - memset(g_bank_name[instance_id], 0, BANK_NAME_LEN); - bank_tmp = constrain(configuration.performance.bank[instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); - configuration.performance.bank[instance_id] = bank_tmp; + memset(g_bank_name[selected_instance_id], 0, BANK_NAME_LEN); + bank_tmp = constrain(configuration.performance.bank[selected_instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); + configuration.performance.bank[selected_instance_id] = bank_tmp; #ifdef DISPLAY_LCD_SPI change_disp_sd(false); #endif - load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + load_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); #ifdef DISPLAY_LCD_SPI change_disp_sd(true); #endif break; case MENU_VOICE_SOUND: - memset(g_voice_name[instance_id], 0, VOICE_NAME_LEN); - voice_tmp = configuration.performance.voice[instance_id] - ENCODER[ENC_R].speed(); - if (voice_tmp < 0 && configuration.performance.bank[instance_id] - 1 >= 0) + memset(g_voice_name[selected_instance_id], 0, VOICE_NAME_LEN); + voice_tmp = configuration.performance.voice[selected_instance_id] - ENCODER[ENC_R].speed(); + if (voice_tmp < 0 && configuration.performance.bank[selected_instance_id] - 1 >= 0) { - configuration.performance.bank[instance_id]--; - configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1); + configuration.performance.bank[selected_instance_id]--; + configuration.performance.bank[selected_instance_id] = constrain(configuration.performance.bank[selected_instance_id], 0, MAX_BANKS - 1); } - else if (voice_tmp < 0 && configuration.performance.bank[instance_id] - 1 <= 0) + else if (voice_tmp < 0 && configuration.performance.bank[selected_instance_id] - 1 <= 0) { voice_tmp = 0; } if (voice_tmp < 0) voice_tmp = MAX_VOICES + voice_tmp; - configuration.performance.voice[instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); + configuration.performance.voice[selected_instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); #ifdef DISPLAY_LCD_SPI change_disp_sd(false); #endif - load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + load_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); #ifdef DISPLAY_LCD_SPI change_disp_sd(true); #endif @@ -3938,36 +3779,36 @@ void UI_func_voice_select(uint8_t param) switch (menu_voice_select) { case MENU_VOICE_BANK: - memset(g_bank_name[instance_id], 0, BANK_NAME_LEN); - bank_tmp = constrain(configuration.performance.bank[instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); - configuration.performance.bank[instance_id] = bank_tmp; + memset(g_bank_name[selected_instance_id], 0, BANK_NAME_LEN); + bank_tmp = constrain(configuration.performance.bank[selected_instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); + configuration.performance.bank[selected_instance_id] = bank_tmp; #ifdef DISPLAY_LCD_SPI change_disp_sd(false); #endif - load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + load_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); #ifdef DISPLAY_LCD_SPI change_disp_sd(true); #endif break; case MENU_VOICE_SOUND: - memset(g_voice_name[instance_id], 0, VOICE_NAME_LEN); - voice_tmp = configuration.performance.voice[instance_id] + ENCODER[ENC_R].speed(); - if (voice_tmp >= MAX_VOICES && configuration.performance.bank[instance_id] + 1 < MAX_BANKS) + memset(g_voice_name[selected_instance_id], 0, VOICE_NAME_LEN); + voice_tmp = configuration.performance.voice[selected_instance_id] + ENCODER[ENC_R].speed(); + if (voice_tmp >= MAX_VOICES && configuration.performance.bank[selected_instance_id] + 1 < MAX_BANKS) { voice_tmp %= MAX_VOICES; - configuration.performance.bank[instance_id]++; - configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id], 0, MAX_BANKS - 1); + configuration.performance.bank[selected_instance_id]++; + configuration.performance.bank[selected_instance_id] = constrain(configuration.performance.bank[selected_instance_id], 0, MAX_BANKS - 1); } - else if (voice_tmp >= MAX_VOICES && configuration.performance.bank[instance_id] + 1 >= MAX_BANKS) + else if (voice_tmp >= MAX_VOICES && configuration.performance.bank[selected_instance_id] + 1 >= MAX_BANKS) { voice_tmp = MAX_VOICES - 1; } - configuration.performance.voice[instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); + configuration.performance.voice[selected_instance_id] = constrain(voice_tmp, 0, MAX_VOICES - 1); #ifdef DISPLAY_LCD_SPI change_disp_sd(false); #endif - load_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + load_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); #ifdef DISPLAY_LCD_SPI change_disp_sd(true); #endif @@ -3988,20 +3829,20 @@ void UI_func_voice_select(uint8_t param) if (menu_voice_select == MENU_VOICE_BANK) { menu_voice_select = MENU_VOICE_SOUND; - instance_id = !instance_id; + selected_instance_id = !selected_instance_id; - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); char bank_name[BANK_NAME_LEN]; char voice_name[VOICE_NAME_LEN]; - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); - if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); - lcd.show(0, 0, 2, configuration.performance.bank[instance_id]); - lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); lcd.show(0, 4, 10, bank_name); lcd.show(1, 4, 10, voice_name); @@ -4016,28 +3857,28 @@ void UI_func_voice_select(uint8_t param) #endif } - if (strlen(g_bank_name[instance_id]) > 0) + if (strlen(g_bank_name[selected_instance_id]) > 0) { - strncpy(bank_name, g_bank_name[instance_id], sizeof(bank_name)); + strncpy(bank_name, g_bank_name[selected_instance_id], sizeof(bank_name)); } else { - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); } - if (strlen(g_voice_name[instance_id]) > 0) + if (strlen(g_voice_name[selected_instance_id]) > 0) { - strncpy(voice_name, g_voice_name[instance_id], sizeof(voice_name)); + strncpy(voice_name, g_voice_name[selected_instance_id], sizeof(voice_name)); } else { - if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); } - lcd.show(0, 0, 2, configuration.performance.bank[instance_id]); - lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(0, 0, 2, configuration.performance.bank[selected_instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); lcd.show(0, 4, 10, bank_name); lcd.show(1, 4, 10, voice_name); @@ -4061,7 +3902,7 @@ void UI_func_voice_select(uint8_t param) if (LCDML.FUNC_close()) // ****** STABLE END ********* { encoderDir[ENC_R].reset(); - if (instance_id == 0) + if (selected_instance_id == 0) { //eeprom_update_var(offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0], "configuration.performance.voice[0]"); //eeprom_update_var(offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0], "configuration.performance.bank[0]"); @@ -4322,9 +4163,9 @@ void UI_func_save_performance(uint8_t param) void UI_func_load_voiceconfig(uint8_t param) { #if NUMDEXED > 1 - static int8_t instance_id; + static int8_t selected_instance_id; #else - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; #endif static uint8_t mode; @@ -4333,7 +4174,7 @@ void UI_func_load_voiceconfig(uint8_t param) { char tmp[10]; - instance_id = 0; + selected_instance_id = 0; encoderDir[ENC_R].reset(); @@ -4346,7 +4187,7 @@ void UI_func_load_voiceconfig(uint8_t param) #else mode = 1; lcd.setCursor(0, 1); - sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[selected_instance_id]); lcd.print(tmp); #endif } @@ -4358,22 +4199,22 @@ void UI_func_load_voiceconfig(uint8_t param) if (LCDML.BT_checkDown()) { if (mode == 0) - instance_id = (instance_id + 1) % 2; + selected_instance_id = (selected_instance_id + 1) % 2; else if (mode == 1) - configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id] + ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); + configuration.performance.voiceconfig_number[selected_instance_id] = constrain(configuration.performance.voiceconfig_number[selected_instance_id] + ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); } else if (LCDML.BT_checkUp()) { if (mode == 0) - instance_id = (instance_id - 1) % 2; + selected_instance_id = (selected_instance_id - 1) % 2; else if (mode == 1) - configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id] - ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); + configuration.performance.voiceconfig_number[selected_instance_id] = constrain(configuration.performance.voiceconfig_number[selected_instance_id] - ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); } else if (LCDML.BT_checkEnter()) { mode = 0xff; lcd.setCursor(0, 1); - if (load_sd_voiceconfig(configuration.performance.voiceconfig_number[instance_id], instance_id) == false) + if (load_sd_voiceconfig(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id) == false) lcd.print("Does not exist. "); else lcd.print("Done. "); @@ -4386,13 +4227,13 @@ void UI_func_load_voiceconfig(uint8_t param) if (mode == 0) { lcd.setCursor(10, 1); - lcd.print(instance_id); + lcd.print(selected_instance_id); } else if (mode == 1) { lcd.setCursor(0, 1); char tmp[10]; - sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[selected_instance_id]); lcd.print(tmp); } } @@ -4407,10 +4248,10 @@ void UI_func_load_voiceconfig(uint8_t param) delay(MESSAGE_WAIT_TIME); } else - eeprom_update_dexed(instance_id); + eeprom_update_dexed(selected_instance_id); #if NUM_DEXED > 1 - if (instance_id > 0) + if (selected_instance_id > 0) EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]); else #endif @@ -4423,9 +4264,9 @@ void UI_func_load_voiceconfig(uint8_t param) void UI_func_save_voiceconfig(uint8_t param) { #if NUMDEXED > 1 - static int8_t instance_id; + static int8_t selected_instance_id; #else - uint8_t instance_id = 0; + uint8_t selected_instance_id = 0; #endif static bool overwrite; @@ -4437,7 +4278,7 @@ void UI_func_save_voiceconfig(uint8_t param) char tmp[FILENAME_LEN]; yesno = false; - instance_id = 0; + selected_instance_id = 0; encoderDir[ENC_R].reset(); @@ -4450,10 +4291,10 @@ void UI_func_save_voiceconfig(uint8_t param) #else mode = 1; lcd.setCursor(0, 1); - sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[selected_instance_id]); lcd.print(tmp); - sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[selected_instance_id]); if (SD.exists(tmp)) overwrite = true; else @@ -4468,18 +4309,18 @@ void UI_func_save_voiceconfig(uint8_t param) if (LCDML.BT_checkDown()) { if (mode == 0) - instance_id = (instance_id + 1) % 2; + selected_instance_id = (selected_instance_id + 1) % 2; else if (mode == 1) - configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id] + ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); + configuration.performance.voiceconfig_number[selected_instance_id] = constrain(configuration.performance.voiceconfig_number[selected_instance_id] + ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); else yesno = true; } else if (LCDML.BT_checkUp()) { if (mode == 0) - instance_id = (instance_id - 1) % 2; + selected_instance_id = (selected_instance_id - 1) % 2; else if (mode == 1) - configuration.performance.voiceconfig_number[instance_id] = constrain(configuration.performance.voiceconfig_number[instance_id] - ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); + configuration.performance.voiceconfig_number[selected_instance_id] = constrain(configuration.performance.voiceconfig_number[selected_instance_id] - ENCODER[ENC_L].speed(), VOICECONFIG_NUM_MIN, VOICECONFIG_NUM_MAX); else yesno = false; } @@ -4499,10 +4340,10 @@ void UI_func_save_voiceconfig(uint8_t param) if (yesno == true) { char tmp[FILENAME_LEN]; - sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[selected_instance_id]); SD.remove(tmp); } - save_sd_voiceconfig(configuration.performance.voiceconfig_number[instance_id], instance_id); + save_sd_voiceconfig(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id); lcd.show(1, 0, 16, "Done."); delay(MESSAGE_WAIT_TIME); LCDML.FUNC_goBackToMenu(); @@ -4513,7 +4354,7 @@ void UI_func_save_voiceconfig(uint8_t param) mode = 1; lcd.setCursor(0, 1); - sprintf(tmp, "[%2d] ", configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "[%2d] ", configuration.performance.voiceconfig_number[selected_instance_id]); lcd.print(tmp); } } @@ -4522,20 +4363,20 @@ void UI_func_save_voiceconfig(uint8_t param) if (mode == 0) { lcd.setCursor(10, 1); - lcd.print(configuration.performance.voiceconfig_number[instance_id]); + lcd.print(configuration.performance.voiceconfig_number[selected_instance_id]); } else if (mode == 1) { char tmp[FILENAME_LEN]; - sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[selected_instance_id]); if (SD.exists(tmp)) overwrite = true; else overwrite = false; lcd.setCursor(0, 1); - sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[instance_id]); + sprintf(tmp, "[%2d]", configuration.performance.voiceconfig_number[selected_instance_id]); lcd.print(tmp); } else if (mode == 2) @@ -4559,7 +4400,7 @@ void UI_func_save_voiceconfig(uint8_t param) } #if NUM_DEXED > 1 - if (instance_id > 0) + if (selected_instance_id > 0) EEPROM.update(EEPROM_START_ADDRESS + offsetof(performance_s, voiceconfig_number[1]), configuration.performance.voiceconfig_number[1]); else #endif @@ -4764,7 +4605,6 @@ void UI_func_save_voice(uint8_t param) { static bool yesno; static uint8_t mode; - static uint8_t instance_id; if (LCDML.FUNC_setup()) // ****** SETUP ********* { @@ -4776,24 +4616,23 @@ void UI_func_save_voice(uint8_t param) #else mode = 0; #endif - instance_id = 0; #if NUM_DEXED == 1 char bank_name[BANK_NAME_LEN]; - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); lcd.setCursor(0, 0); lcd.print(F("Save to Bank")); - lcd.show(1, 0, 2, configuration.performance.bank[instance_id]); + lcd.show(1, 0, 2, configuration.performance.bank[selected_instance_id]); lcd.show(1, 4, 10, bank_name); lcd.show(1, 2, 2, " ["); lcd.show(1, 14, 1, "]"); #else lcd.setCursor(0, 0); lcd.print(F("Save Instance")); - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(5, 1); lcd.write(5); lcd.setCursor(10, 1); @@ -4812,9 +4651,9 @@ void UI_func_save_voice(uint8_t param) { case 0: // Instance selection if (LCDML.BT_checkDown() || LCDML.BT_checkUp()) - instance_id = !instance_id; + selected_instance_id = !selected_instance_id; - lcd_active_instance_number(instance_id); + lcd_active_instance_number(selected_instance_id); lcd.setCursor(5, 1); lcd.write(5); lcd.setCursor(10, 1); @@ -4822,28 +4661,28 @@ void UI_func_save_voice(uint8_t param) break; case 1: // Bank selection if (LCDML.BT_checkDown()) - configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); - else if (LCDML.BT_checkUp() && configuration.performance.bank[instance_id] > 0) - configuration.performance.bank[instance_id] = constrain(configuration.performance.bank[instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); + configuration.performance.bank[selected_instance_id] = constrain(configuration.performance.bank[selected_instance_id] + ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); + else if (LCDML.BT_checkUp() && configuration.performance.bank[selected_instance_id] > 0) + configuration.performance.bank[selected_instance_id] = constrain(configuration.performance.bank[selected_instance_id] - ENCODER[ENC_R].speed(), 0, MAX_BANKS - 1); - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); - lcd.show(1, 0, 2, configuration.performance.bank[instance_id]); + lcd.show(1, 0, 2, configuration.performance.bank[selected_instance_id]); lcd.show(1, 4, 10, bank_name); break; case 2: // Voice selection - if (LCDML.BT_checkDown() && configuration.performance.voice[instance_id] < MAX_VOICES - 1) - configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id] + ENCODER[ENC_R].speed(), 0, MAX_VOICES - 1); - else if (LCDML.BT_checkUp() && configuration.performance.voice[instance_id] > 0) - configuration.performance.voice[instance_id] = constrain(configuration.performance.voice[instance_id] - ENCODER[ENC_R].speed(), 0, MAX_VOICES - 1); + if (LCDML.BT_checkDown() && configuration.performance.voice[selected_instance_id] < MAX_VOICES - 1) + configuration.performance.voice[selected_instance_id] = constrain(configuration.performance.voice[selected_instance_id] + ENCODER[ENC_R].speed(), 0, MAX_VOICES - 1); + else if (LCDML.BT_checkUp() && configuration.performance.voice[selected_instance_id] > 0) + configuration.performance.voice[selected_instance_id] = constrain(configuration.performance.voice[selected_instance_id] - ENCODER[ENC_R].speed(), 0, MAX_VOICES - 1); - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); - if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); - lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); lcd.show(1, 4, 10, voice_name); break; case 3: // Yes/No selection @@ -4866,24 +4705,24 @@ void UI_func_save_voice(uint8_t param) switch (mode) { case 1: - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); lcd.setCursor(0, 0); lcd.print(F("Save to Bank")); - lcd.show(1, 0, 2, configuration.performance.bank[instance_id]); + lcd.show(1, 0, 2, configuration.performance.bank[selected_instance_id]); lcd.show(1, 4, 10, bank_name); lcd.show(1, 2, 2, " ["); lcd.show(1, 14, 1, "]"); break; case 2: - if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) + if (!get_bank_name(configuration.performance.bank[selected_instance_id], bank_name, sizeof(bank_name))) strncpy(bank_name, "*ERROR*", sizeof(bank_name)); - if (!get_voice_by_bank_name(configuration.performance.bank[instance_id], bank_name, configuration.performance.voice[instance_id], voice_name, sizeof(voice_name))) + if (!get_voice_by_bank_name(configuration.performance.bank[selected_instance_id], bank_name, configuration.performance.voice[selected_instance_id], voice_name, sizeof(voice_name))) strncpy(voice_name, "*ERROR*", sizeof(voice_name)); lcd.show(0, 0, 16, "Save to Bank"); - lcd.show(0, 13, 2, configuration.performance.bank[instance_id]); - lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); + lcd.show(0, 13, 2, configuration.performance.bank[selected_instance_id]); + lcd.show(1, 0, 2, configuration.performance.voice[selected_instance_id] + 1); lcd.show(1, 4, 10, voice_name); break; case 3: @@ -4895,14 +4734,14 @@ void UI_func_save_voice(uint8_t param) if (yesno == true) { #ifdef DEBUG - bool ret = save_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + bool ret = save_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); if (ret == true) Serial.println(F("Saving voice OK.")); else Serial.println(F("Error while saving voice.")); #else - save_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); + save_sd_voice(configuration.performance.bank[selected_instance_id], configuration.performance.voice[selected_instance_id], selected_instance_id); #endif lcd.show(1, 0, 16, "Done."); @@ -4926,7 +4765,7 @@ void UI_func_save_voice(uint8_t param) } else { - if (instance_id == 0) + if (selected_instance_id == 0) { EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0]); EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0]);