diff --git a/UI.hpp b/UI.hpp index b673ece..496201f 100644 --- a/UI.hpp +++ b/UI.hpp @@ -145,6 +145,7 @@ uint8_t orig_attack_values[2][7]; uint8_t orig_release_values[2][7]; int temp_int; float temp_float; +bool ask_before_quit = false; #ifdef I2C_DISPLAY #include @@ -743,6 +744,11 @@ void lcdml_menu_control(void) { LCDML.OTHER_jumpToID(LCDML.MENU_getLastActiveFunctionID()); else LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID()); + } else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_drum_midi_note) && ask_before_quit == false) { + ask_before_quit = true; + encoderDir[ENC_L].reset(); + encoderDir[ENC_R].reset(); + LCDML.OTHER_updateFunc(); } else LCDML.BT_quit(); } @@ -4394,6 +4400,18 @@ void UI_func_drum_midi_note(uint8_t param) { if (LCDML.FUNC_loop()) // ****** LOOP ********* { + if (ask_before_quit == true) { + if (store_flag == true) { + display.show(0, 0, LCD_cols, "Store changes?"); + display.show(1, 0, LCD_cols, "[NO] YES"); + delay(1000); + } + ask_before_quit = false; + LCDML.FUNC_goBackToMenu(); + /*LCDML.BT_quit(); + LCDML.OTHER_updateFunc();*/ + } + if (midi_learn_mode >= DRUMS_MIDI_NOTE_MIN) configuration.drums.midinote[active_sample] = midi_learn_mode; @@ -4402,17 +4420,17 @@ void UI_func_drum_midi_note(uint8_t param) { if (display_name == true) { if (active_sample < NUM_DRUMSET_CONFIG - 2) active_sample++; - store_flag = true; } else { configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] + ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); + store_flag = true; } } else if (LCDML.BT_checkUp()) { if (display_name == true) { if (active_sample > 0) active_sample--; - store_flag = true; } else { configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] - ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); + store_flag = true; } } else if (LCDML.BT_checkEnter()) { display_name = !display_name; @@ -4438,10 +4456,6 @@ void UI_func_drum_midi_note(uint8_t param) { if (LCDML.FUNC_close()) // ****** STABLE END ********* { - if (store_flag == true) { - display.show(0, 0, LCD_cols, "Store changes?"); - display.show(1, 0, LCD_cols, "[NO] YES"); - } encoderDir[ENC_L].reset(); midi_learn_mode = MIDI_LEARN_MODE_OFF; } @@ -6792,4 +6806,4 @@ void save_favorite(uint8_t b, uint8_t v, uint8_t instance_id) { char* basename(const char* filename) { char* p = strrchr(filename, '/'); return p ? p + 1 : (char*)filename; -} \ No newline at end of file +}