Added "Overwrite?" screen for storing new sounds.

master
Holger Wirtz 6 years ago
parent 0d92b1af0a
commit 99bdb53a6f
  1. 9
      MicroMDAEPiano.ino
  2. 120
      UI.hpp

@ -169,8 +169,8 @@ void setup()
// create EPiano object
ep = new mdaEPiano();
initial_values_from_eeprom();
set_complete_configuration();
initial_values_from_eeprom();
setup_midi_devices();
@ -480,11 +480,9 @@ void config_from_eeprom(void)
}
else
#ifdef DEBUG
{
Serial.println(F(" - mismatch (or force) -> nothing done!"));
#endif
#ifdef DEBUG
Serial.println();
}
show_sound();
#endif
}
@ -523,6 +521,7 @@ void initial_values_from_eeprom(void)
Serial.println(master_volume, DEC);
Serial.print(F("Max configs in EEPROM: "));
Serial.println(MAX_SOUNDS);
show_sound();
#endif
}

120
UI.hpp

@ -8,7 +8,7 @@
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
/// Configures the number of available functions per line.
const uint8_t MAX_FUNCTIONS = 39; ///< @note Default: 8
const uint8_t MAX_FUNCTIONS = 42; ///< @note Default: 8
/// Configures the number of available lines per screen.
const uint8_t MAX_LINES = 19; ///< @note Default: 12
@ -17,7 +17,7 @@
const uint8_t MAX_SCREENS = 14; ///< @note Default: 14
/// Configures the number of available menus per menus system.
const uint8_t MAX_MENUS = 40; ///< @note Default: 8
const uint8_t MAX_MENUS = 41; ///< @note Default: 8
*/
@ -36,7 +36,7 @@ int32_t encoder_value[NUM_ENCODER];
Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
elapsedMillis back_to_main;
#define NUM_MENUS 40
#define NUM_MENUS 41
#define MAIN 0
/*************************************/
@ -82,9 +82,13 @@ elapsedMillis back_to_main;
#define MIDI_SOFT_THRU 37
#define MAX_POLY 38
/*************************************/
#define MASTER_VOLUME 39
#define STORE_QUESTION 39
/*************************************/
#define MASTER_VOLUME 40
/*************************************/
int8_t menu_position[NUM_MENUS];
bool yes_no = false;
#define LEFT_ENCODER 0
#define RIGHT_ENCODER 1
@ -221,6 +225,17 @@ char* get_midi_soft_thru_value_text(void)
return (midi_soft_thru_value_text1);
}
char yes_no_value_text1[] = " ";
char* get_yes_no_value_text(void)
{
if (yes_no == false)
sprintf(yes_no_value_text1, "No ");
else
sprintf(yes_no_value_text1, "Yes");
return (yes_no_value_text1);
}
/******************************************
MAIN MENU
******************************************/
@ -610,7 +625,7 @@ LiquidMenu eq_treble_menu(lcd);
/******************************************
SAVE SOUND MENU
******************************************/
#define NUM_SAVE_SOUNDS_MENUS 1
#define NUM_SAVE_SOUNDS_MENUS 2
const char save_sound_text1[] PROGMEM = "Save Sound";
LiquidLine save_sound_line1(1, 0, save_sound_text1);
LiquidLine save_sound_line2(1, 1, sound);
@ -692,6 +707,15 @@ LiquidLine master_volume_line2(1, 1, master_volume);
LiquidScreen master_volume_screen;
LiquidMenu master_volume_menu(lcd);
/******************************************
STORE_QUESTION DISPLAY
******************************************/
const char store_question_text1[] PROGMEM = "Overwrite?";
LiquidLine store_question_line1(1, 0, store_question_text1);
LiquidLine store_question_line2(1, 1, get_yes_no_value_text);
LiquidScreen store_question_screen;
LiquidMenu store_question_menu(lcd);
/******************************************
GLOBAL MENU OBJECTS
******************************************/
@ -717,7 +741,8 @@ void callback_load_sound_function(void) {
void callback_edit_sound_function(void)
{
#ifdef DEBUG
Serial.println(F("callback_edit_sound_function"));
Serial.print(F("callback_edit_sound_function, focus position:"));
Serial.println(menu_position[EDIT_SOUND], DEC);
#endif
menu_system.change_menu(edit_sound_menu);
menu_system.set_focusPosition(Position::LEFT);
@ -836,7 +861,7 @@ void callback_detune_function(void)
void callback_velocity_sense_function(void)
{
#ifdef DEBUG
Serial.println(F("callback_velocity_sense_function"));
Serial.print(F("callback_velocity_sense_function"));
#endif
menu_system.change_menu(velocity_sense_menu);
menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
@ -1021,17 +1046,11 @@ void callback_chorus_frequency_function(void)
#ifdef DEBUG
Serial.println(F("callback_chorus_frequency_function"));
#endif
Serial.println("0");
menu_system.change_menu(chorus_frequency_menu);
Serial.println("1");
menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
Serial.println("2");
encoder_value[RIGHT_ENCODER] = configuration.chorus_frequency;
Serial.println("3");
enc[RIGHT_ENCODER].write(configuration.chorus_frequency, ENC_CHORUS_FREQUENCY_MIN, ENC_CHORUS_FREQUENCY_MAX);
Serial.println("4");
menu_system.update();
Serial.println("5");
}
void callback_chorus_delay_function(void)
@ -1121,13 +1140,25 @@ void callback_save_sound_function(void)
menu_system.update();
}
void callback_store_question_function(void)
{
#ifdef DEBUG
Serial.println(F("callback_store_question_function"));
#endif
menu_system.change_menu(store_question_menu);
//menu_position[MAIN] = encoder_value[RIGHT_ENCODER];
encoder_value[RIGHT_ENCODER] = yes_no;
enc[RIGHT_ENCODER].write(yes_no, 0, 1);
menu_system.update();
}
/******************************************
SYSTEM MENU CALLBACKS
******************************************/
void callback_system_function(void)
{
#ifdef DEBUG
Serial.println(F("callback_system_function"));
Serial.print(F("callback_system_function, focus position:"));
Serial.println(menu_position[SYSTEM]);
#endif
menu_system.change_menu(system_menu);
menu_system.set_focusPosition(Position::LEFT);
@ -1270,6 +1301,15 @@ void goto_system_menu(uint8_t menu_number)
enc[RIGHT_ENCODER].write(menu_position[SYSTEM], 0, NUM_SYSTEM_MENUS - 1);
}
void goto_store_question_menu(uint8_t menu_number)
{
menu_position[menu_number] = enc[RIGHT_ENCODER].read();
menu_system.change_menu(store_question_menu);
menu_system.set_focusPosition(Position::LEFT);
//encoder_value[RIGHT_ENCODER] = menu_position[STORE_QUESTION];
enc[RIGHT_ENCODER].write(menu_position[STORE_QUESTION], 0, 1);
}
/******************************************
INIT MENU FUNCTION
******************************************/
@ -1552,6 +1592,14 @@ void init_menus(void)
save_sound_screen.set_displayLineCount(2);
save_sound_menu.add_screen(save_sound_screen);
// setup store_question display
store_question_line1.attach_function(STORE_QUESTION, callback_store_question_function);
store_question_screen.add_line(store_question_line1);
store_question_screen.add_line(store_question_line2);
store_question_screen.set_displayLineCount(2);
store_question_menu.add_screen(store_question_screen);
// setup effects menu
system_screen.add_line(system_line1);
system_screen.add_line(system_line2);
@ -1636,6 +1684,7 @@ void init_menus(void)
menu_system.add_menu(eq_bass_menu);
menu_system.add_menu(eq_treble_menu);
menu_system.add_menu(save_sound_menu);
menu_system.add_menu(store_question_menu);
menu_system.add_menu(system_menu);
menu_system.add_menu(loudness_menu);
menu_system.add_menu(midi_channel_menu);
@ -1643,6 +1692,7 @@ void init_menus(void)
menu_system.add_menu(max_poly_menu);
menu_system.add_menu(info_menu);
menu_system.add_menu(master_volume_menu);
menu_system.set_focusPosition(Position::LEFT);
menu_system.switch_focus();
menu_system.update();
@ -1676,6 +1726,7 @@ void save_sound(void)
Serial.println(sound);
#endif
eeprom_config_write(sound);
yes_no = false;
}
void set_decay(uint8_t value)
@ -1962,7 +2013,6 @@ void set_bass_lr_level(uint8_t value)
void set_bass_mono_level(uint8_t value)
{
#ifdef DEBUG
Serial.print(F("Set BASS_MONO_LEVEL "));
Serial.println(value);
@ -2369,6 +2419,15 @@ void handle_ui(void)
menu_system.update();
}
}
else if (menu_system.get_currentScreen() == &store_question_screen)
{
if (encoder_tmp != encoder_value[RIGHT_ENCODER])
{
// value up/down
yes_no = encoder_tmp;
menu_system.update();
}
}
else if (menu_system.get_currentScreen() == &loudness_screen)
{
if (encoder_tmp != encoder_value[RIGHT_ENCODER])
@ -2449,13 +2508,30 @@ void handle_ui(void)
}
else if (menu_system.get_currentScreen() == &save_sound_screen)
{
// save sound
// ask for storing sound
#ifdef DEBUG
Serial.print("Save sound ");
Serial.print("Storing sound?");
Serial.println();
#endif
goto_store_question_menu(SAVE_SOUND);
}
else if (menu_system.get_currentScreen() == &store_question_screen)
{
// save sound
if (encoder_tmp == 1)
{
#ifdef DEBUG
Serial.print(F("Save sound "));
Serial.println(sound, DEC);
#endif
save_sound();
}
#ifdef DEBUG
else
Serial.println(F("Not saving sound!"));
#endif
goto_main_menu(SAVE_SOUND);
}
else
{
uint8_t menu_callback_offset = 0;
@ -2466,9 +2542,10 @@ void handle_ui(void)
menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS;
else if (menu_system.get_currentScreen() == &system_screen)
menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS + NUM_EFFECTS_MENUS;
#ifdef DEBUG
Serial.print(F("Starting callback number "));
Serial.println(encoder_value[RIGHT_ENCODER] + 1 + menu_callback_offset, DEC);
Serial.println(encoder_value[RIGHT_ENCODER] + menu_callback_offset, DEC);
Serial.print(F("encoder_value[RIGHT_ENCODER]="));
Serial.print(encoder_value[RIGHT_ENCODER], DEC);
Serial.print(F(" menu_callback_offset="));
@ -2754,6 +2831,13 @@ void handle_ui(void)
{
#ifdef DEBUG
Serial.println(F("from save_sound to main"));
#endif
goto_main_menu(SAVE_SOUND);
}
else if (menu_system.get_currentScreen() == &store_question_screen) // store_question menu
{
#ifdef DEBUG
Serial.println(F("from store_question to main"));
#endif
goto_main_menu(SAVE_SOUND);
}

Loading…
Cancel
Save