diff --git a/MicroDexed.ino b/MicroDexed.ino index 26f6d82..4a94879 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -418,7 +418,7 @@ void setup() sgtl5000.enable(); sgtl5000.lineOutLevel(SGTL5000_LINEOUT_LEVEL); sgtl5000.dacVolumeRamp(); - //sgtl5000.dacVolume(1.0); // doing this at the end of setup() + sgtl5000.dacVolume(1.0); //sgtl5000.dacVolumeRampLinear(); //sgtl5000.dacVolumeRampDisable(); sgtl5000.unmuteHeadphone(); @@ -645,10 +645,6 @@ void setup() strcpy(seq_name, "INIT Perf"); LCDML.OTHER_jumpToFunc(UI_func_voice_select); - -#if defined(TEENSY_AUDIO_BOARD) - sgtl5000.dacVolume(1.0); -#endif } void loop() @@ -1930,15 +1926,31 @@ void initial_values(bool init) } else { - uint8_t eeprom_performance = EEPROM[EEPROM_START_ADDRESS + 2]; - + load_sd_sys_json(); + if (configuration.sys.load_at_startup == 255) + { #ifdef DEBUG - Serial.print(F("Loading initial system data from performance ")); - Serial.println(eeprom_performance, DEC); + Serial.print(F("Loading initial system data from performance ")); + Serial.println(configuration.sys.performance_number, DEC); #endif - - load_sd_performance_json(eeprom_performance); - load_sd_sys_json(); + load_sd_performance_json(configuration.sys.performance_number); + } + else if (configuration.sys.load_at_startup < 100) + { +#ifdef DEBUG + Serial.print(F("Loading initial system data from performance ")); + Serial.println(configuration.sys.load_at_startup, DEC); +#endif + load_sd_performance_json(configuration.sys.load_at_startup); + } + else + { +#ifdef DEBUG + Serial.print(F("Loading initial system data from default performance ")); + Serial.println(STARTUP_NUM_DEFAULT, DEC); +#endif + load_sd_performance_json(STARTUP_NUM_DEFAULT); + } } #ifdef DEBUG Serial.println(F("OK, loaded!")); @@ -1946,7 +1958,7 @@ void initial_values(bool init) check_configuration(); } - configuration.sys.vol = EEPROM[EEPROM_START_ADDRESS + 3]; + configuration.sys.vol = EEPROM[EEPROM_START_ADDRESS + 2]; set_volume(configuration.sys.vol, configuration.sys.mono); #ifdef DEBUG @@ -1970,6 +1982,7 @@ void check_configuration_sys(void) configuration.sys.soft_midi_thru = constrain(configuration.sys.soft_midi_thru, SOFT_MIDI_THRU_MIN, SOFT_MIDI_THRU_MAX); configuration.sys.favorites = constrain(configuration.sys.favorites, FAVORITES_NUM_MIN, FAVORITES_NUM_MAX); configuration.sys.performance_number = constrain(configuration.sys.performance_number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); + configuration.sys.load_at_startup = constrain(configuration.sys.load_at_startup, STARTUP_NUM_MIN, STARTUP_NUM_MAX); } void check_configuration_fx(void) @@ -2065,6 +2078,7 @@ void init_configuration(void) configuration.sys.mono = MONO_DEFAULT; configuration.sys.soft_midi_thru = SOFT_MIDI_THRU_DEFAULT; configuration.sys.performance_number = PERFORMANCE_NUM_DEFAULT; + configuration.sys.load_at_startup = STARTUP_NUM_DEFAULT; #ifdef USE_PLATEREVERB configuration.fx.reverb_lowpass = REVERB_LOWPASS_DEFAULT; @@ -2145,8 +2159,7 @@ void eeprom_update(void) { EEPROM.update(EEPROM_START_ADDRESS, (EEPROM_MARKER & 0xff00) >> 8); EEPROM.update(EEPROM_START_ADDRESS + 1, EEPROM_MARKER & 0xff); - EEPROM.update(EEPROM_START_ADDRESS + 2, configuration.sys.performance_number); - EEPROM.update(EEPROM_START_ADDRESS + 3, configuration.sys.vol); + EEPROM.update(EEPROM_START_ADDRESS + 2, configuration.sys.vol); } /****************************************************************************** @@ -2777,6 +2790,7 @@ void show_configuration(void) Serial.print(F(" Soft MIDI Thru ")); Serial.println(configuration.sys.soft_midi_thru, DEC); Serial.print(F(" Favorites ")); Serial.println(configuration.sys.favorites, DEC); Serial.print(F(" Performance Number ")); Serial.println(configuration.sys.performance_number, DEC); + Serial.print(F(" Load at startup ")); Serial.println(configuration.sys.load_at_startup, DEC); Serial.println(F("FX")); Serial.print(F(" Reverb Roomsize ")); Serial.println(configuration.fx.reverb_roomsize, DEC); Serial.print(F(" Reverb Level ")); Serial.println(configuration.fx.reverb_level, DEC); diff --git a/UI.hpp b/UI.hpp index 3a5fc76..ed9f63c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -333,6 +333,7 @@ void UI_func_eq_4(uint8_t param); void UI_func_eq_5(uint8_t param); void UI_func_eq_6(uint8_t param); void UI_func_eq_7(uint8_t param); +void UI_func_startup(uint8_t param); void UI_function_not_enabled(void); void UI_function_not_implemented(uint8_t param); void UI_func_favorites(uint8_t param); @@ -6275,7 +6276,11 @@ void UI_func_load_performance(uint8_t param) delay(MESSAGE_WAIT_TIME); } else + { + configuration.sys.performance_number = temp_int; + save_sd_sys_json(); encoderDir[ENC_R].reset(); + } } } @@ -6350,7 +6355,6 @@ void UI_func_save_performance(uint8_t param) sprintf(tmp, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, temp_int, PERFORMANCE_CONFIG_NAME); SD.remove(tmp); } - save_sd_performance_json(temp_int); lcd.show(1, 0, 16, "Done."); seq_state_last_loadsave = temp_int; delay(MESSAGE_WAIT_TIME); @@ -8055,6 +8059,67 @@ void UI_func_eq_7(uint8_t param) #endif } +void UI_func_startup(uint8_t param) +{ + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + encoderDir[ENC_R].reset(); + lcd.setCursor(0, 0); + lcd.print(F("Load at startup")); + lcd.setCursor(0, 1); + if (configuration.sys.load_at_startup == 255) + lcd.print(F("Last Perf. ")); + else if (configuration.sys.load_at_startup < 100) + { + lcd.print(F("Fixed Perf. ")); + lcd.print(configuration.sys.load_at_startup); + } + } + + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up())) + { + if (LCDML.BT_checkDown()) + { + if (configuration.sys.load_at_startup == 255) + configuration.sys.load_at_startup = PERFORMANCE_NUM_MIN; + else if (configuration.sys.load_at_startup >= 0 && configuration.sys.load_at_startup <= PERFORMANCE_NUM_MAX) + configuration.sys.load_at_startup++; + if (configuration.sys.load_at_startup > PERFORMANCE_NUM_MAX) + configuration.sys.load_at_startup = 255; + } + else if (LCDML.BT_checkUp()) + { + if (configuration.sys.load_at_startup == 255) + configuration.sys.load_at_startup = PERFORMANCE_NUM_MAX; + else if (configuration.sys.load_at_startup >= PERFORMANCE_NUM_MIN && configuration.sys.load_at_startup <= PERFORMANCE_NUM_MAX) + configuration.sys.load_at_startup--; + } + } + + lcd.setCursor(0, 1); + if (configuration.sys.load_at_startup == 255) + lcd.print(F("Last Perf. ")); + else if (configuration.sys.load_at_startup < 100) + { + lcd.print(F("Fixed Perf. ")); + lcd.setCursor(12, 1); + lcd.print(configuration.sys.load_at_startup); + } + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + //lcd_special_chars(SCROLLBAR); + save_sd_sys_json(); + if (configuration.sys.load_at_startup < 100 && configuration.sys.load_at_startup != configuration.sys.performance_number) + load_sd_performance_json(configuration.sys.load_at_startup); + + encoderDir[ENC_R].reset(); + } +} + void UI_function_not_enabled(void) { if (LCDML.FUNC_setup()) // ****** SETUP ********* diff --git a/UI_FX.h b/UI_FX.h index 2dc45ea..3f1466c 100644 --- a/UI_FX.h +++ b/UI_FX.h @@ -132,7 +132,8 @@ LCDML_add(98, LCDML_0, 6, "System", NULL); LCDML_add(99, LCDML_0_6, 1, "Stereo/Mono", UI_func_stereo_mono); LCDML_add(100, LCDML_0_6, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); LCDML_add(101, LCDML_0_6, 3, "Favorites", UI_func_favorites); -LCDML_add(102, LCDML_0, 7, "Info", UI_func_information); -LCDML_addAdvanced(103, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 103 +LCDML_add(102, LCDML_0_6, 4, "Startup", UI_func_startup); +LCDML_add(103, LCDML_0, 7, "Info", UI_func_information); +LCDML_addAdvanced(104, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 104 #endif diff --git a/UI_FX_T4.h b/UI_FX_T4.h index 91fde8e..4f33fcc 100644 --- a/UI_FX_T4.h +++ b/UI_FX_T4.h @@ -140,7 +140,8 @@ LCDML_add(106, LCDML_0, 5, "System", NULL); LCDML_add(107, LCDML_0_5, 1, "Stereo/Mono", UI_func_stereo_mono); LCDML_add(108, LCDML_0_5, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); LCDML_add(109, LCDML_0_5, 3, "Favorites", UI_func_favorites); -LCDML_add(110, LCDML_0, 6, "Info", UI_func_information); -LCDML_addAdvanced(111, LCDML_0, 7, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 111 +LCDML_add(110, LCDML_0_5, 4, "Startup", UI_func_startup); +LCDML_add(111, LCDML_0, 6, "Info", UI_func_information); +LCDML_addAdvanced(112, LCDML_0, 7, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 112 #endif diff --git a/UI_NO_FX.h b/UI_NO_FX.h index 9daeaaa..25f9adc 100644 --- a/UI_NO_FX.h +++ b/UI_NO_FX.h @@ -77,7 +77,7 @@ LCDML_add(43, LCDML_0_1, 8, "Save Voice", UI_func_save_voice); LCDML_add(44, LCDML_0, 2, "Load/Save", NULL); LCDML_add(45, LCDML_0_2, 1, "Load Perf.", UI_func_load_performance); LCDML_add(46, LCDML_0_2, 2, "Save Perf.", UI_func_save_performance); -LCDML_add(47, LCDML_0_2, 3, "Name Perf.", UI_func_set_performance_name); +LCDML_add(47, LCDML_0_2, 3, "Name Perf.", UI_func_set_performance_name); LCDML_add(48, LCDML_0_2, 4, "MIDI", NULL); LCDML_add(49, LCDML_0_2_4, 1, "MIDI Recv Bank", UI_func_sysex_receive_bank); LCDML_add(50, LCDML_0_2_4, 2, "MIDI Snd Bank", UI_func_sysex_send_bank); @@ -106,7 +106,8 @@ LCDML_add(72, LCDML_0, 5, "System", NULL); LCDML_add(73, LCDML_0_5, 1, "Stereo/Mono", UI_func_stereo_mono); LCDML_add(74, LCDML_0_5, 2, "MIDI Soft THRU", UI_func_midi_soft_thru); LCDML_add(75, LCDML_0_5, 3, "Favorites", UI_func_favorites); -LCDML_add(76, LCDML_0, 6, "Info", UI_func_information); -LCDML_addAdvanced(77, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); -#define _LCDML_DISP_cnt 77 +LCDML_add(76, LCDML_0_5, 4, "Startup", UI_func_startup); +LCDML_add(77, LCDML_0, 6, "Info", UI_func_information); +LCDML_addAdvanced(78, LCDML_0, 8, COND_hide, "Volume", UI_func_volume, 0, _LCDML_TYPE_default); +#define _LCDML_DISP_cnt 78 #endif diff --git a/config.h b/config.h index eb29dc3..84690d9 100644 --- a/config.h +++ b/config.h @@ -333,7 +333,7 @@ #define SAVE_SYS_MS 5000 #define VOL_MAX_FLOAT 0.95 -#define EEPROM_MARKER 0x4242 +#define EEPROM_MARKER 0x4243 #ifndef NUM_DRUMS #define NUM_DRUMS 0 @@ -676,7 +676,11 @@ #define FAVORITES_NUM_MAX 100 #define FAVORITES_NUM_DEFAULT 0 -#define VOLUME_MULTIPLIER 1.3 +#define STARTUP_NUM_MIN 0 +#define STARTUP_NUM_MAX 255 +#define STARTUP_NUM_DEFAULT 0 + +#define VOLUME_MULTIPLIER 1.4 // Buffer-size define for load/save configuration as JSON #define JSON_BUFFER_SIZE 8192 @@ -755,6 +759,7 @@ typedef struct sys_s { uint8_t soft_midi_thru; uint8_t performance_number; uint8_t favorites; + uint8_t load_at_startup; } sys_t; typedef struct configuration_s { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 85d84c8..3fd9ba0 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -999,9 +999,10 @@ bool load_sd_sys_json(void) configuration.sys.soft_midi_thru = data_json["soft_midi_thru"]; configuration.sys.performance_number = data_json["performance_number"]; configuration.sys.favorites = data_json["favorites"]; + configuration.sys.load_at_startup = data_json["load_at_startup"]; check_configuration_sys(); - //set_sys_params(); //TODO + set_sys_params(); return (true); } @@ -1052,6 +1053,7 @@ bool save_sd_sys_json(void) data_json["soft_midi_thru"] = configuration.sys.soft_midi_thru; data_json["performance_number"] = configuration.sys.performance_number; data_json["favorites"] = configuration.sys.favorites; + data_json["load_at_startup"] = configuration.sys.load_at_startup; #ifdef DEBUG Serial.println(F("Write JSON data:"));