mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 04:06:47 +00:00
Restructure touch drivers
This commit is contained in:
parent
156814b79c
commit
df91cacfcc
@ -9,7 +9,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define ADC_MAX 4095 // maximum value for ESP32 ADC (default 11db, 12 bits)
|
#define ADC_MAX 4095 // maximum value for ESP32 ADC (default 11db, 12 bits)
|
||||||
#define aXM TOUCH_anDC // analog input pin connected to LCD_RS
|
#define aXM TOUCH_anDC // analog input pin connected to LCD_RS
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_BASE_TFT_DRIVER_H
|
#define HASP_BASE_TFT_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_LOVYANGFX_DRIVER_H
|
#define HASP_LOVYANGFX_DRIVER_H
|
||||||
|
|
||||||
#if defined(ARDUINO) && defined(LGFX_USE_V1)
|
#if defined(ARDUINO) && defined(LGFX_USE_V1)
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "LovyanGFX.hpp"
|
#include "LovyanGFX.hpp"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_TFTESPI_DRIVER_H
|
#define HASP_TFTESPI_DRIVER_H
|
||||||
|
|
||||||
#if defined(ARDUINO) && defined(USER_SETUP_LOADED)
|
#if defined(ARDUINO) && defined(USER_SETUP_LOADED)
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "TFT_eSPI.h"
|
#include "TFT_eSPI.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_BASE_TOUCH_DRIVER_H
|
#define HASP_BASE_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hasplib.h"
|
#include "hasplib.h"
|
||||||
@ -27,6 +27,7 @@ class BaseTouch {
|
|||||||
{}
|
{}
|
||||||
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
{
|
||||||
|
data->state = LV_INDEV_STATE_REL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void calibrate(uint16_t* calData)
|
void calibrate(uint16_t* calData)
|
||||||
@ -70,11 +71,11 @@ class BaseTouch {
|
|||||||
#warning Building for Generic Touch
|
#warning Building for Generic Touch
|
||||||
using dev::BaseTouch;
|
using dev::BaseTouch;
|
||||||
extern dev::BaseTouch haspTouch;
|
extern dev::BaseTouch haspTouch;
|
||||||
IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
// IRAM_ATTR bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
// {
|
||||||
data->state = LV_INDEV_STATE_REL;
|
// data->state = LV_INDEV_STATE_REL;
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#include "../old/hasp_drv_analogTouch.h"
|
#include "../old/hasp_drv_analogTouch.h"
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
#define HASP_FT6336T_TOUCH_DRIVER_H
|
#define HASP_FT6336T_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include "hasp_conf.h"
|
||||||
#include "lvgl.h"
|
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "FT6336U.h"
|
#include "FT6336U.h"
|
||||||
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
#include "touch_driver.h" // base class
|
#include "touch_driver.h" // base class
|
||||||
#include "touch_helper.h" // i2c scanner
|
#include "touch_helper.h" // i2c scanner
|
||||||
@ -19,8 +20,6 @@ extern uint8_t hasp_sleep_state;
|
|||||||
|
|
||||||
#define RST_PIN (TOUCH_RST) // -1 if pin is connected to VCC else set pin number
|
#define RST_PIN (TOUCH_RST) // -1 if pin is connected to VCC else set pin number
|
||||||
|
|
||||||
FT6336U* ft6336u_touch;
|
|
||||||
|
|
||||||
// Read touch points
|
// Read touch points
|
||||||
// HASP_ATTRIBUTE_FAST_MEM bool FT6336U_getXY(int16_t* touchX, int16_t* touchY)
|
// HASP_ATTRIBUTE_FAST_MEM bool FT6336U_getXY(int16_t* touchX, int16_t* touchY)
|
||||||
// {
|
// {
|
||||||
@ -56,6 +55,25 @@ namespace dev {
|
|||||||
class TouchFt6336u : public BaseTouch {
|
class TouchFt6336u : public BaseTouch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
FT6336U* ft6336u_touch;
|
||||||
|
|
||||||
|
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
|
{
|
||||||
|
if(ft6336u_touch->read_touch_number() == 1) {
|
||||||
|
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
|
||||||
|
|
||||||
|
data->point.x = ft6336u_touch->read_touch1_x();
|
||||||
|
data->point.y = ft6336u_touch->read_touch1_y();
|
||||||
|
data->state = LV_INDEV_STATE_PR;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Return `false` because we are not buffering and no more data to read*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void init(int w, int h)
|
void init(int w, int h)
|
||||||
{
|
{
|
||||||
LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA);
|
LOG_INFO(TAG_DRVR, F("Touch SDA : %d"), TOUCH_SDA);
|
||||||
@ -86,30 +104,13 @@ class TouchFt6336u : public BaseTouch {
|
|||||||
LOG_ERROR(TAG_DRVR, F("FT6336U touch driver failed to start"));
|
LOG_ERROR(TAG_DRVR, F("FT6336U touch driver failed to start"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
|
||||||
{
|
|
||||||
if(ft6336u_touch->read_touch_number() == 1) {
|
|
||||||
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
|
|
||||||
|
|
||||||
data->point.x = ft6336u_touch->read_touch1_x();
|
|
||||||
data->point.y = ft6336u_touch->read_touch1_y();
|
|
||||||
data->state = LV_INDEV_STATE_PR;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
data->state = LV_INDEV_STATE_REL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Return `false` because we are not buffering and no more data to read*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dev
|
} // namespace dev
|
||||||
|
|
||||||
#warning Using FT6336
|
#warning Using FT6336
|
||||||
using dev::TouchFt6336u;
|
using dev::TouchFt6336u;
|
||||||
extern dev::TouchFt6336u haspTouch;
|
dev::TouchFt6336u haspTouch;
|
||||||
|
|
||||||
#endif // ARDUINO
|
#endif // ARDUINO
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "Goodix.h"
|
#include "Goodix.h"
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_LOVYANGFX_TOUCH_DRIVER_H
|
#define HASP_LOVYANGFX_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "touch_driver.h" // base class
|
#include "touch_driver.h" // base class
|
||||||
#include "dev/device.h" // for haspTft
|
#include "dev/device.h" // for haspTft
|
||||||
@ -33,7 +33,7 @@ namespace dev {
|
|||||||
class TouchLovyanGfx : public BaseTouch {
|
class TouchLovyanGfx : public BaseTouch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
{
|
||||||
int16_t touchX = 0;
|
int16_t touchX = 0;
|
||||||
int16_t touchY = 0;
|
int16_t touchY = 0;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_STMPE610_TOUCH_DRIVER_H
|
#define HASP_STMPE610_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include "Adafruit_STMPE610.h"
|
#include "Adafruit_STMPE610.h"
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
@ -23,8 +23,6 @@ extern uint8_t hasp_sleep_state;
|
|||||||
#define TS_MINY 100
|
#define TS_MINY 100
|
||||||
#define TS_MAXY 3750
|
#define TS_MAXY 3750
|
||||||
|
|
||||||
static Adafruit_STMPE610 stmpe610_touchpanel = Adafruit_STMPE610(TOUCH_CS);
|
|
||||||
|
|
||||||
// bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
// bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
// {
|
// {
|
||||||
// data->state = LV_INDEV_STATE_REL;
|
// data->state = LV_INDEV_STATE_REL;
|
||||||
@ -58,6 +56,8 @@ namespace dev {
|
|||||||
class TouchStmpe610 : public BaseTouch {
|
class TouchStmpe610 : public BaseTouch {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Adafruit_STMPE610 stmpe610_touchpanel = Adafruit_STMPE610(TOUCH_CS);
|
||||||
|
|
||||||
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
{
|
||||||
data->state = LV_INDEV_STATE_REL;
|
data->state = LV_INDEV_STATE_REL;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_TFTESPI_TOUCH_DRIVER_H
|
#define HASP_TFTESPI_TOUCH_DRIVER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "touch_driver.h" // base class
|
#include "touch_driver.h" // base class
|
||||||
#include "dev/device.h" // for haspTft
|
#include "dev/device.h" // for haspTft
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define HASP_TOUCH_HELPER_H
|
#define HASP_TOUCH_HELPER_H
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
#include "hasp_debug.h"
|
#include "hasp_debug.h"
|
||||||
|
@ -93,7 +93,7 @@ IRAM_ATTR void gui_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color
|
|||||||
|
|
||||||
IRAM_ATTR bool gui_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
IRAM_ATTR bool gui_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||||
{
|
{
|
||||||
// return haspTouch.read(indev_driver, data);
|
return haspTouch.read(indev_driver, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void guiCalibrate(void)
|
void guiCalibrate(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user