Seperating encoder functions from control function.

pull/3/head
Holger Wirtz 5 years ago
parent 482e714dec
commit f59d810343
  1. 261
      UI.hpp

261
UI.hpp

@ -76,6 +76,14 @@ void lcdml_menu_display(void);
void lcdml_voice_menu_display(void);
void lcdml_menu_clear(void);
void lcdml_menu_control(void);
void encoder_right_up(void);
void encoder_right_down(void);
void encoder_right_button_long(void);
void encoder_right_button_short(void);
void encoder_left_up(void);
void encoder_left_down(void);
void encoder_left_button_long(void);
void encoder_left_button_short(void);
void lcdml_voice_menu_control(void);
void UI_func_sound(uint8_t param);
void UI_func_reverb_roomsize(uint8_t param);
@ -170,8 +178,9 @@ void lcdml_menu_control(void)
bool button[NUM_ENCODER] = {digitalRead(BUT_R_PIN), digitalRead(BUT_L_PIN)};
/************************************************************************************
Right encoder
Basic encoder handlying (from LCDMenuLib2
************************************************************************************/
// RIGHT
if (g_LCDML_CONTROL_Encoder_position[ENC_R] <= -3)
{
if (!button[ENC_R])
@ -182,6 +191,124 @@ void lcdml_menu_control(void)
}
else
{
encoder_right_up();
}
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4);
}
else if (g_LCDML_CONTROL_Encoder_position[ENC_R] >= 3)
{
if (!button[ENC_R])
{
LCDML.BT_right();
g_LCDML_CONTROL_button_prev[ENC_R] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_R] = -1;
}
else
{
encoder_right_down();
}
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4);
}
else
{
if (!button[ENC_R] && g_LCDML_CONTROL_button_prev[ENC_R]) //falling edge, button[ENC_R] pressed
{
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[ENC_R] not active
{
g_LCDML_CONTROL_button_prev[ENC_R] = HIGH;
if (g_LCDML_CONTROL_button_press_time[ENC_R] < 0)
{
g_LCDML_CONTROL_button_press_time[ENC_R] = millis();
//Reset for left right action
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= g_LCDML_CONTROL_button_long_press)
{
LCDML.BT_quit();
if (menu_state == MENU_EDIT)
{
LCDML.BT_quit();
}
else if (menu_state == MENU_VOICE)
{
encoder_right_button_long();
}
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= g_LCDML_CONTROL_button_short_press)
{
encoder_right_button_short();
}
}
}
// LEFT
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
{
encoder_left_up();
}
ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] + 4);
}
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
{
encoder_left_down();
}
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();
encoder_left_button_long();
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= g_LCDML_CONTROL_button_short_press)
{
//LCDML.BT_enter();
encoder_left_button_short();
}
}
}
}
/************************************************************************************
RIGHT Encoder functions
************************************************************************************/
void encoder_right_up(void)
{
switch (menu_state)
{
case MENU_EDIT:
@ -221,20 +348,10 @@ void lcdml_menu_control(void)
UI_func_voice_selection(0);
break;
}
}
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] + 4);
}
else if (g_LCDML_CONTROL_Encoder_position[ENC_R] >= 3)
{
}
if (!button[ENC_R])
{
LCDML.BT_right();
g_LCDML_CONTROL_button_prev[ENC_R] = LOW;
g_LCDML_CONTROL_button_press_time[ENC_R] = -1;
}
else
{
void encoder_right_down(void)
{
switch (menu_state)
{
case MENU_EDIT:
@ -274,41 +391,22 @@ void lcdml_menu_control(void)
UI_func_voice_selection(0);
break;
}
}
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position[ENC_R] - 4);
}
else
{
if (!button[ENC_R] && g_LCDML_CONTROL_button_prev[ENC_R]) //falling edge, button[ENC_R] pressed
{
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[ENC_R] not active
{
g_LCDML_CONTROL_button_prev[ENC_R] = HIGH;
}
if (g_LCDML_CONTROL_button_press_time[ENC_R] < 0)
{
g_LCDML_CONTROL_button_press_time[ENC_R] = millis();
//Reset for left right action
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= g_LCDML_CONTROL_button_long_press)
{
LCDML.BT_quit();
if (menu_state == MENU_EDIT)
{
LCDML.BT_quit();
}
else if (menu_state == MENU_VOICE)
{
void encoder_right_button_long(void)
{
#ifdef DEBUG
Serial.println(F("State: MENU_VOICE, button long press"));
#else
;
#endif
}
void encoder_right_button_short(void)
{
#ifdef DEBUG
Serial.println(F("Encoder right short press"));
#endif
}
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= g_LCDML_CONTROL_button_short_press)
{
if (menu_state == MENU_EDIT)
{
LCDML.BT_enter();
@ -324,23 +422,13 @@ void lcdml_menu_control(void)
menu_voice = MENU_VOICE_BANK;
UI_func_voice_selection(0);
}
}
}
}
}
/************************************************************************************
Left encoder
/************************************************************************************
LEFT Encoder functions
************************************************************************************/
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
{
void encoder_left_up(void)
{
#ifdef DEBUG
Serial.println(F("Volume +"));
#endif
@ -351,20 +439,10 @@ void lcdml_menu_control(void)
eeprom_write();
}
UI_func_volume(0);
}
ENCODER[ENC_L].write(g_LCDML_CONTROL_Encoder_position[ENC_L] + 4);
}
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
{
void encoder_left_down(void)
{
#ifdef DEBUG
Serial.println(F("Volume -"));
#endif
@ -375,35 +453,19 @@ void lcdml_menu_control(void)
eeprom_write();
}
UI_func_volume(0);
}
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();
void encoder_left_button_long(void)
{
#ifdef DEBUG
Serial.println(F("Encoder left long press"));
#else
;
#endif
}
else if ((millis() - g_LCDML_CONTROL_button_press_time[ENC_L]) >= g_LCDML_CONTROL_button_short_press)
{
//LCDML.BT_enter();
}
void encoder_left_button_short(void)
{
#ifdef DEBUG
Serial.println(F("Encoder left short press"));
#endif
@ -417,9 +479,6 @@ void lcdml_menu_control(void)
menu_state = MENU_EDIT;
LCDML.MENU_goRoot();
}
}
}
}
}
/***********************************************************************

Loading…
Cancel
Save