Added "Overwrite?" screen for storing new sounds.

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

@ -169,8 +169,8 @@ void setup()
// create EPiano object // create EPiano object
ep = new mdaEPiano(); ep = new mdaEPiano();
initial_values_from_eeprom();
set_complete_configuration(); set_complete_configuration();
initial_values_from_eeprom();
setup_midi_devices(); setup_midi_devices();
@ -480,11 +480,9 @@ void config_from_eeprom(void)
} }
else else
#ifdef DEBUG #ifdef DEBUG
{
Serial.println(F(" - mismatch (or force) -> nothing done!")); Serial.println(F(" - mismatch (or force) -> nothing done!"));
#endif }
#ifdef DEBUG
Serial.println();
show_sound(); show_sound();
#endif #endif
} }
@ -523,6 +521,7 @@ void initial_values_from_eeprom(void)
Serial.println(master_volume, DEC); Serial.println(master_volume, DEC);
Serial.print(F("Max configs in EEPROM: ")); Serial.print(F("Max configs in EEPROM: "));
Serial.println(MAX_SOUNDS); Serial.println(MAX_SOUNDS);
show_sound();
#endif #endif
} }
@ -614,71 +613,71 @@ void show_sound(void)
Serial.println(sound, DEC); Serial.println(sound, DEC);
Serial.print(F("Checksum: 0x")); Serial.print(F("Checksum: 0x"));
Serial.println(configuration.checksum, HEX); Serial.println(configuration.checksum, HEX);
Serial.print(F("Decay:")); Serial.print(F("Decay: "));
Serial.println(configuration.decay, DEC); Serial.println(configuration.decay, DEC);
Serial.print(F("Release:")); Serial.print(F("Release: "));
Serial.println(configuration.release, DEC); Serial.println(configuration.release, DEC);
Serial.print(F("Hardness:")); Serial.print(F("Hardness: "));
Serial.println(configuration.hardness, DEC); Serial.println(configuration.hardness, DEC);
Serial.print(F("Treble:")); Serial.print(F("Treble: "));
Serial.println(configuration.treble, DEC); Serial.println(configuration.treble, DEC);
Serial.print(F("Stereo:")); Serial.print(F("Stereo: "));
Serial.println(configuration.stereo, DEC); Serial.println(configuration.stereo, DEC);
Serial.print(F("Transpose:")); Serial.print(F("Transpose: "));
Serial.println(configuration.transpose, DEC); Serial.println(configuration.transpose, DEC);
Serial.print(F("Tune:")); Serial.print(F("Tune: "));
Serial.println(configuration.tune, DEC); Serial.println(configuration.tune, DEC);
Serial.print(F("Detune:")); Serial.print(F("Detune: "));
Serial.println(configuration.detune, DEC); Serial.println(configuration.detune, DEC);
Serial.print(F("Velocity Sense:")); Serial.print(F("Velocity Sense: "));
Serial.println(configuration.velocity_sense, DEC); Serial.println(configuration.velocity_sense, DEC);
Serial.print(F("Pan Tremolo Frequency:")); Serial.print(F("Pan Tremolo Frequency: "));
Serial.println(configuration.pan_trem_frequency, DEC); Serial.println(configuration.pan_trem_frequency, DEC);
Serial.print(F("Pan Tremolo Level:")); Serial.print(F("Pan Tremolo Level: "));
Serial.println(configuration.pan_trem_level, DEC); Serial.println(configuration.pan_trem_level, DEC);
Serial.print(F("Ovedrive:")); Serial.print(F("Ovedrive: "));
Serial.println(configuration.overdrive, DEC); Serial.println(configuration.overdrive, DEC);
Serial.print(F("Compressor Gain:")); Serial.print(F("Compressor Gain: "));
Serial.println(configuration.comp_gain, DEC); Serial.println(configuration.comp_gain, DEC);
Serial.print(F("Compressor Respone:")); Serial.print(F("Compressor Respone: "));
Serial.println(configuration.comp_response, DEC); Serial.println(configuration.comp_response, DEC);
Serial.print(F("Compressor Limit:")); Serial.print(F("Compressor Limit: "));
Serial.println(configuration.comp_limit, DEC); Serial.println(configuration.comp_limit, DEC);
Serial.print(F("Compressor Threshold:")); Serial.print(F("Compressor Threshold: "));
Serial.println(configuration.comp_threshold, DEC); Serial.println(configuration.comp_threshold, DEC);
Serial.print(F("Compressor Attack:")); Serial.print(F("Compressor Attack: "));
Serial.println(configuration.comp_attack, DEC); Serial.println(configuration.comp_attack, DEC);
Serial.print(F("Compressor Decay:")); Serial.print(F("Compressor Decay: "));
Serial.println(configuration.comp_decay, DEC); Serial.println(configuration.comp_decay, DEC);
Serial.print(F("Reverb Roomsize:")); Serial.print(F("Reverb Roomsize: "));
Serial.println(configuration.reverb_roomsize, DEC); Serial.println(configuration.reverb_roomsize, DEC);
Serial.print(F("Reverb Damping:")); Serial.print(F("Reverb Damping: "));
Serial.println(configuration.reverb_damping, DEC); Serial.println(configuration.reverb_damping, DEC);
Serial.print(F("Reverb Level:")); Serial.print(F("Reverb Level: "));
Serial.println(configuration.reverb_level, DEC); Serial.println(configuration.reverb_level, DEC);
Serial.print(F("CHorus Frequency:")); Serial.print(F("CHorus Frequency: "));
Serial.println(configuration.chorus_frequency, DEC); Serial.println(configuration.chorus_frequency, DEC);
Serial.print(F("Chorus Delay:")); Serial.print(F("Chorus Delay: "));
Serial.println(configuration.chorus_delay, DEC); Serial.println(configuration.chorus_delay, DEC);
Serial.print(F("Chorus Level:")); Serial.print(F("Chorus Level: "));
Serial.println(configuration.chorus_level, DEC); Serial.println(configuration.chorus_level, DEC);
Serial.print(F("Bass L/R Level:")); Serial.print(F("Bass L/R Level: "));
Serial.println(configuration.bass_lr_level, DEC); Serial.println(configuration.bass_lr_level, DEC);
Serial.print(F("Bass Mono Level:")); Serial.print(F("Bass Mono Level: "));
Serial.println(configuration.bass_mono_level, DEC); Serial.println(configuration.bass_mono_level, DEC);
Serial.print(F("EQ Bass:")); Serial.print(F("EQ Bass: "));
Serial.println(configuration.eq_bass, DEC); Serial.println(configuration.eq_bass, DEC);
Serial.print(F("EQ Treble:")); Serial.print(F("EQ Treble: "));
Serial.println(configuration.eq_treble, DEC); Serial.println(configuration.eq_treble, DEC);
Serial.print(F("Loudness:")); Serial.print(F("Loudness: "));
Serial.println(configuration.loudness, DEC); Serial.println(configuration.loudness, DEC);
Serial.print(F("MIDI Channel:")); Serial.print(F("MIDI Channel: "));
Serial.println(configuration.midi_channel, DEC); Serial.println(configuration.midi_channel, DEC);
Serial.print(F("MIDI Soft-Thru:")); Serial.print(F("MIDI Soft-Thru: "));
Serial.println(configuration.midi_soft_thru, DEC); Serial.println(configuration.midi_soft_thru, DEC);
Serial.print(F("Maximum Polyphony:")); Serial.print(F("Maximum Polyphony: "));
Serial.println(configuration.max_poly, DEC); Serial.println(configuration.max_poly, DEC);
Serial.print(F("Panorama:")); Serial.print(F("Panorama: "));
Serial.println(configuration.pan, DEC); Serial.println(configuration.pan, DEC);
} }
#endif #endif

