|
|
|
@ -4108,50 +4108,148 @@ void UI_func_save_fx(uint8_t param) |
|
|
|
|
void UI_func_save_voice(uint8_t param) |
|
|
|
|
{ |
|
|
|
|
static bool yesno; |
|
|
|
|
static uint8_t mode; |
|
|
|
|
|
|
|
|
|
uint8_t instance_id = 0; |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_setup()) // ****** SETUP *********
|
|
|
|
|
{ |
|
|
|
|
encoderDir[ENC_R].reset(); |
|
|
|
|
|
|
|
|
|
yesno = false; |
|
|
|
|
mode = 0; |
|
|
|
|
|
|
|
|
|
char bank_name[BANK_NAME_LEN]; |
|
|
|
|
|
|
|
|
|
if (!get_bank_name(configuration.performance.bank[instance_id], bank_name, sizeof(bank_name))) |
|
|
|
|
strncpy(bank_name, "*ERROR*", sizeof(bank_name)); |
|
|
|
|
|
|
|
|
|
lcd.setCursor(0, 0); |
|
|
|
|
lcd.print(F("Save Voice")); |
|
|
|
|
lcd.setCursor(0, 1); |
|
|
|
|
lcd.print(F("[NO ]")); |
|
|
|
|
lcd.print(F("Save to Bank")); |
|
|
|
|
lcd.show(1, 0, 2, configuration.performance.bank[instance_id]); |
|
|
|
|
lcd.show(1, 4, 10, bank_name); |
|
|
|
|
lcd.show(1, 2, 2, " ["); |
|
|
|
|
lcd.show(1, 14, 1, "]"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_loop()) // ****** LOOP *********
|
|
|
|
|
{ |
|
|
|
|
if ((LCDML.BT_checkDown() || LCDML.BT_checkUp())) |
|
|
|
|
char bank_name[BANK_NAME_LEN]; |
|
|
|
|
char voice_name[VOICE_NAME_LEN]; |
|
|
|
|
|
|
|
|
|
if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) |
|
|
|
|
{ |
|
|
|
|
switch (mode) |
|
|
|
|
{ |
|
|
|
|
case 0: // 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); |
|
|
|
|
|
|
|
|
|
if (!get_bank_name(configuration.performance.bank[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, 4, 10, bank_name); |
|
|
|
|
break; |
|
|
|
|
case 1: // 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 (!get_bank_name(configuration.performance.bank[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))) |
|
|
|
|
strncpy(voice_name, "*ERROR*", sizeof(voice_name)); |
|
|
|
|
|
|
|
|
|
lcd.show(1, 0, 2, configuration.performance.voice[instance_id] + 1); |
|
|
|
|
lcd.show(1, 4, 10, voice_name); |
|
|
|
|
break; |
|
|
|
|
case 2: // Yes/No selection
|
|
|
|
|
yesno = !yesno; |
|
|
|
|
if (yesno == true) |
|
|
|
|
{ |
|
|
|
|
lcd.setCursor(1, 1); |
|
|
|
|
lcd.print(F("YES")); |
|
|
|
|
lcd.show(1, 1, 3, "YES"); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
lcd.setCursor(1, 1); |
|
|
|
|
lcd.print(F("NO ")); |
|
|
|
|
lcd.show(1, 1, 3, "NO"); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (LCDML.BT_checkEnter()) |
|
|
|
|
{ |
|
|
|
|
if (encoderDir[ENC_R].ButtonShort()) |
|
|
|
|
mode++; |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_close()) // ****** STABLE END *********
|
|
|
|
|
if (mode == 1) |
|
|
|
|
{ |
|
|
|
|
if (!get_bank_name(configuration.performance.bank[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))) |
|
|
|
|
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(1, 4, 10, voice_name); |
|
|
|
|
} |
|
|
|
|
if (mode == 2) |
|
|
|
|
{ |
|
|
|
|
lcd.show(0, 0, 16, "Overwrite?"); |
|
|
|
|
lcd.show(1, 0, 15, "[NO"); |
|
|
|
|
lcd.show(1, 4, 1, "]"); |
|
|
|
|
} |
|
|
|
|
else if (mode > 2) |
|
|
|
|
{ |
|
|
|
|
if (yesno == true) |
|
|
|
|
{ |
|
|
|
|
LCDML.DISP_clear(); |
|
|
|
|
lcd.print(F("Save Cfg default")); |
|
|
|
|
bool ret = save_sd_voice(configuration.performance.bank[instance_id], configuration.performance.voice[instance_id], instance_id); |
|
|
|
|
|
|
|
|
|
// Storing on inside bank TBD
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
if (ret == true) |
|
|
|
|
Serial.println(F("Saving voice OK.")); |
|
|
|
|
else |
|
|
|
|
Serial.println(F("Error while saving voice.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
lcd.setCursor(0, 1); |
|
|
|
|
lcd.print(F("Done. ")); |
|
|
|
|
lcd.show(1, 0, 16, "Done."); |
|
|
|
|
delay(500); |
|
|
|
|
|
|
|
|
|
mode = 0xff; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
encoderDir[ENC_R].reset(); |
|
|
|
|
LCDML.FUNC_goBackToMenu(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (LCDML.FUNC_close()) // ****** STABLE END *********
|
|
|
|
|
{ |
|
|
|
|
if (mode < 0xff) |
|
|
|
|
{ |
|
|
|
|
lcd.show(1, 0, 16, "Canceled."); |
|
|
|
|
delay(500); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (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]); |
|
|
|
|
} |
|
|
|
|
#if NUM_DEXED > 1 |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[1]); |
|
|
|
|
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[1]); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
encoderDir[ENC_R].reset(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|