Restore access to configuration menu via screen long-press and selector button
This commit is contained in:
parent
3ea2487d8d
commit
644179f09c
1 changed files with 25 additions and 4 deletions
|
|
@ -300,6 +300,13 @@ recent_client_addr : {0x00,0x00,0x00,0x00,0x00,0x00} array of bytes[6]
|
||||||
while (!foundOBD2) { //not success try scan and connect another OBD2
|
while (!foundOBD2) { //not success try scan and connect another OBD2
|
||||||
scanBTdevice();
|
scanBTdevice();
|
||||||
autoDim(); //auto backlight handle
|
autoDim(); //auto backlight handle
|
||||||
|
|
||||||
|
if (digitalRead(SELECTOR_PIN) == LOW) { //button pressed
|
||||||
|
delay(50);
|
||||||
|
if (digitalRead(SELECTOR_PIN) == LOW) {
|
||||||
|
configMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize ELM327
|
//Initialize ELM327
|
||||||
|
|
@ -338,11 +345,13 @@ void loop() {
|
||||||
updateBacklightFade(); // non-blocking smooth backlight fade handler
|
updateBacklightFade(); // non-blocking smooth backlight fade handler
|
||||||
handleArcAlarmFlash(); // non-blocking arc alarm flash handler (blinks when in TFT_RED)
|
handleArcAlarmFlash(); // non-blocking arc alarm flash handler (blinks when in TFT_RED)
|
||||||
|
|
||||||
// SCAN TOUCHSCREEN
|
// SCAN TOUCHSCREEN & BUTTON
|
||||||
// - Single click on a quadrant: toggles between clock (arc) and number
|
// - Single click on a quadrant: toggles between clock (arc) and number
|
||||||
// - Double click on a quadrant: puts that instrument in full screen (or exits full screen)
|
// - Double click on a quadrant: puts that instrument in full screen (or exits full screen)
|
||||||
|
// - Long press (> 1s) on screen OR holding selector button: opens configuration menu
|
||||||
uint16_t touchX = 0, touchY = 0;
|
uint16_t touchX = 0, touchY = 0;
|
||||||
bool isTouched = getTouch(&touchX, &touchY);
|
bool isTouched = getTouch(&touchX, &touchY);
|
||||||
|
bool btnPressed = (digitalRead(SELECTOR_PIN) == LOW);
|
||||||
|
|
||||||
static bool isTouching = false;
|
static bool isTouching = false;
|
||||||
static uint32_t touchStartTime = 0;
|
static uint32_t touchStartTime = 0;
|
||||||
|
|
@ -350,19 +359,31 @@ void loop() {
|
||||||
static uint8_t clickCount = 0;
|
static uint8_t clickCount = 0;
|
||||||
static uint32_t firstClickTime = 0;
|
static uint32_t firstClickTime = 0;
|
||||||
static int8_t clickQuadrant = -1;
|
static int8_t clickQuadrant = -1;
|
||||||
|
static bool longPressHandled = false;
|
||||||
|
|
||||||
if (isTouched) {
|
if (isTouched || btnPressed) {
|
||||||
if (!isTouching) {
|
if (!isTouching) {
|
||||||
isTouching = true;
|
isTouching = true;
|
||||||
touchStartTime = millis();
|
touchStartTime = millis();
|
||||||
lastTouchX = touchX;
|
lastTouchX = touchX;
|
||||||
lastTouchY = touchY;
|
lastTouchY = touchY;
|
||||||
|
longPressHandled = false;
|
||||||
|
} else if (!longPressHandled && (millis() - touchStartTime > 1000)) {
|
||||||
|
// Long press (> 1s) or button hold: Open Config Menu!
|
||||||
|
longPressHandled = true;
|
||||||
|
clickCount = 0;
|
||||||
|
ledcWriteTone(buzzerChannel, 3500);
|
||||||
|
delay(40);
|
||||||
|
ledcWriteTone(buzzerChannel, 0);
|
||||||
|
configMenu();
|
||||||
|
if (foundOBD2) initScreen();
|
||||||
|
isTouching = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Touch released
|
// Touch / button released
|
||||||
if (isTouching) {
|
if (isTouching) {
|
||||||
isTouching = false;
|
isTouching = false;
|
||||||
if (millis() - touchStartTime >= 30) {
|
if (!longPressHandled && (millis() - touchStartTime >= 30)) {
|
||||||
// Valid tap detected! Determine quadrant
|
// Valid tap detected! Determine quadrant
|
||||||
int quad = (lastTouchX < 160) ? ((lastTouchY < 120) ? 0 : 2) : ((lastTouchY < 120) ? 1 : 3);
|
int quad = (lastTouchX < 160) ? ((lastTouchY < 120) ? 0 : 2) : ((lastTouchY < 120) ? 1 : 3);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue