diff --git a/UI.hpp b/UI.hpp index ca55526..20ad64e 100644 --- a/UI.hpp +++ b/UI.hpp @@ -258,6 +258,7 @@ class EncoderDirection { button_short = false; button_long = false; + button_pressed = false; left = false; right = false; up = false; @@ -294,6 +295,16 @@ class EncoderDirection return (false); } + void ButtonPressed(bool state) + { + button_pressed = state; + } + + bool ButtonPressed(void) + { + return (button_pressed); + } + void Left(bool state) { left = state; @@ -357,6 +368,7 @@ class EncoderDirection private: bool button_short; bool button_long; + bool button_pressed; bool left; bool right; bool up; @@ -418,7 +430,7 @@ void setup_ui(void) // Enable Menu Rollover //LCDML.MENU_enRollover(); // Enable Screensaver (screensaver menu function, time to activate in ms) - LCDML.SCREEN_enable(UI_func_voice_select, VOICE_SELECTION_MS); + //LCDML.SCREEN_enable(UI_func_voice_select, VOICE_SELECTION_MS); } #ifdef DEBUG @@ -531,11 +543,13 @@ void lcdml_menu_control(void) { if (!button[ENC_R] && g_LCDML_CONTROL_button_prev[ENC_R]) //falling edge, button pressed { + encoderDir[ENC_R].ButtonPressed(true); g_LCDML_CONTROL_button_prev[ENC_R] = LOW; g_LCDML_CONTROL_button_press_time[ENC_R] = millis(); } else if (button[ENC_R] && !g_LCDML_CONTROL_button_prev[ENC_R]) //rising edge, button not active { + encoderDir[ENC_R].ButtonPressed(false); g_LCDML_CONTROL_button_prev[ENC_R] = HIGH; if (g_LCDML_CONTROL_button_press_time[ENC_R] < 0) @@ -546,18 +560,20 @@ void lcdml_menu_control(void) else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= LONG_BUTTON_PRESS) { #ifdef DEBUG - Serial.println("ENC-R long"); + Serial.println("ENC-R long released"); #endif //LCDML.BT_quit(); encoderDir[ENC_R].ButtonLong(true); - if (LCDML.FUNC_getID() < 0xff) - LCDML.FUNC_setGBAToLastFunc(); - else - LCDML.FUNC_setGBAToLastCursorPos(); + /* + if (LCDML.FUNC_getID() < 0xff) + LCDML.FUNC_setGBAToLastFunc(); + else + LCDML.FUNC_setGBAToLastCursorPos(); - //LCDML.FUNC_setGBA(); - LCDML.OTHER_jumpToFunc(UI_func_voice_select); + //LCDML.FUNC_setGBA(); + LCDML.OTHER_jumpToFunc(UI_func_voice_select); + */ } else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= BUT_DEBOUNCE_MS) { @@ -571,6 +587,21 @@ void lcdml_menu_control(void) } } + if (encoderDir[ENC_R].ButtonPressed() == true && (millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= LONG_BUTTON_PRESS) + { +#ifdef DEBUG + Serial.println("ENC-R long recognized"); +#endif + encoderDir[ENC_R].ButtonLong(true); + + if (LCDML.FUNC_getID() < 0xff) + LCDML.FUNC_setGBAToLastFunc(); + else + LCDML.FUNC_setGBAToLastCursorPos(); + + LCDML.OTHER_jumpToFunc(UI_func_voice_select); + } + // LEFT if (g_LCDML_CONTROL_Encoder_position[ENC_L] <= -3) { @@ -628,11 +659,13 @@ void lcdml_menu_control(void) { if (!button[ENC_L] && g_LCDML_CONTROL_button_prev[ENC_L]) //falling edge, button pressed { + encoderDir[ENC_L].ButtonPressed(true); g_LCDML_CONTROL_button_prev[ENC_L] = LOW; g_LCDML_CONTROL_button_press_time[ENC_L] = millis(); } else if (button[ENC_L] && !g_LCDML_CONTROL_button_prev[ENC_L]) //rising edge, button not active { + encoderDir[ENC_L].ButtonPressed(false); g_LCDML_CONTROL_button_prev[ENC_L] = HIGH; if (g_LCDML_CONTROL_button_press_time[ENC_L] < 0) @@ -643,12 +676,14 @@ void lcdml_menu_control(void) else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= LONG_BUTTON_PRESS) { #ifdef DEBUG - Serial.println(F("ENC-L long")); + Serial.println(F("ENC-L long released")); #endif //encoderDir[ENC_L].ButtonLong(true); //LCDML.BT_quit(); - for (uint8_t i = 0; i < NUM_DEXED; i++) + /* + for (uint8_t i = 0; i < NUM_DEXED; i++) MicroDexed[i]->panic(); + */ } else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= BUT_DEBOUNCE_MS) { @@ -663,11 +698,33 @@ void lcdml_menu_control(void) LCDML.MENU_goRoot(); menu_init = false; } + else if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_volume)) + { + encoderDir[ENC_L].reset(); + encoderDir[ENC_R].reset(); + + if (LCDML.MENU_getLastActiveFunctionID() < 0xff) + LCDML.OTHER_jumpToID(LCDML.MENU_getLastActiveFunctionID()); + else + LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID()); + } else LCDML.BT_quit(); } } } + + if (encoderDir[ENC_L].ButtonPressed() == true && (millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= LONG_BUTTON_PRESS) + { +#ifdef DEBUG + Serial.println(F("ENC-L long recognized")); +#endif + for (uint8_t i = 0; i < NUM_DEXED; i++) + MicroDexed[i]->panic(); + + encoderDir[ENC_L].reset(); + encoderDir[ENC_R].reset(); + } } /***********************************************************************