Added functionality for asking for storing when drum midi notes are

changed.
dev
Holger Wirtz 2 years ago
parent c407ee8194
commit 30624db43b
  1. 51
      UI.hpp

@ -4376,13 +4376,18 @@ void UI_func_drum_midi_note(uint8_t param) {
} }
#else #else
static bool display_name; static bool display_name;
static bool store_flag; static uint8_t midinote_old[NUM_DRUMSET_CONFIG];
static int8_t ask_before_quit_mode;
char tmp_val[4]; char tmp_val[4];
char tmp_name[9]; char tmp_name[9];
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
store_flag = false; ask_before_quit_mode = -1;
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
midinote_old[i] = configuration.drums.midinote[i];
if (!display_name) if (!display_name)
midi_learn_mode = MIDI_LEARN_MODE_NOTE; midi_learn_mode = MIDI_LEARN_MODE_NOTE;
@ -4400,16 +4405,21 @@ void UI_func_drum_midi_note(uint8_t param) {
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
{ {
if (ask_before_quit == true) { if (ask_before_quit == true && ask_before_quit_mode == false) {
if (store_flag == true) { uint8_t num_changes = 0;
display.show(0, 0, LCD_cols, "Store changes?");
display.show(1, 0, LCD_cols, "[NO] YES"); for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) {
delay(1000); if (midinote_old[i] != configuration.drums.midinote[i])
num_changes++;
} }
if (num_changes > 0) {
display.show(0, 0, LCD_cols, "Store changes?");
display.show(1, 0, LCD_cols, " NO YES [BACK]");
ask_before_quit_mode = 0;
} else {
ask_before_quit = false; ask_before_quit = false;
LCDML.FUNC_goBackToMenu(); LCDML.FUNC_goBackToMenu();
/*LCDML.BT_quit(); }
LCDML.OTHER_updateFunc();*/
} }
if (midi_learn_mode >= DRUMS_MIDI_NOTE_MIN) if (midi_learn_mode >= DRUMS_MIDI_NOTE_MIN)
@ -4420,20 +4430,37 @@ void UI_func_drum_midi_note(uint8_t param) {
if (display_name == true) { if (display_name == true) {
if (active_sample < NUM_DRUMSET_CONFIG - 2) if (active_sample < NUM_DRUMSET_CONFIG - 2)
active_sample++; active_sample++;
} else if (ask_before_quit_mode >= 0) {
++ask_before_quit_mode %= 3;
// TODO: Display selection is missing
} else { } else {
configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] + ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); 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()) { } else if (LCDML.BT_checkUp()) {
if (display_name == true) { if (display_name == true) {
if (active_sample > 0) if (active_sample > 0)
active_sample--; active_sample--;
} else if (ask_before_quit_mode >= 0) {
--ask_before_quit_mode %= 3;
// TODO: Display selection is missing
} else { } else {
configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] - ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); 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()) { } else if (LCDML.BT_checkEnter()) {
display_name = !display_name; if (ask_before_quit_mode >= 0) {
if (ask_before_quit_mode == 0) { //NO
ask_before_quit = false;
LCDML.FUNC_goBackToMenu();
} else if (ask_before_quit_mode == 1) { // YES
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++)
configuration.drums.midinote[i] = midinote_old[i];
} else if (ask_before_quit_mode == 2) { // BACK
ask_before_quit_mode = -1;
ask_before_quit = false;
LCDML.OTHER_updateFunc(); // TODO: Is this the right function for going back?
}
} else display_name = !display_name;
} }
} }

Loading…
Cancel
Save