From 04cf625696e606c5941e951393cdefadbf54ee3d Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 25 Sep 2022 10:37:55 +0200 Subject: [PATCH] Drum panorama menu is ready. --- MicroDexed.ino | 5 ++-- UI.hpp | 75 ++++++++++++++++++++++++++++++++++---------------- config.h | 4 +-- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 41ab449..e341efe 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -562,13 +562,14 @@ void setup() { configuration.drums.drum_midi_channel = DRUM_MIDI_CHANNEL; for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) { configuration.drums.drum_vol[i] = mapfloat((drum_config[i].vol_max - drum_config[i].vol_min) / 2.0, 0.0, 1.0, DRUMS_VOL_MIN, DRUMS_VOL_MAX); - configuration.drums.drum_pan[i] = mapfloat(drum_config[i].pan, 0.0, 1.0, DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); + configuration.drums.drum_pan[i] = mapfloat(drum_config[i].pan, -1.0, 1.0, DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); configuration.drums.drum_reverb_send[i] = mapfloat(drum_config[i].reverb_send, 0.0, 1.0, DRUMS_REVERB_SEND_MIN, DRUMS_REVERB_SEND_MAX); configuration.drums.drum_pitch[i] = mapfloat(drum_config[i].pitch, 0.0, 1.0, DRUMS_PITCH_MIN, DRUMS_PITCH_MAX); } + #endif } - + // Setup EPiano #if defined(USE_FX) #if defined(USE_EPIANO) diff --git a/UI.hpp b/UI.hpp index 9bffc40..7110788 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4121,48 +4121,75 @@ void UI_func_drum_volume(uint8_t param) { } } -void UI_func_drum_pan(uint8_t param) { - char temp[8]; +void _UI_func_drum_pan_display(bool mode) { + char temp1[10]; + char temp2[10]; + + memset(temp1, 0, sizeof(temp1)); + memset(temp2, 0, sizeof(temp2)); + if (configuration.drums.drum_pan[activesample] > 25) + display.show(0, 14, 4, ">>"); + else if (configuration.drums.drum_pan[activesample] > 10) + display.show(0, 14, 4, "> "); + else if (configuration.drums.drum_pan[activesample] > 0) + display.show(0, 14, 4, ">="); + else if (configuration.drums.drum_pan[activesample] < -25) + display.show(0, 14, 4, "<<"); + else if (configuration.drums.drum_pan[activesample] < -10) + display.show(0, 14, 4, " <"); + else if (configuration.drums.drum_pan[activesample] < 0) + display.show(0, 14, 4, "=<"); + else + display.show(0, 14, 4, "=="); + if (mode == false) { + snprintf_P(temp1, sizeof(temp1), PSTR("[%02d]"), activesample + 1); + snprintf_P(temp2, sizeof(temp2), PSTR(" %02d "), abs(configuration.drums.drum_pan[activesample])); - memset(temp, 0, sizeof(temp)); + } else { + snprintf_P(temp1, sizeof(temp1), PSTR(" %02d "), activesample + 1); + snprintf_P(temp2, sizeof(temp2), PSTR("[%02d]"), abs(configuration.drums.drum_pan[activesample])); + } + display.show(1, 0, 4, temp1); + display.show(1, 4, 8, basename(drum_config[activesample].name)); + display.show(1, 12, 4, temp2); +} + +void UI_func_drum_pan(uint8_t param) { + static bool mode; if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); display.setCursor(0, 0); display.print("Drum Panorama"); - if (configuration.drums.drum_pan[activesample] > 0) - display.show(0, 14, 4, " >"); - else if (configuration.drums.drum_pan[activesample] < 0) - display.show(0, 14, 4, "<"); - else - display.show(0, 14, 4, "=="); - snprintf_P(temp, sizeof(temp), PSTR("[%02d]"), activesample + 1); - display.show(1, 0, 4, temp); - display.show(1, 4, 9, basename(drum_config[activesample].name)); + _UI_func_drum_pan_display(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 (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort()) { + mode = !mode; + } else if (LCDML.BT_checkDown()) { + if (mode == false) activesample = (activesample + ENCODER[ENC_R].speed()) % (NUM_DRUMSET_CONFIG - 1); - else if (LCDML.BT_checkUp()) { + else + configuration.drums.drum_pan[activesample] = constrain(++configuration.drums.drum_pan[activesample], DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); + } else if (LCDML.BT_checkUp()) { + if (mode == false) { uint8_t temp_encoder = ENCODER[ENC_R].speed(); if (activesample - temp_encoder < 0) activesample = NUM_DRUMSET_CONFIG - (abs(activesample - temp_encoder)) - 1; else activesample -= temp_encoder; + } else { + configuration.drums.drum_pan[activesample] = constrain(--configuration.drums.drum_pan[activesample], DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); } } - if (configuration.drums.drum_pan[activesample] > 0) - display.show(0, 14, 4, " >"); - else if (configuration.drums.drum_pan[activesample] < 0) - display.show(0, 14, 4, "<"); - else - display.show(0, 14, 4, "=="); - snprintf_P(temp, sizeof(temp), PSTR("[%02d]"), activesample + 1); - display.show(1, 0, 4, temp); - display.show(1, 4, 9, basename(drum_config[activesample].name)); + + // Display and set values + _UI_func_drum_pan_display(mode); + + //configuration.drums.drum_pan[i] = mapfloat(drum_config[i].pan, 0.0, 1.0, DRUMS_PANORAMA_MIN, DRUMS_PANORAMA_MAX); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index a3cb0d9..a67a901 100644 --- a/config.h +++ b/config.h @@ -664,8 +664,8 @@ #define DRUMS_MAIN_VOL_MAX 100 #define DRUMS_MAIN_VOL_DEFAULT 80 -#define DRUMS_PANORAMA_MIN 0 -#define DRUMS_PANORAMA_MAX 99 +#define DRUMS_PANORAMA_MIN -50 +#define DRUMS_PANORAMA_MAX 50 #define DRUMS_VOL_MIN 0 #define DRUMS_VOL_MAX 99