Fixes for going back from volume menu.

pull/32/head
Holger Wirtz 5 years ago
parent fb9bd37352
commit 8920c97b32
  1. 77
      UI.hpp

@ -258,6 +258,7 @@ class EncoderDirection
{ {
button_short = false; button_short = false;
button_long = false; button_long = false;
button_pressed = false;
left = false; left = false;
right = false; right = false;
up = false; up = false;
@ -294,6 +295,16 @@ class EncoderDirection
return (false); return (false);
} }
void ButtonPressed(bool state)
{
button_pressed = state;
}
bool ButtonPressed(void)
{
return (button_pressed);
}
void Left(bool state) void Left(bool state)
{ {
left = state; left = state;
@ -357,6 +368,7 @@ class EncoderDirection
private: private:
bool button_short; bool button_short;
bool button_long; bool button_long;
bool button_pressed;
bool left; bool left;
bool right; bool right;
bool up; bool up;
@ -418,7 +430,7 @@ void setup_ui(void)
// Enable Menu Rollover // Enable Menu Rollover
//LCDML.MENU_enRollover(); //LCDML.MENU_enRollover();
// Enable Screensaver (screensaver menu function, time to activate in ms) // 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 #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 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_prev[ENC_R] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_R] = millis(); 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 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; g_LCDML_CONTROL_button_prev[ENC_R] = HIGH;
if (g_LCDML_CONTROL_button_press_time[ENC_R] < 0) 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) else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= LONG_BUTTON_PRESS)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println("ENC-R long"); Serial.println("ENC-R long released");
#endif #endif
//LCDML.BT_quit(); //LCDML.BT_quit();
encoderDir[ENC_R].ButtonLong(true); encoderDir[ENC_R].ButtonLong(true);
if (LCDML.FUNC_getID() < 0xff) /*
LCDML.FUNC_setGBAToLastFunc(); if (LCDML.FUNC_getID() < 0xff)
else LCDML.FUNC_setGBAToLastFunc();
LCDML.FUNC_setGBAToLastCursorPos(); else
LCDML.FUNC_setGBAToLastCursorPos();
//LCDML.FUNC_setGBA(); //LCDML.FUNC_setGBA();
LCDML.OTHER_jumpToFunc(UI_func_voice_select); LCDML.OTHER_jumpToFunc(UI_func_voice_select);
*/
} }
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= BUT_DEBOUNCE_MS) 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 // LEFT
if (g_LCDML_CONTROL_Encoder_position[ENC_L] <= -3) 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 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_prev[ENC_L] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_L] = millis(); 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 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; g_LCDML_CONTROL_button_prev[ENC_L] = HIGH;
if (g_LCDML_CONTROL_button_press_time[ENC_L] < 0) 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) else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= LONG_BUTTON_PRESS)
{ {
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("ENC-L long")); Serial.println(F("ENC-L long released"));
#endif #endif
//encoderDir[ENC_L].ButtonLong(true); //encoderDir[ENC_L].ButtonLong(true);
//LCDML.BT_quit(); //LCDML.BT_quit();
for (uint8_t i = 0; i < NUM_DEXED; i++) /*
for (uint8_t i = 0; i < NUM_DEXED; i++)
MicroDexed[i]->panic(); MicroDexed[i]->panic();
*/
} }
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= BUT_DEBOUNCE_MS) 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(); LCDML.MENU_goRoot();
menu_init = false; 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 else
LCDML.BT_quit(); 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();
}
} }
/*********************************************************************** /***********************************************************************

Loading…
Cancel
Save