t-hmi: implement pr suggestions; remove janky global in touchhandler class
This commit is contained in:
parent
42b5f11d3c
commit
e089634eff
@ -14,7 +14,10 @@
|
||||
#include "drivers/displays/display.h"
|
||||
#include "drivers/storage/SDCard.h"
|
||||
#include "timeconst.h"
|
||||
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include "TouchHandler.h"
|
||||
#endif
|
||||
|
||||
//3 seconds WDT
|
||||
#define WDT_TIMEOUT 3
|
||||
@ -102,7 +105,7 @@ void setup()
|
||||
mMonitor.NerdStatus = NM_waitingConfig;
|
||||
doLedStuff(0);
|
||||
|
||||
#ifdef NERDMINER_T_HMI
|
||||
#ifdef SDMMC_1BIT_FIX
|
||||
SDCrd.initSDcard();
|
||||
#endif
|
||||
|
||||
@ -151,9 +154,6 @@ void app_error_fault_handler(void *arg) {
|
||||
// restart ESP32
|
||||
esp_restart();
|
||||
}
|
||||
#ifdef NERDMINER_T_HMI
|
||||
extern uint16_t t_hmiCheckForTouch();
|
||||
#endif
|
||||
|
||||
void loop() {
|
||||
// keep watching the push buttons:
|
||||
|
@ -3,8 +3,6 @@
|
||||
#ifdef TOUCH_ENABLE
|
||||
#include "TouchHandler.h"
|
||||
|
||||
// Global variable declaration
|
||||
extern unsigned int lowerScreen;
|
||||
|
||||
|
||||
TouchHandler::~TouchHandler() {
|
||||
@ -12,7 +10,7 @@ TouchHandler::~TouchHandler() {
|
||||
|
||||
TouchHandler::TouchHandler(TFT_eSPI& tft, uint8_t csPin, uint8_t irqPin, SPIClass& spi)
|
||||
: tft(tft), csPin(csPin), irqPin(irqPin), spi(spi), lastTouchTime(0),
|
||||
screenSwitchCallback(nullptr), touch(spi, csPin, irqPin) {
|
||||
screenSwitchCallback(nullptr), screenSwitchAltCallback(nullptr), touch(spi, csPin, irqPin) {
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +23,11 @@ void TouchHandler::setScreenSwitchCallback(void (*callback)()) {
|
||||
screenSwitchCallback = callback;
|
||||
}
|
||||
|
||||
void TouchHandler::setScreenSwitchAltCallback(void (*callback)()) {
|
||||
screenSwitchAltCallback = callback;
|
||||
}
|
||||
|
||||
|
||||
uint16_t TouchHandler::isTouched() {
|
||||
// XXX - move touch_x, touch_y to private and min_x, min_y,max_x, max_y
|
||||
uint16_t touch_x, touch_y, code = 0;
|
||||
@ -38,8 +41,9 @@ uint16_t TouchHandler::isTouched() {
|
||||
if (touch_x < 200 + (1700 - 200) / 4) {
|
||||
// bottom
|
||||
code = 1;
|
||||
if (debounce())
|
||||
lowerScreen = 3 - lowerScreen;
|
||||
if (debounce() && screenSwitchAltCallback) {
|
||||
screenSwitchAltCallback();
|
||||
}
|
||||
} else {
|
||||
// top
|
||||
code = 2;
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
void begin(uint16_t xres, uint16_t yres);
|
||||
uint16_t isTouched();
|
||||
void setScreenSwitchCallback(void (*callback)());
|
||||
|
||||
void setScreenSwitchAltCallback(void (*callback)());
|
||||
private:
|
||||
bool debounce();
|
||||
TFT_eSPI& tft;
|
||||
@ -24,6 +24,7 @@ private:
|
||||
unsigned long lastTouchTime;
|
||||
// unsigned int lower_switch;
|
||||
void (*screenSwitchCallback)();
|
||||
void (*screenSwitchAltCallback)();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define SDMMC_D0 (13)
|
||||
|
||||
#define TOUCH_ENABLE (1)
|
||||
|
||||
#define SDMMC_1BIT_FIX (1)
|
||||
#ifndef TFT_BL
|
||||
// XXX - defined in User_Setups/Setup207_LilyGo_T_HMI.h:37
|
||||
#define TFT_BL (38) // LED back-light
|
||||
|
@ -38,6 +38,9 @@ extern monitor_data mMonitor;
|
||||
extern pool_data pData;
|
||||
extern DisplayDriver *currentDisplayDriver;
|
||||
|
||||
void toggleBottomScreen() { lowerScreen = 3 - lowerScreen; }
|
||||
|
||||
|
||||
uint32_t readAdcVoltage(int pin) {
|
||||
esp_adc_cal_characteristics_t adc_chars;
|
||||
|
||||
@ -82,6 +85,7 @@ void t_hmiDisplay_Init(void)
|
||||
Serial.println(F("Initialize the touch screen"));
|
||||
touchHandler.begin(HEIGHT, WIDTH);
|
||||
touchHandler.setScreenSwitchCallback(switchToNextScreen);
|
||||
touchHandler.setScreenSwitchAltCallback(toggleBottomScreen);
|
||||
#endif
|
||||
|
||||
Serial.println(F("Turn on the LCD backlight"));
|
||||
|
@ -34,7 +34,7 @@ SDCard::SDCard(int ID):cardInitialized_(false),cardBusy_(false)
|
||||
}
|
||||
iSD_ = &SD;
|
||||
#endif // interface type
|
||||
#ifndef NERDMINER_T_HMI
|
||||
#ifndef SDMMC_1BIT_FIX
|
||||
initSDcard();
|
||||
#endif
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
bool loadConfigFile(TSettings* Settings);
|
||||
bool cardAvailable();
|
||||
bool cardBusy();
|
||||
#ifdef NERDMINER_T_HMI
|
||||
#ifdef SDMMC_1BIT_FIX
|
||||
bool initSDcard();
|
||||
private:
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user