From 40c124db0bf73b8bf346851f6e93fe2828bc11e9 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 23 Dec 2022 08:33:15 +0100 Subject: [PATCH] Added LED blinking for showing that the system is not blocking. Added UI for drum midinote - but there's still work to do. --- MicroDexed.ino | 11 +++++++ UI.hpp | 82 +++++++++++++++++++++++++++++++++++++++++++------- config.h | 1 + 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 8306fd5..d50ddc0 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -354,7 +354,9 @@ int16_t _midi_bpm = -1; elapsedMillis midi_bpm_timer; elapsedMillis long_button_pressed; elapsedMillis control_rate; +elapsedMillis led_blink; elapsedMillis save_sys; +bool led_status = false; bool save_sys_flag = false; uint8_t active_voices[NUM_DEXED]; uint8_t midi_voices[NUM_DEXED]; @@ -444,6 +446,8 @@ void setup() { setup_debug_message(); #endif + pinMode(LED_BUILTIN, OUTPUT); + generate_version_string(version_string, sizeof(version_string)); #ifdef DEBUG @@ -853,6 +857,13 @@ void loop() { show_cpu_and_mem_usage(); } #endif + + // LED blink + if (led_blink > LED_BLINK_MS) { + digitalWrite(LED_BUILTIN, led_status); + led_status = !led_status; + led_blink = 0; + } } /****************************************************************************** diff --git a/UI.hpp b/UI.hpp index a84426f..89e1f09 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4295,20 +4295,80 @@ void UI_func_drum_reverb_send(uint8_t param) { } } -bool _get_midi_note(uint8_t note) { - for (uint8_t i = DRUMS_MIDI_NOTE_MIN; i <= DRUMS_MIDI_NOTE_MAX; i++) { - if (drum_config[activesample].midinote == i) - return (true); +void UI_func_drum_midi_note(uint8_t param) { + static bool display_name; + char tmp_val[4]; + char tmp_name[9]; + + if (LCDML.FUNC_setup()) // ****** SETUP ********* + { + midi_learn_mode = true; + + memset(tmp_name, ' ', 8); + strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name)); + tmp_name[8] = '\0'; + + display.setCursor(0, 0); + display.print(F("MIDI Note")); + display.setCursor(1, 1); + display.print(tmp_name); + display.setCursor(LCD_cols - 4, 1); + getNoteName(tmp_val, configuration.drums.midinote[active_sample]); + display.print(tmp_val); + _check_display_name(display_name, 3); } - return (false); -} -void _UI_func_drum_midi_note_display(bool mode) { - ; -} + if (LCDML.FUNC_loop()) // ****** LOOP ********* + { + if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { + if (LCDML.BT_checkDown()) { + if (display_name == true) { + if (active_sample < NUM_DRUMSET_CONFIG - 2) { + active_sample++; + display.setCursor(LCD_cols - 4, 1); + getNoteName(tmp_val, configuration.drums.midinote[active_sample]); + display.print(tmp_val); + } + } else { + configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] + ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); + } + } else if (LCDML.BT_checkUp()) { + if (display_name == true) { + if (active_sample > 0) { + active_sample--; + display.setCursor(LCD_cols - 4, 1); + getNoteName(tmp_val, configuration.drums.midinote[active_sample]); + display.print(tmp_val); + } + } else { + configuration.drums.midinote[active_sample] = constrain(configuration.drums.midinote[active_sample] - ENCODER[ENC_L].speed(), DRUMS_MIDI_NOTE_MIN, DRUMS_MIDI_NOTE_MAX); + } + } else if (LCDML.BT_checkEnter()) { + display_name = !display_name; + } + } -void UI_func_drum_midi_note(uint8_t param) { - ; + getNoteName(tmp_val, configuration.drums.midinote[active_sample]); +#ifdef DEBUG + Serial.printf("Drum midinote for active_sample=%d [%s]=%d (%s)\n", active_sample, drum_config[active_sample].name, configuration.drums.midinote[active_sample], tmp_val); +#endif + memset(tmp_name, ' ', 8); + strncpy(tmp_name, drum_config[active_sample].name, strlen(drum_config[active_sample].name)); + tmp_name[8] = '\0'; + + display.setCursor(1, 1); + display.print(tmp_name); + display.setCursor(LCD_cols - 4, 1); + display.print(tmp_val); + + _check_display_name(display_name, 3); + } + + if (LCDML.FUNC_close()) // ****** STABLE END ********* + { + encoderDir[ENC_L].reset(); + midi_learn_mode = false; + } } void UI_func_save_performance(uint8_t param) { diff --git a/config.h b/config.h index 5fd27f9..fcb9a56 100644 --- a/config.h +++ b/config.h @@ -345,6 +345,7 @@ //************************************************************************************************* #define MAX_DEXED 2 // No! - even don't think about increasing this number! IT _WILL_ PRODUCE MASSIVE PROBLEMS! #define CONTROL_RATE_MS 50 +#define LED_BLINK_MS 1000 #define SAVE_SYS_MS 5000 #define VOL_MAX_FLOAT 0.95