|
|
@ -133,6 +133,78 @@ Encoder ENCODER[NUM_ENCODER] = {Encoder(ENC_R_PIN_B, ENC_R_PIN_A), Encoder(ENC_L |
|
|
|
long g_LCDML_CONTROL_button_press_time[NUM_ENCODER] = {0, 0}; |
|
|
|
long g_LCDML_CONTROL_button_press_time[NUM_ENCODER] = {0, 0}; |
|
|
|
bool g_LCDML_CONTROL_button_prev[NUM_ENCODER] = {HIGH, HIGH}; |
|
|
|
bool g_LCDML_CONTROL_button_prev[NUM_ENCODER] = {HIGH, HIGH}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void lcdml_menu_control(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// If something must init, put in in the setup condition
|
|
|
|
|
|
|
|
if(LCDML.BT_setup()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pinMode(BUT_R_PIN, INPUT_PULLUP); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Volatile Variable
|
|
|
|
|
|
|
|
long g_LCDML_CONTROL_Encoder_position = ENCODER[ENC_R].read(); |
|
|
|
|
|
|
|
bool button = digitalRead(BUT_R_PIN); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(g_LCDML_CONTROL_Encoder_position <= -3) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!button) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LCDML.BT_left(); |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_prev[ENC_R] = LOW; |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_press_time[ENC_R] = -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LCDML.BT_down(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position+4); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(g_LCDML_CONTROL_Encoder_position >= 3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!button) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LCDML.BT_right(); |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_prev[ENC_R] = LOW; |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_press_time[ENC_R] = -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LCDML.BT_up(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ENCODER[ENC_R].write(g_LCDML_CONTROL_Encoder_position-4); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(!button && g_LCDML_CONTROL_button_prev[ENC_R]) //falling edge, button pressed
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_prev[ENC_R] = LOW; |
|
|
|
|
|
|
|
g_LCDML_CONTROL_button_press_time[ENC_R] = millis(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if(button && !g_LCDML_CONTROL_button_prev[ENC_R]) //rising edge, button 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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if((millis() - g_LCDML_CONTROL_button_press_time[ENC_R]) >= g_LCDML_CONTROL_button_short_press) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LCDML.BT_enter(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
void lcdml_menu_control(void) |
|
|
|
void lcdml_menu_control(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// If something must init, put in in the setup condition
|
|
|
|
// If something must init, put in in the setup condition
|
|
|
@ -199,7 +271,7 @@ void lcdml_menu_control(void) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
void lcdml_voice_menu_control(void) |
|
|
|
void lcdml_voice_menu_control(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// If something must init, put in in the setup condition
|
|
|
|
// If something must init, put in in the setup condition
|
|
|
|