pull/3/head
Holger Wirtz 5 years ago
parent d99e5d6efb
commit 19cf6d9275
  1. 2
      MicroDexed.ino
  2. 98
      UI.hpp

@ -144,7 +144,7 @@ void setup()
// 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_selection, VOICE_SELECTION_MS); // set to 10 seconds //LCDML.SCREEN_enable(UI_func_voice_selection, VOICE_SELECTION_MS); // set to 10 seconds
#else #else
Serial.println(F("NO LCD DISPLAY ENABLED!")); Serial.println(F("NO LCD DISPLAY ENABLED!"));
#endif #endif

@ -51,8 +51,8 @@ const uint8_t scroll_bar[5][8] = {
}; };
enum { ENC_R, ENC_L }; enum { ENC_R, ENC_L };
enum { MENU_R_SHOW, MENU_R_EDIT}; enum { MENU_VOICE, MENU_EDIT};
uint8_t menu_state = MENU_R_SHOW; uint8_t menu_state = MENU_EDIT;
void lcdml_menu_display(void); void lcdml_menu_display(void);
void lcdml_voice_menu_display(void); void lcdml_voice_menu_display(void);
@ -137,12 +137,14 @@ void lcdml_menu_control(void)
if (LCDML.BT_setup()) if (LCDML.BT_setup())
{ {
pinMode(BUT_R_PIN, INPUT_PULLUP); pinMode(BUT_R_PIN, INPUT_PULLUP);
pinMode(BUT_L_PIN, INPUT_PULLUP);
} }
//Volatile Variable //Volatile Variable
long g_LCDML_CONTROL_Encoder_position[NUM_ENCODER] = {ENCODER[ENC_R].read(), ENCODER[ENC_L].read()}; long g_LCDML_CONTROL_Encoder_position[NUM_ENCODER] = {ENCODER[ENC_R].read(), ENCODER[ENC_L].read()};
bool button[NUM_ENCODER] = {digitalRead(BUT_R_PIN), digitalRead(BUT_L_PIN)}; bool button[NUM_ENCODER] = {digitalRead(BUT_R_PIN), digitalRead(BUT_L_PIN)};
// Right encoder
if (g_LCDML_CONTROL_Encoder_position[ENC_R] <= -3) if (g_LCDML_CONTROL_Encoder_position[ENC_R] <= -3)
{ {
if (!button[ENC_R]) if (!button[ENC_R])
@ -153,7 +155,7 @@ void lcdml_menu_control(void)
} }
else else
{ {
if (menu_state == MENU_R_SHOW) if (menu_state == MENU_EDIT)
LCDML.BT_down(); LCDML.BT_down();
} }
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4); ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4);
@ -169,7 +171,7 @@ void lcdml_menu_control(void)
} }
else else
{ {
if (menu_state == MENU_R_SHOW) if (menu_state == MENU_EDIT)
LCDML.BT_up(); LCDML.BT_up();
} }
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4); ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4);
@ -200,24 +202,84 @@ void lcdml_menu_control(void)
} }
} }
} }
/*
// checking encoder left (volume) // Left encoder
if (g_LCDML_CONTROL_old_var[ENC_L] != g_LCDML_CONTROL_Encoder_position[ENC_L])
{
if (g_LCDML_CONTROL_Encoder_position[ENC_L] <= -3) if (g_LCDML_CONTROL_Encoder_position[ENC_L] <= -3)
{ {
if (!button[ENC_L])
{
//LCDML.BT_left();
g_LCDML_CONTROL_button_prev[ENC_L] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_L] = -1;
}
else
{
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume +")); Serial.println(F("Volume +"));
#endif #endif
} }
ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] + 4);
}
else if (g_LCDML_CONTROL_Encoder_position[ENC_L] >= 3) else if (g_LCDML_CONTROL_Encoder_position[ENC_L] >= 3)
{ {
if (!button[ENC_L])
{
//LCDML.BT_right();
g_LCDML_CONTROL_button_prev[ENC_L] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_L] = -1;
}
else
{
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("Volume -")); Serial.println(F("Volume -"));
#endif #endif
} }
g_LCDML_CONTROL_old_var[ENC_L] = g_LCDML_CONTROL_Encoder_position[ENC_L]; ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] - 4);
}*/ }
else
{
if (!button[ENC_L] && g_LCDML_CONTROL_button_prev[ENC_L]) //falling edge, button[ENC_L] pressed
{
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[ENC_L] not active
{
g_LCDML_CONTROL_button_prev[ENC_L] = HIGH;
if (g_LCDML_CONTROL_button_press_time[ENC_L] < 0)
{
g_LCDML_CONTROL_button_press_time[ENC_L] = millis();
//Reset for left right action
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= g_LCDML_CONTROL_button_long_press)
{
//LCDML.BT_quit();
#ifdef DEBUG
Serial.println(F("Encoder left long press"));
#endif
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= g_LCDML_CONTROL_button_short_press)
{
//LCDML.BT_enter();
#ifdef DEBUG
Serial.println(F("Encoder left short press"));
#endif
if (menu_state == MENU_EDIT)
{
menu_state = MENU_VOICE;
LCDML.OTHER_jumpToFunc(UI_func_voice_selection,0);
}
else if (menu_state == MENU_VOICE)
{
menu_state = MENU_EDIT;
LCDML.MENU_goRoot();
}
}
}
}
} }
/*********************************************************************** /***********************************************************************
@ -349,7 +411,7 @@ void UI_func_sound(uint8_t param)
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Filter Res.")); lcd.print(F("Filter Res."));
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
lcd.print(F("<valua>")); lcd.print(F("<value>"));
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -483,6 +545,7 @@ void UI_func_voice_selection(uint8_t param)
if (LCDML.FUNC_setup()) // ****** SETUP ********* if (LCDML.FUNC_setup()) // ****** SETUP *********
{ {
// update LCD content // update LCD content
lcd.clear();
lcd.setCursor(0, 0); // set cursor lcd.setCursor(0, 0); // set cursor
lcd.print("screensaver"); // print change content lcd.print("screensaver"); // print change content
lcd.setCursor(0, 1); // set cursor lcd.setCursor(0, 1); // set cursor
@ -492,9 +555,9 @@ void UI_func_voice_selection(uint8_t param)
if (LCDML.FUNC_loop()) if (LCDML.FUNC_loop())
{ {
if (LCDML.BT_checkEnter()) // check if any button is pressed (enter, up, down, left, right) if (LCDML.BT_checkEnter())
{ {
LCDML.FUNC_goBackToMenu(); // leave this function LCDML.MENU_goRoot();
} }
} }
@ -505,14 +568,5 @@ void UI_func_voice_selection(uint8_t param)
} }
} }
void UI_func_goToRootMenu(uint8_t param)
{
if (LCDML.FUNC_setup()) // ****** SETUP *********
{
// go to root and display menu
LCDML.MENU_goRoot();
}
}
#endif #endif
#endif #endif

Loading…
Cancel
Save