diff --git a/UI.hpp b/UI.hpp index d057485..67e8d06 100644 --- a/UI.hpp +++ b/UI.hpp @@ -28,6 +28,7 @@ #include #include +#include #include "config.h" #define _LCDML_DISP_cols LCD_cols @@ -64,6 +65,12 @@ void UI_func_delay_feedback(uint8_t param); void UI_func_delay_level(uint8_t param); void UI_func_filter_cutoff(uint8_t param); void UI_func_filter_resonance(uint8_t param); +void UI_func_midi_channel(uint8_t param); +void UI_func_loudness(uint8_t param); +void UI_func_panorama(uint8_t param); +void UI_func_stereo_mono(uint8_t param); +void UI_func_polyphony(uint8_t param); +void UI_func_engine(uint8_t param); void UI_func_back(uint8_t param); void UI_func_goToRootMenu(uint8_t param); @@ -90,9 +97,15 @@ LCDML_add(15, LCDML_0_2_4, 1, "Cutoff", UI_func_filter_cutoff); LCDML_add(16, LCDML_0_2_4, 2, "Resonance", UI_func_filter_resonance); LCDML_add(17, LCDML_0, 3, "Store", NULL); LCDML_add(18, LCDML_0, 4, "System", NULL); -LCDML_add(19, LCDML_0, 5, "Info", NULL); +LCDML_add(19, LCDML_0_4, 1, "MIDI Channel", UI_func_midi_channel); +LCDML_add(20, LCDML_0_4, 2, "Loudness", UI_func_loudness); +LCDML_add(21, LCDML_0_4, 3, "Panorama", UI_func_panorama); +LCDML_add(22, LCDML_0_4, 4, "Stereo/Mono", UI_func_stereo_mono); +LCDML_add(23, LCDML_0_4, 5, "Polyphony", UI_func_polyphony); +LCDML_add(24, LCDML_0_4, 6, "Engine", UI_func_engine); +LCDML_add(25, LCDML_0, 5, "Info", NULL); -#define _LCDML_DISP_cnt 19 +#define _LCDML_DISP_cnt 25 // create menu LCDML_createMenu(_LCDML_DISP_cnt); @@ -101,15 +114,13 @@ LCDML_createMenu(_LCDML_DISP_cnt); CONTROL ***********************************************************************/ #define g_LCDML_CONTROL_button_long_press 800 // ms -#define g_LCDML_CONTROL_button_short_press 120 // ms - -#define ENCODER_OPTIMIZE_INTERRUPTS //Only when using pin2/3 (or 20/21 on mega) -#include +#define g_LCDML_CONTROL_button_short_press 40 // ms -Encoder ENCODER(ENC_R_PIN_B, ENC_R_PIN_A); +//#define ENCODER_OPTIMIZE_INTERRUPTS //Only when using pin2/3 (or 20/21 on mega) +Encoder ENCODER[2] = {Encoder(ENC_L_PIN_A, ENC_L_PIN_B), Encoder(ENC_R_PIN_A, ENC_R_PIN_B)}; -long g_LCDML_CONTROL_button_press_time = 0; -bool g_LCDML_CONTROL_button_prev = HIGH; +long g_LCDML_CONTROL_button_press_time[2] = {0, 0}; +bool g_LCDML_CONTROL_button_prev[2] = {HIGH, HIGH}; void lcdml_menu_control(void) { @@ -119,62 +130,63 @@ void lcdml_menu_control(void) //pinMode(ENC_R_PIN_A, INPUT_PULLUP); //pinMode(ENC_R_PIN_B, INPUT_PULLUP); pinMode(BUT_R_PIN, INPUT_PULLUP); + pinMode(BUT_L_PIN, INPUT_PULLUP); } //Volatile Variable - long g_LCDML_CONTROL_Encoder_position = ENCODER.read(); - bool button = digitalRead(BUT_R_PIN); + long g_LCDML_CONTROL_Encoder_position[2] = {ENCODER[0].read(), ENCODER[1].read()}; + bool button[2] = {digitalRead(BUT_R_PIN), digitalRead(BUT_L_PIN)}; - if (g_LCDML_CONTROL_Encoder_position <= -3) { + if (g_LCDML_CONTROL_Encoder_position[0] <= -3) { - if (!button) + if (!button[0]) { LCDML.BT_left(); - g_LCDML_CONTROL_button_prev = LOW; - g_LCDML_CONTROL_button_press_time = -1; + g_LCDML_CONTROL_button_prev[0] = LOW; + g_LCDML_CONTROL_button_press_time[0] = -1; } else { LCDML.BT_down(); } - ENCODER.write(g_LCDML_CONTROL_Encoder_position + 4); + ENCODER[0].write(g_LCDML_CONTROL_Encoder_position[0] + 4); } - else if (g_LCDML_CONTROL_Encoder_position >= 3) + else if (g_LCDML_CONTROL_Encoder_position[0] >= 3) { - if (!button) + if (!button[0]) { LCDML.BT_right(); - g_LCDML_CONTROL_button_prev = LOW; - g_LCDML_CONTROL_button_press_time = -1; + g_LCDML_CONTROL_button_prev[0] = LOW; + g_LCDML_CONTROL_button_press_time[0] = -1; } else { LCDML.BT_up(); } - ENCODER.write(g_LCDML_CONTROL_Encoder_position - 4); + ENCODER[0].write(g_LCDML_CONTROL_Encoder_position[0] - 4); } else { - if (!button && g_LCDML_CONTROL_button_prev) //falling edge, button pressed + if (!button[0] && g_LCDML_CONTROL_button_prev[0]) //falling edge, button pressed { - g_LCDML_CONTROL_button_prev = LOW; - g_LCDML_CONTROL_button_press_time = millis(); + g_LCDML_CONTROL_button_prev[0] = LOW; + g_LCDML_CONTROL_button_press_time[0] = millis(); } - else if (button && !g_LCDML_CONTROL_button_prev) //rising edge, button not active + else if (button[0] && !g_LCDML_CONTROL_button_prev[0]) //rising edge, button not active { - g_LCDML_CONTROL_button_prev = HIGH; + g_LCDML_CONTROL_button_prev[0] = HIGH; - if (g_LCDML_CONTROL_button_press_time < 0) + if (g_LCDML_CONTROL_button_press_time[0] < 0) { - g_LCDML_CONTROL_button_press_time = millis(); + g_LCDML_CONTROL_button_press_time[0] = millis(); //Reset for left right action } - else if ((millis() - g_LCDML_CONTROL_button_press_time) >= g_LCDML_CONTROL_button_long_press) + else if ((millis() - g_LCDML_CONTROL_button_press_time[0]) >= g_LCDML_CONTROL_button_long_press) { LCDML.BT_quit(); } - else if ((millis() - g_LCDML_CONTROL_button_press_time) >= g_LCDML_CONTROL_button_short_press) + else if ((millis() - g_LCDML_CONTROL_button_press_time[0]) >= g_LCDML_CONTROL_button_short_press) { LCDML.BT_enter(); } @@ -317,7 +329,7 @@ void UI_func_sound(uint8_t param) if (LCDML.FUNC_loop()) // ****** LOOP ********* { - if (LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right) + if (LCDML.BT_checkEnter()) { // check if any button is pressed (enter, up, down, left, right) // LCDML_goToMenu stops a running menu function and goes to the menu LCDML.FUNC_goBackToMenu(); } @@ -384,6 +396,36 @@ void UI_func_filter_resonance(uint8_t param) ; } +void UI_func_midi_channel(uint8_t param) +{ + ; +} + +void UI_func_loudness(uint8_t param) +{ + ; +} + +void UI_func_panorama(uint8_t param) +{ + ; +} + +void UI_func_stereo_mono(uint8_t param) +{ + ; +} + +void UI_func_polyphony(uint8_t param) +{ + ; +} + +void UI_func_engine(uint8_t param) +{ + ; +} + void UI_func_information(uint8_t param) { if (LCDML.FUNC_setup()) // ****** SETUP ********* @@ -392,14 +434,14 @@ void UI_func_information(uint8_t param) lcd.setCursor(0, 0); lcd.print(F("MicroDexed")); lcd.setCursor(0, 1); - lcd.print(F("LCDMenuLib2")); + lcd.print(VERSION); } if (LCDML.FUNC_loop()) // ****** LOOP ********* { // loop function, can be run in a loop when LCDML_DISP_triggerMenu(xx) is set // the quit button works in every DISP function without any checks; it starts the loop_end function - if (LCDML.BT_checkAny()) { // check if any button is pressed (enter, up, down, left, right) + if (LCDML.BT_checkEnter()) { // check if any button is pressed (enter, up, down, left, right) // LCDML_goToMenu stops a running menu function and goes to the menu LCDML.FUNC_goBackToMenu(); } @@ -425,7 +467,7 @@ void UI_func_screensaver(uint8_t param) if (LCDML.FUNC_loop()) { - if (LCDML.BT_checkAny()) // check if any button is pressed (enter, up, down, left, right) + if (LCDML.BT_checkEnter()) // check if any button is pressed (enter, up, down, left, right) { LCDML.FUNC_goBackToMenu(); // leave this function }