128
UI.hpp

@ -8,7 +8,7 @@
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5 const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
/// Configures the number of available functions per line. /// 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. /// Configures the number of available lines per screen.
const uint8_t MAX_LINES = 19; ///< @note Default: 12 const uint8_t MAX_LINES = 19; ///< @note Default: 12
@ -17,7 +17,7 @@
const uint8_t MAX_SCREENS = 14; ///< @note Default: 14 const uint8_t MAX_SCREENS = 14; ///< @note Default: 14
/// Configures the number of available menus per menus system. /// 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)}; Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)};
elapsedMillis back_to_main; elapsedMillis back_to_main;
#define NUM_MENUS 40 #define NUM_MENUS 41
#define MAIN 0 #define MAIN 0
/*************************************/ /*************************************/
@ -82,9 +82,13 @@ elapsedMillis back_to_main;
#define MIDI_SOFT_THRU 37 #define MIDI_SOFT_THRU 37
#define MAX_POLY 38 #define MAX_POLY 38
/*************************************/ /*************************************/
#define MASTER_VOLUME 39 #define STORE_QUESTION 39
/*************************************/
#define MASTER_VOLUME 40
/*************************************/
int8_t menu_position[NUM_MENUS]; int8_t menu_position[NUM_MENUS];
bool yes_no = false;
#define LEFT_ENCODER 0 #define LEFT_ENCODER 0
#define RIGHT_ENCODER 1 #define RIGHT_ENCODER 1
@ -221,6 +225,17 @@ char* get_midi_soft_thru_value_text(void)
return (midi_soft_thru_value_text1); 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 MAIN MENU
******************************************/ ******************************************/
@ -610,7 +625,7 @@ LiquidMenu eq_treble_menu(lcd);
/****************************************** /******************************************
SAVE SOUND MENU SAVE SOUND MENU
******************************************/ ******************************************/
#define NUM_SAVE_SOUNDS_MENUS 1 #define NUM_SAVE_SOUNDS_MENUS 2
const char save_sound_text1[] PROGMEM = "Save Sound"; const char save_sound_text1[] PROGMEM = "Save Sound";
LiquidLine save_sound_line1(1, 0, save_sound_text1); LiquidLine save_sound_line1(1, 0, save_sound_text1);
LiquidLine save_sound_line2(1, 1, sound); LiquidLine save_sound_line2(1, 1, sound);
@ -692,6 +707,15 @@ LiquidLine master_volume_line2(1, 1, master_volume);
LiquidScreen master_volume_screen; LiquidScreen master_volume_screen;
LiquidMenu master_volume_menu(lcd); 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 GLOBAL MENU OBJECTS
******************************************/ ******************************************/
@ -717,7 +741,8 @@ void callback_load_sound_function(void) {
void callback_edit_sound_function(void) void callback_edit_sound_function(void)
{ {
#ifdef DEBUG #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 #endif
menu_system.change_menu(edit_sound_menu); menu_system.change_menu(edit_sound_menu);
menu_system.set_focusPosition(Position::LEFT); menu_system.set_focusPosition(Position::LEFT);
@ -836,7 +861,7 @@ void callback_detune_function(void)
void callback_velocity_sense_function(void) void callback_velocity_sense_function(void)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("callback_velocity_sense_function")); Serial.print(F("callback_velocity_sense_function"));
#endif #endif
menu_system.change_menu(velocity_sense_menu); menu_system.change_menu(velocity_sense_menu);
menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER]; menu_position[EDIT_SOUND] = encoder_value[RIGHT_ENCODER];
@ -851,7 +876,7 @@ void callback_velocity_sense_function(void)
void callback_effect_function(void) void callback_effect_function(void)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("callback_effect_function, focus position: ")); Serial.print(F("callback_effect_function, focus position:"));
Serial.println(menu_position[EFFECTS]); Serial.println(menu_position[EFFECTS]);
#endif #endif
menu_system.change_menu(effects_menu); menu_system.change_menu(effects_menu);
@ -1021,17 +1046,11 @@ void callback_chorus_frequency_function(void)
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("callback_chorus_frequency_function")); Serial.println(F("callback_chorus_frequency_function"));
#endif #endif
Serial.println("0");
menu_system.change_menu(chorus_frequency_menu); menu_system.change_menu(chorus_frequency_menu);
Serial.println("1");
menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER];
Serial.println("2");
encoder_value[RIGHT_ENCODER] = configuration.chorus_frequency; 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); enc[RIGHT_ENCODER].write(configuration.chorus_frequency, ENC_CHORUS_FREQUENCY_MIN, ENC_CHORUS_FREQUENCY_MAX);
Serial.println("4");
menu_system.update(); menu_system.update();
Serial.println("5");
} }
void callback_chorus_delay_function(void) void callback_chorus_delay_function(void)
@ -1121,13 +1140,25 @@ void callback_save_sound_function(void)
menu_system.update(); 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 SYSTEM MENU CALLBACKS
******************************************/ ******************************************/
void callback_system_function(void) void callback_system_function(void)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("callback_system_function")); Serial.print(F("callback_system_function, focus position:"));
Serial.println(menu_position[SYSTEM]);
#endif #endif
menu_system.change_menu(system_menu); menu_system.change_menu(system_menu);
menu_system.set_focusPosition(Position::LEFT); 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); 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 INIT MENU FUNCTION
******************************************/ ******************************************/
@ -1552,6 +1592,14 @@ void init_menus(void)
save_sound_screen.set_displayLineCount(2); save_sound_screen.set_displayLineCount(2);
save_sound_menu.add_screen(save_sound_screen); 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 // setup effects menu
system_screen.add_line(system_line1); system_screen.add_line(system_line1);
system_screen.add_line(system_line2); 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_bass_menu);
menu_system.add_menu(eq_treble_menu); menu_system.add_menu(eq_treble_menu);
menu_system.add_menu(save_sound_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(system_menu);
menu_system.add_menu(loudness_menu); menu_system.add_menu(loudness_menu);
menu_system.add_menu(midi_channel_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(max_poly_menu);
menu_system.add_menu(info_menu); menu_system.add_menu(info_menu);
menu_system.add_menu(master_volume_menu); menu_system.add_menu(master_volume_menu);
menu_system.set_focusPosition(Position::LEFT); menu_system.set_focusPosition(Position::LEFT);
menu_system.switch_focus(); menu_system.switch_focus();
menu_system.update(); menu_system.update();
@ -1676,6 +1726,7 @@ void save_sound(void)
Serial.println(sound); Serial.println(sound);
#endif #endif
eeprom_config_write(sound); eeprom_config_write(sound);
yes_no = false;
} }
void set_decay(uint8_t value) 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) void set_bass_mono_level(uint8_t value)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Set BASS_MONO_LEVEL ")); Serial.print(F("Set BASS_MONO_LEVEL "));
Serial.println(value); Serial.println(value);
@ -2104,7 +2154,7 @@ void handle_ui(void)
if (encoder_tmp != encoder_value[RIGHT_ENCODER]) if (encoder_tmp != encoder_value[RIGHT_ENCODER])
{ {
// value up/down // value up/down
sound=encoder_tmp; sound = encoder_tmp;
menu_system.update(); menu_system.update();
} }
} }
@ -2365,7 +2415,16 @@ void handle_ui(void)
if (encoder_tmp != encoder_value[RIGHT_ENCODER]) if (encoder_tmp != encoder_value[RIGHT_ENCODER])
{ {
// value up/down // value up/down
sound=encoder_tmp; sound = encoder_tmp;
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(); menu_system.update();
} }
} }
@ -2449,12 +2508,29 @@ void handle_ui(void)
} }
else if (menu_system.get_currentScreen() == &save_sound_screen) else if (menu_system.get_currentScreen() == &save_sound_screen)
{ {
// save sound // ask for storing sound
#ifdef DEBUG #ifdef DEBUG
Serial.print("Save sound "); Serial.print("Storing sound?");
Serial.println(); Serial.println();
#endif #endif
save_sound(); 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 else
{ {
@ -2466,9 +2542,10 @@ void handle_ui(void)
menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS; menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS;
else if (menu_system.get_currentScreen() == &system_screen) else if (menu_system.get_currentScreen() == &system_screen)
menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS + NUM_EFFECTS_MENUS; menu_callback_offset = NUM_MAIN_MENUS + NUM_EDIT_SOUND_MENUS + NUM_EFFECTS_MENUS;
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Starting callback number ")); 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(F("encoder_value[RIGHT_ENCODER]="));
Serial.print(encoder_value[RIGHT_ENCODER], DEC); Serial.print(encoder_value[RIGHT_ENCODER], DEC);
Serial.print(F(" menu_callback_offset=")); Serial.print(F(" menu_callback_offset="));
@ -2754,6 +2831,13 @@ void handle_ui(void)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("from save_sound to main")); 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 #endif
goto_main_menu(SAVE_SOUND); goto_main_menu(SAVE_SOUND);
} }

Loading…
Cancel
Save