Update touch driver IDs

This commit is contained in:
fvanroie 2021-11-08 17:30:34 +01:00
parent a874639b7c
commit 52f2692489
16 changed files with 187 additions and 133 deletions

View File

@ -25,8 +25,7 @@
#define PCNT_INPUT_CTRL_IO 36 // Pulse Control GPIO #define PCNT_INPUT_CTRL_IO 36 // Pulse Control GPIO
#define PCNT_FILTER_VAL 300 // filter (damping, inertia) value for avoiding glitches in the count, max. 1023 #define PCNT_FILTER_VAL 300 // filter (damping, inertia) value for avoiding glitches in the count, max. 1023
#define MEASURED_WATTS 1580 #define MEASURED_WATTS 1580
#define MEASURED_PULSES_PER_SECOND 281 #define MEASURED_PULSES_PER_SECOND 281 // Pulses / Per second
// Per second
int16_t PulseCounter = 0; // pulse counter, max. value is 32535 int16_t PulseCounter = 0; // pulse counter, max. value is 32535
int OverflowCounter = 0; // pulse counter overflow counter int OverflowCounter = 0; // pulse counter overflow counter

View File

@ -1,4 +1,4 @@
#if TOUCH_DRIVER == 5206 #if TOUCH_DRIVER == 0x5206
#include <Wire.h> #include <Wire.h>
#include "focaltech.h" #include "focaltech.h"

View File

@ -4,7 +4,7 @@
#ifndef HASP_DRV_FT5206_H #ifndef HASP_DRV_FT5206_H
#define HASP_DRV_FT5206_H #define HASP_DRV_FT5206_H
#if TOUCH_DRIVER == 5206 #if TOUCH_DRIVER == 0x5206
#define FT5206_address 0x38 #define FT5206_address 0x38

View File

@ -1,4 +1,4 @@
#if TOUCH_DRIVER == 6336 #if TOUCH_DRIVER == 0x6336
#include <Wire.h> #include <Wire.h>
#include "FT6336U.h" #include "FT6336U.h"

View File

@ -4,7 +4,7 @@
#ifndef HASP_DRV_FT6336U_H #ifndef HASP_DRV_FT6336U_H
#define HASP_DRV_FT6336U_H #define HASP_DRV_FT6336U_H
#if TOUCH_DRIVER == 6336 #if TOUCH_DRIVER == 0x6336
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR

View File

@ -1,5 +1,5 @@
/* /*
#if TOUCH_DRIVER == 91100 #if TOUCH_DRIVER == 0x091100
#include <Wire.h> #include <Wire.h>
#include "Goodix.h" #include "Goodix.h"

View File

@ -5,7 +5,7 @@
#ifndef HASP_DRV_911_H #ifndef HASP_DRV_911_H
#define HASP_DRV_911_H #define HASP_DRV_911_H
#if TOUCH_DRIVER == 91100 #if TOUCH_DRIVER == 0x091100
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR

View File

@ -1,4 +1,4 @@
#if TOUCH_DRIVER == 610 #if TOUCH_DRIVER == 0x0610
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -4,7 +4,7 @@
#ifndef HASP_DRV_STMPE610_H #ifndef HASP_DRV_STMPE610_H
#define HASP_DRV_STMPE610_H #define HASP_DRV_STMPE610_H
#if TOUCH_DRIVER == 610 #if TOUCH_DRIVER == 0x0610
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR

View File

@ -6,25 +6,25 @@
#include "hasp_drv_touch.h" #include "hasp_drv_touch.h"
#include "drv/tft/tft_driver.h" #include "drv/tft/tft_driver.h"
#if TOUCH_DRIVER == 2046 #if TOUCH_DRIVER == 0x2046
#if defined(USE_FSMC) #if defined(USE_FSMC)
#else #else
#include "drv/old/hasp_drv_tft_espi.h" #include "drv/old/hasp_drv_tft_espi.h"
#endif #endif
#elif TOUCH_DRIVER == 2046 #elif TOUCH_DRIVER == 0x2046
#include "indev/XPT2046.h" #include "indev/XPT2046.h"
#elif TOUCH_DRIVER == 0x2046B #elif TOUCH_DRIVER == 0x2046B
#include "drv/old/hasp_drv_xpt2046.h" #include "drv/old/hasp_drv_xpt2046.h"
#elif TOUCH_DRIVER == 911 #elif TOUCH_DRIVER == 0x0911
#include "drv/old/hasp_drv_gt911.h" #include "drv/old/hasp_drv_gt911.h"
#elif TOUCH_DRIVER == 0xADC #elif TOUCH_DRIVER == 0x0ADC
#include "drv/old/hasp_drv_ft6336u.h" #include "drv/old/hasp_drv_ft6336u.h"
#elif TOUCH_DRIVER == 5206 #elif TOUCH_DRIVER == 0x5206
#include "drv/old/hasp_drv_ft5206.h" #include "drv/old/hasp_drv_ft5206.h"
#elif TOUCH_DRIVER == 6336 #elif TOUCH_DRIVER == 0x6336
#include "drv/old/hasp_drv_ft6336u.h" #include "drv/old/hasp_drv_ft6336u.h"
#elif TOUCH_DRIVER == 610 #elif TOUCH_DRIVER == 0x0610
#include "drv/old/hasp_drv_stmpe610.h" #include "drv/old/hasp_drv_stmpe610.h"
#else #else
//#include "tp_i2c.h" //#include "tp_i2c.h"
@ -54,7 +54,7 @@ void drv_touch_init(uint8_t rotation)
touch_rotate = false; touch_rotate = false;
} }
#if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver #if TOUCH_DRIVER == 0x2046 // XPT2046 Resistive touch panel driver
#if defined(USE_FSMC) #if defined(USE_FSMC)
xpt2046_init(rotation); xpt2046_init(rotation);
#else #else
@ -62,19 +62,19 @@ void drv_touch_init(uint8_t rotation)
// tft_espi_init(rotation); // tft_espi_init(rotation);
#endif #endif
#elif TOUCH_DRIVER == 911 #elif TOUCH_DRIVER == 0x0911
// GT911_init(); // GT911_init();
#elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller #elif TOUCH_DRIVER == 0x0ADC // Analog Digital Touch Conroller
// Touch_init(); // Touch_init();
#elif TOUCH_DRIVER == 5206 #elif TOUCH_DRIVER == 0x5206
FT5206_init(); FT5206_init();
#elif TOUCH_DRIVER == 6336 #elif TOUCH_DRIVER == 0x6336
FT6336U_init(); FT6336U_init();
#elif TOUCH_DRIVER == 610 #elif TOUCH_DRIVER == 0x0610
STMPE610_init(); STMPE610_init();
#else #else
@ -89,26 +89,26 @@ static inline bool drv_touchpad_getXY(int16_t* touchX, int16_t* touchY)
bool touched; bool touched;
int16_t normal_x; int16_t normal_x;
int16_t normal_y; int16_t normal_y;
#if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver #if TOUCH_DRIVER == 0x2046 // XPT2046 Resistive touch panel driver
touched = haspTft.tft.getTouch((uint16_t*)&normal_x, (uint16_t*)&normal_y, 300); touched = haspTft.tft.getTouch((uint16_t*)&normal_x, (uint16_t*)&normal_y, 300);
#elif TOUCH_DRIVER == 0x2046B #elif TOUCH_DRIVER == 0x2046B
touched = XPT2046_getXY(&normal_x, &normal_y, true); touched = XPT2046_getXY(&normal_x, &normal_y, true);
#elif TOUCH_DRIVER == 911 #elif TOUCH_DRIVER == 0x0911
// touched = GT911_getXY(&normal_x, &normal_y, true); // touched = GT911_getXY(&normal_x, &normal_y, true);
#elif TOUCH_DRIVER == 0xADC // Analog Digital Touch Conroller #elif TOUCH_DRIVER == 0x0ADC // Analog Digital Touch Conroller
// touched = Touch_getXY(&normal_x, &normal_y, false); // touched = Touch_getXY(&normal_x, &normal_y, false);
#elif TOUCH_DRIVER == 5206 #elif TOUCH_DRIVER == 0x5206
// WARNING : this library is slooow !! use 6336 instead // WARNING : this library is slooow !! use 6336 instead
touched = FT5206_getXY(&normal_x, &normal_y, false); // no debug touched = FT5206_getXY(&normal_x, &normal_y, false); // no debug
#elif TOUCH_DRIVER == 6336 #elif TOUCH_DRIVER == 0x6336
touched = FT6336U_getXY(&normal_x, &normal_y, false); // no debug touched = FT6336U_getXY(&normal_x, &normal_y, false); // no debug
#elif TOUCH_DRIVER == 610 #elif TOUCH_DRIVER == 0x0610
touched = STMPE610_getXY(&normal_x, &normal_y, drv_touch_rotation, false); // no debug touched = STMPE610_getXY(&normal_x, &normal_y, drv_touch_rotation, false); // no debug
#else #else
@ -220,7 +220,7 @@ IRAM_ATTR bool drv_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* dat
IRAM_ATTR void drv_touch_loop() IRAM_ATTR void drv_touch_loop()
{ {
#if TOUCH_DRIVER == 911 #if TOUCH_DRIVER == 0x0911
// GT911_loop(); // GT911_loop();
#endif #endif
} }

View File

@ -3,6 +3,7 @@
#if defined(ARDUINO) && defined(LGFX_USE_V1) #if defined(ARDUINO) && defined(LGFX_USE_V1)
#include "tft_driver_lovyangfx.h" #include "tft_driver_lovyangfx.h"
#include <Preferences.h>
namespace dev { namespace dev {
@ -31,7 +32,6 @@ static uint32_t _read_panel_id(lgfx::Bus_SPI* bus, int32_t pin_cs, uint32_t cmd
_pin_level(pin_cs, true); _pin_level(pin_cs, true);
LOG_VERBOSE(TAG_TFT, "[Autodetect] read cmd:%u = %u", cmd, res); LOG_VERBOSE(TAG_TFT, "[Autodetect] read cmd:%u = %u", cmd, res);
LOG_VERBOSE(TAG_TFT, "[Autodetect] read cmd:%02x = %08x", cmd, res);
return res; return res;
} }
@ -39,50 +39,35 @@ void LovyanGfx::init(int w, int h)
{ {
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
Preferences preferences;
preferences.begin("gfx", false);
#ifdef USE_DMA_TO_TFT #ifdef USE_DMA_TO_TFT
int dma_channel = 1; // Set the DMA channel (1 or 2. 0=disable) int dma_channel = 1; // Set the DMA channel (1 or 2. 0=disable)
#else #else
int dma_channel = 0; // Set the DMA channel (1 or 2. 0=disable) int dma_channel = 0; // Set the DMA channel (1 or 2. 0=disable)
#endif #endif
uint32_t tft_driver = 0; uint32_t tft_driver = preferences.getUInt("DRIVER", get_tft_driver());
switch(tft_driver) {
#ifdef ILI9341_DRIVER case 0x9341:
tft_driver = 0x9341; tft._panel_instance = new lgfx::Panel_ILI9341();
#endif break;
case 0x9481:
#ifdef ILI9481_DRIVER tft._panel_instance = new lgfx::Panel_ILI9481();
tft_driver = 0x9481; break;
#endif case 0x9488:
tft._panel_instance = new lgfx::Panel_ILI9488();
#ifdef ILI9488_DRIVER break;
tft_driver = 0x9488; case 0x7796:
#endif tft._panel_instance = new lgfx::Panel_ST7796();
break;
#ifdef ST7789_DRIVER case 0x8357D:
tft_driver = 0x7789; tft._panel_instance = new lgfx::Panel_HX8357D();
#endif break;
default: {
#ifdef ST7796_DRIVER LOG_ERROR(TAG_TFT, F("Unknown display driver")); // Needs to be in curly braces
tft_driver = 0x7796; }
#endif
#ifdef HX8357D_DRIVER
tft_driver = 0x8357D; // Adafruit Feather Wing 3.5"
#endif
if(tft_driver == 0x9341)
tft._panel_instance = new lgfx::Panel_ILI9341();
else if(tft_driver == 0x9481)
tft._panel_instance = new lgfx::Panel_ILI9481();
else if(tft_driver == 0x9488)
tft._panel_instance = new lgfx::Panel_ILI9488();
else if(tft_driver == 0x7796)
tft._panel_instance = new lgfx::Panel_ST7796();
else if(tft_driver == 0x8357D)
tft._panel_instance = new lgfx::Panel_HX8357D();
else {
LOG_VERBOSE(TAG_TFT, F("Unknown display driver")); // Needs to be in curly braces
} }
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
@ -103,7 +88,7 @@ void LovyanGfx::init(int w, int h)
cfg.pin_d5 = TFT_D5; cfg.pin_d5 = TFT_D5;
cfg.pin_d6 = TFT_D6; cfg.pin_d6 = TFT_D6;
cfg.pin_d7 = TFT_D7 bus->config(cfg); // 設定値をバスに反映します。 cfg.pin_d7 = TFT_D7 bus->config(cfg); // 設定値をバスに反映します。
tft._panel_instance.setBus(bus); // バスをパネルにセットします。 tft._panel_instance.setBus(bus); // Set the bus on the panel.
} }
#else #else
{ // Set SPI bus control { // Set SPI bus control
@ -113,36 +98,37 @@ void LovyanGfx::init(int w, int h)
cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3) cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3)
cfg.freq_write = SPI_FREQUENCY; // SPI clock during transmission (Max 80MHz, 80MHz Can be rounded to the value cfg.freq_write = SPI_FREQUENCY; // SPI clock during transmission (Max 80MHz, 80MHz Can be rounded to the value
// divided by an integer ) // divided by an integer )
cfg.freq_read = SPI_READ_FREQUENCY; // SPI clock when receiving cfg.freq_read = SPI_READ_FREQUENCY; // SPI clock when receiving
cfg.spi_3wire = false; // Set true when receiving with MOSI pin cfg.spi_3wire = (TFT_MOSI == -1); // true when receiving with MOSI pin
cfg.use_lock = true; // Set to true when using transaction lock cfg.use_lock = true; // Set to true when using transaction lock
cfg.dma_channel = dma_channel; // Set the DMA channel (1 or 2. 0=disable) cfg.dma_channel = dma_channel; // Set the DMA channel (1 or 2. 0=disable)
cfg.pin_sclk = TFT_SCLK; // Set SPI SCLK pin number cfg.pin_sclk = preferences.getChar("SCLK", TFT_SCLK); // Set SPI SCLK pin number
cfg.pin_mosi = TFT_MOSI; // Set SPI MOSI pin number cfg.pin_mosi = preferences.getChar("MOSI", TFT_MOSI); // Set SPI MOSI pin number
cfg.pin_miso = TFT_MISO; // Set SPI MISO pin number (-1 = disable) cfg.pin_miso = preferences.getChar("MISO", TFT_MISO); // Set SPI MISO pin number (-1 = disable)
cfg.pin_dc = TFT_DC; // Set SPI D/C pin number (-1 = disable) cfg.pin_dc = preferences.getChar("DC", TFT_DC); // Set SPI D/C pin number (-1 = disable)
bus->config(cfg); // The set value is reflected on the bus. bus->config(cfg); // The set value is reflected on the bus.
bus->init(); bus->init();
_read_panel_id(bus, TFT_CS, 0x00); int8_t cs = preferences.getChar("CS", TFT_CS);
_read_panel_id(bus, TFT_CS, 0x04); _read_panel_id(bus, cs, 0x00); // NOP
_read_panel_id(bus, TFT_CS, 0x09); _read_panel_id(bus, cs, 0x04); // ST7789/ILI9488: RDDID (04h): Read Display ID
_read_panel_id(bus, TFT_CS, 0xBF); _read_panel_id(bus, cs, 0x09); // ST7789/ILI9488: RDDST (09h): Read Display Status
_read_panel_id(bus, cs, 0xBF); // /ILI9481: Device Code Read
tft._panel_instance->setBus(bus); // Set the bus on the panel. tft._panel_instance->setBus(bus); // Set the bus on the panel.
} }
#endif #endif
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
{ // Set the display panel control. { // Set the display panel control.
auto cfg = tft._panel_instance->config(); // Gets the structure for display panel settings. auto cfg = tft._panel_instance->config(); // Gets the structure for display panel settings.
cfg.pin_cs = TFT_CS; // CS Pin Number (-1 = disable) cfg.pin_cs = preferences.getChar("CS", TFT_CS); // CS Pin Number (-1 = disable)
cfg.pin_rst = TFT_RST; // RST Pin Number (-1 = disable) cfg.pin_rst = preferences.getChar("RST", TFT_RST); // RST Pin Number (-1 = disable)
cfg.pin_busy = -1; // BUSY Pin Number (-1 = disable) cfg.pin_busy = -1; // BUSY Pin Number (-1 = disable)
cfg.memory_width = w; // Maximum width supported by driver IC cfg.memory_width = w; // Maximum width supported by driver IC
cfg.memory_height = h; // Maximum height supported by driver IC cfg.memory_height = h; // Maximum height supported by driver IC
cfg.panel_width = w; // Actually displayable width cfg.panel_width = w; // Actually displayable width
cfg.panel_height = h; // Actually displayable height cfg.panel_height = h; // Actually displayable height
cfg.offset_x = 0; // Amount of X-direction offset of the panel cfg.offset_x = 0; // Amount of X-direction offset of the panel
cfg.offset_y = 0; // Amount of Y-direction offset of the panel cfg.offset_y = 0; // Amount of Y-direction offset of the panel
cfg.offset_rotation = 0; // Offset of values in the direction of rotation 0 ~ 7 (4 ~ 7 are upside down) cfg.offset_rotation = 0; // Offset of values in the direction of rotation 0 ~ 7 (4 ~ 7 are upside down)
cfg.dummy_read_pixel = 8; // Number of dummy read bits before pixel reading cfg.dummy_read_pixel = 8; // Number of dummy read bits before pixel reading
cfg.dummy_read_bits = 1; // Number of bits of dummy read before reading data other than pixels cfg.dummy_read_bits = 1; // Number of bits of dummy read before reading data other than pixels
@ -157,14 +143,14 @@ void LovyanGfx::init(int w, int h)
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
#if 1 #if 0
{ // Set the backlight control. (Delete if not needed) { // Set the backlight control. (Delete if not needed)
auto cfg = tft._light_instance.config(); // Get the backlight structure for configuration. auto cfg = tft._light_instance.config(); // Get the backlight structure for configuration.
cfg.pin_bl = TFT_BCKL; // Backlight Pin Number cfg.pin_bl = preferences.getChar("BCKL", TFT_BCKL); // Backlight Pin Number
cfg.invert = false; // True if you want to invert the brightness of the Backlight cfg.invert = false; // True if you want to invert the brightness of the Backlight
cfg.freq = 44100; // Backlight PWM frequency cfg.freq = 44100; // Backlight PWM frequency
cfg.pwm_channel = 0; // PWM channel number to use cfg.pwm_channel = 0; // PWM channel number to use
tft._light_instance.config(cfg); tft._light_instance.config(cfg);
tft._panel_instance->setLight(&tft._light_instance); // Set the Backlight on the panel. tft._panel_instance->setLight(&tft._light_instance); // Set the Backlight on the panel.
@ -173,13 +159,31 @@ void LovyanGfx::init(int w, int h)
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
tft._touch_instance = new lgfx::Touch_FT5x06(); uint32_t touch_driver = preferences.getUInt("T_DRIVER", get_touch_driver());
{ // Set the touch screen control. (Delete if not needed) switch(touch_driver) {
case 0x0911:
tft._touch_instance = new lgfx::Touch_GT911();
break;
case 0x5206:
case 0x6336:
tft._touch_instance = new lgfx::Touch_FT5x06();
break;
case 0x2046:
tft._touch_instance = new lgfx::Touch_XPT2046();
break;
case 0x0610:
tft._touch_instance = new lgfx::Touch_STMPE610();
break;
default: {
LOG_ERROR(TAG_TFT, F("Unknown touch driver")); // Needs to be in curly braces
};
}
if(touch_driver == 0x2046 || touch_driver == 0x0610) { // Set the touch screen control. (Delete if not needed)
auto cfg = tft._touch_instance->config(); auto cfg = tft._touch_instance->config();
cfg.pin_int = TOUCH_IRQ; // INT Pin Number cfg.pin_int = TOUCH_IRQ; // INT Pin Number
cfg.offset_rotation = 0; // Adjustment when the display and touch orientation do not match: cfg.offset_rotation = 0; // Adjustment when the display and touch orientation do not match:
// Set with a value from 0 to 7 // Set with a value from 0 to 7
#if(TOUCH_DRIVER == 2046) || (TOUCH_DRIVER == 610)
cfg.bus_shared = true; // Set to true if you are using the same bus as the screen cfg.bus_shared = true; // Set to true if you are using the same bus as the screen
cfg.spi_host = HSPI_HOST; // Select the SPI to use (HSPI_HOST or VSPI_HOST) cfg.spi_host = HSPI_HOST; // Select the SPI to use (HSPI_HOST or VSPI_HOST)
cfg.pin_sclk = TFT_SCLK; // SCLK Pin Number cfg.pin_sclk = TFT_SCLK; // SCLK Pin Number
@ -192,7 +196,16 @@ void LovyanGfx::init(int w, int h)
cfg.y_min = 0; // Minimum Y value (raw value) obtained from touch screen cfg.y_min = 0; // Minimum Y value (raw value) obtained from touch screen
cfg.y_max = h - 1; // Maximum Y value (raw value) obtained from touch screen cfg.y_max = h - 1; // Maximum Y value (raw value) obtained from touch screen
#elif(TOUCH_DRIVER == 911) || (TOUCH_DRIVER == 6336) tft._touch_instance->config(cfg);
tft._panel_instance->setTouch(tft._touch_instance); // Set the touch screen on the panel.
}
if(touch_driver == 0x6336 || touch_driver == 0x5206 ||
touch_driver == 0x0911) { // Set the touch screen control. (Delete if not needed)
auto cfg = tft._touch_instance->config();
cfg.pin_int = TOUCH_IRQ; // INT Pin Number
cfg.offset_rotation = 0; // Adjustment when the display and touch orientation do not match:
cfg.bus_shared = false; // Set to true if you are using the same bus as the screen cfg.bus_shared = false; // Set to true if you are using the same bus as the screen
cfg.pin_sda = TOUCH_SDA; cfg.pin_sda = TOUCH_SDA;
cfg.pin_scl = TOUCH_SCL; cfg.pin_scl = TOUCH_SCL;
@ -203,13 +216,13 @@ void LovyanGfx::init(int w, int h)
cfg.x_max = w - 1; // Maximum X value (raw value) obtained from touch screen cfg.x_max = w - 1; // Maximum X value (raw value) obtained from touch screen
cfg.y_min = 0; // Minimum Y value (raw value) obtained from touch screen cfg.y_min = 0; // Minimum Y value (raw value) obtained from touch screen
cfg.y_max = h - 1; // Maximum Y value (raw value) obtained from touch screen cfg.y_max = h - 1; // Maximum Y value (raw value) obtained from touch screen
#endif
tft._touch_instance->config(cfg); tft._touch_instance->config(cfg);
tft._panel_instance->setTouch(tft._touch_instance); // Set the touch screen on the panel. tft._panel_instance->setTouch(tft._touch_instance); // Set the touch screen on the panel.
} }
tft.setPanel(tft._panel_instance); // Set the panel to be used.
tft.setPanel(tft._panel_instance); // Set the panel to be used.
LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
preferences.end();
/* TFT init */ /* TFT init */
tft.begin(); tft.begin();
@ -224,10 +237,9 @@ void LovyanGfx::show_info()
LOG_VERBOSE(TAG_TFT, F("LovyanGFX : v%d.%d.%d"), LGFX_VERSION_MAJOR, LGFX_VERSION_MINOR, LGFX_VERSION_PATCH); LOG_VERBOSE(TAG_TFT, F("LovyanGFX : v%d.%d.%d"), LGFX_VERSION_MAJOR, LGFX_VERSION_MINOR, LGFX_VERSION_PATCH);
// LOG_VERBOSE(TAG_TFT, F("Transactns : %s"), (tftSetup.trans == 1) ? PSTR(D_YES) : PSTR(D_NO));
// LOG_VERBOSE(TAG_TFT, F("Interface : %s"), (tftSetup.serial == 1) ? PSTR("SPI") : PSTR("Parallel"));
#ifdef ESP32_PARALLEL #ifdef ESP32_PARALLEL
{ {
LOG_VERBOSE(TAG_TFT, F("Interface : Parallel"));
auto bus = (lgfx::v1::Bus_Parallel8*)tft._bus_instance; auto bus = (lgfx::v1::Bus_Parallel8*)tft._bus_instance;
auto cfg = bus->config(); // Get the structure for bus configuration. auto cfg = bus->config(); // Get the structure for bus configuration.
tftPinInfo(F("TFT_WR"), cfg.pin_wr); tftPinInfo(F("TFT_WR"), cfg.pin_wr);
@ -245,6 +257,7 @@ void LovyanGfx::show_info()
} }
#else #else
{ {
LOG_VERBOSE(TAG_TFT, F("Interface : Serial"));
auto bus = (lgfx::v1::Bus_SPI*)tft._bus_instance; auto bus = (lgfx::v1::Bus_SPI*)tft._bus_instance;
auto cfg = bus->config(); // Get the structure for bus configuration. auto cfg = bus->config(); // Get the structure for bus configuration.
tftPinInfo(F("MOSI"), cfg.pin_mosi); tftPinInfo(F("MOSI"), cfg.pin_mosi);
@ -285,15 +298,6 @@ void LovyanGfx::show_info()
LOG_VERBOSE(TAG_TFT, F("Touch I2C freq. : %d.%d MHz"), freq / 10, freq % 10); LOG_VERBOSE(TAG_TFT, F("Touch I2C freq. : %d.%d MHz"), freq / 10, freq % 10);
} }
} }
// if(tftSetup.serial == 1) {
// LOG_VERBOSE(TAG_TFT, F("Display SPI freq. : %d.%d MHz"), tftSetup.tft_spi_freq / 10,
// tftSetup.tft_spi_freq % 10);
// }
// if(tftSetup.pin_tch_cs != -1) {
// LOG_VERBOSE(TAG_TFT, F("Touch SPI freq. : %d.%d MHz"), tftSetup.tch_spi_freq / 10,
// tftSetup.tch_spi_freq % 10);
// }
} }
void LovyanGfx::splashscreen() void LovyanGfx::splashscreen()
@ -471,6 +475,50 @@ const char* LovyanGfx::get_tft_model()
#endif #endif
} }
uint32_t LovyanGfx::get_tft_driver()
{
#if defined(ILI9341_DRIVER)
return 0x9341;
#elif defined(ST7735_DRIVER)
return 0x7735;
#elif defined(ILI9163_DRIVER)
return 0x9163;
#elif defined(S6D02A1_DRIVER)
return 0x6D02A1;
#elif defined(ST7796_DRIVER)
return 0x7796;
#elif defined(ILI9486_DRIVER)
return 0x9486;
#elif defined(ILI9481_DRIVER)
return 0x9481;
#elif defined(ILI9488_DRIVER)
return 0x9488;
#elif defined(HX8357D_DRIVER)
return 0x8357D;
#elif defined(EPD_DRIVER)
return 0xED;
#elif defined(ST7789_DRIVER)
return 0x7789;
#elif defined(R61581_DRIVER)
return 0x61581;
#elif defined(ST7789_2_DRIVER)
return 0x77892;
#elif defined(RM68140_DRIVER)
return 0x68140;
#else
return 0;
#endif
}
uint32_t LovyanGfx::get_touch_driver()
{
#ifdef TOUCH_DRIVER
return TOUCH_DRIVER > 0 ? TOUCH_DRIVER : 0;
#else
return 0;
#endif
}
} // namespace dev } // namespace dev
dev::LovyanGfx haspTft; dev::LovyanGfx haspTft;

View File

@ -21,6 +21,10 @@
#include "custom/bootlogo_template.h" // Sketch tab header for xbm images #include "custom/bootlogo_template.h" // Sketch tab header for xbm images
#endif #endif
#ifndef TOUCH_CS
#define TOUCH_CS -1
#endif
#ifndef TOUCH_IRQ #ifndef TOUCH_IRQ
#define TOUCH_IRQ -1 #define TOUCH_IRQ -1
#endif #endif
@ -34,7 +38,7 @@ class LGFX : public lgfx::LGFX_Device {
lgfx::Light_PWM _light_instance; lgfx::Light_PWM _light_instance;
lgfx::ITouch* _touch_instance; lgfx::ITouch* _touch_instance;
LGFX(void) LGFX(void)
{ {
_bus_instance = new lgfx::v1::Bus_SPI(); _bus_instance = new lgfx::v1::Bus_SPI();
} }
@ -58,6 +62,9 @@ class LovyanGfx : BaseTft {
const char* get_tft_model(); const char* get_tft_model();
private: private:
uint32_t get_tft_driver();
uint32_t get_touch_driver();
void tftOffsetInfo(uint8_t pin, uint8_t x_offset, uint8_t y_offset) void tftOffsetInfo(uint8_t pin, uint8_t x_offset, uint8_t y_offset)
{ {
if(x_offset != 0) { if(x_offset != 0) {

View File

@ -51,23 +51,23 @@ class BaseTouch {
#if defined(LGFX_USE_V1) #if defined(LGFX_USE_V1)
#warning Building for LovyanGfx Touch #warning Building for LovyanGfx Touch
#include "touch_driver_lovyangfx.h" #include "touch_driver_lovyangfx.h"
#elif TOUCH_DRIVER == 2046 && defined(USER_SETUP_LOADED) #elif TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED)
#warning Building for XPT2046 #warning Building for XPT2046
//#include "touch_driver_xpt2046.h" //#include "touch_driver_xpt2046.h"
#include "touch_driver_tftespi.h" #include "touch_driver_tftespi.h"
#elif TOUCH_DRIVER == 5206 #elif TOUCH_DRIVER == 0x5206
#warning Building for FT5206 #warning Building for FT5206
#include "touch_driver_ft5206.h" #include "touch_driver_ft5206.h"
#elif TOUCH_DRIVER == 6336 #elif TOUCH_DRIVER == 0x6336
#warning Building for FT6336 #warning Building for FT6336
#include "touch_driver_ft6336u.h" #include "touch_driver_ft6336u.h"
#elif TOUCH_DRIVER == 610 #elif TOUCH_DRIVER == 0x0610
#warning Building for STMPE610 #warning Building for STMPE610
#include "touch_driver_stmpe610.h" #include "touch_driver_stmpe610.h"
#elif TOUCH_DRIVER == 911 #elif TOUCH_DRIVER == 0x0911
#warning Building for GT911 #warning Building for GT911
#include "touch_driver_gt911.h" #include "touch_driver_gt911.h"
#elif TOUCH_DRIVER == 0xADC #elif TOUCH_DRIVER == 0x0ADC
#warning Building for analog touch #warning Building for analog touch
#include "touch_driver_analog.h" #include "touch_driver_analog.h"
#else #else

View File

@ -104,7 +104,7 @@ IRAM_ATTR bool gui_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* dat
void guiCalibrate(void) void guiCalibrate(void)
{ {
#if TOUCH_DRIVER == 2046 && defined(USER_SETUP_LOADED) #if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED)
#ifdef TOUCH_CS #ifdef TOUCH_CS
haspTouch.calibrate(gui_settings.cal_data); haspTouch.calibrate(gui_settings.cal_data);
#endif #endif
@ -202,7 +202,7 @@ void guiSetup()
PSTR(LVGL_VERSION_INFO)); PSTR(LVGL_VERSION_INFO));
/* Initialize the LVGL display driver with correct orientation */ /* Initialize the LVGL display driver with correct orientation */
#if(TOUCH_DRIVER == 2046) || defined(LGFX_USE_V1) // Use native display driver to rotate display and touch #if(TOUCH_DRIVER == 0x2046) || defined(LGFX_USE_V1) // Use native display driver to rotate display and touch
static lv_disp_drv_t disp_drv; static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); lv_disp_drv_init(&disp_drv);
disp_drv.buffer = &disp_buf; disp_drv.buffer = &disp_buf;
@ -458,7 +458,7 @@ bool guiGetConfig(const JsonObject& settings)
} else { } else {
changed = true; changed = true;
#if TOUCH_DRIVER == 2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS) #if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
// tft_espi_set_touch(gui_settings.cal_data); // tft_espi_set_touch(gui_settings.cal_data);
haspTft.tft.setTouch(gui_settings.cal_data); haspTft.tft.setTouch(gui_settings.cal_data);
#endif #endif
@ -474,7 +474,7 @@ bool guiGetConfig(const JsonObject& settings)
} }
changed = true; changed = true;
#if TOUCH_DRIVER == 2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS) #if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
// tft_espi_set_touch(gui_settings.cal_data); // tft_espi_set_touch(gui_settings.cal_data);
haspTft.tft.setTouch(gui_settings.cal_data); haspTft.tft.setTouch(gui_settings.cal_data);
#endif #endif
@ -544,7 +544,7 @@ bool guiSetConfig(const JsonObject& settings)
oobeSetAutoCalibrate(true); oobeSetAutoCalibrate(true);
} }
#if TOUCH_DRIVER == 2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS) #if TOUCH_DRIVER == 0x2046 && defined(USER_SETUP_LOADED) && defined(TOUCH_CS)
if(status) // tft_espi_set_touch(gui_settings.cal_data); if(status) // tft_espi_set_touch(gui_settings.cal_data);
haspTft.tft.setTouch(gui_settings.cal_data); haspTft.tft.setTouch(gui_settings.cal_data);
#endif #endif

View File

@ -1359,7 +1359,7 @@ void webHandleGuiConfig()
httpMessage += F("<button type='submit' name='save' value='gui'>" D_HTTP_SAVE_SETTINGS "</button>"); httpMessage += F("<button type='submit' name='save' value='gui'>" D_HTTP_SAVE_SETTINGS "</button>");
httpMessage += F("</form></div>"); httpMessage += F("</form></div>");
#if TOUCH_DRIVER == 2046 && defined(TOUCH_CS) #if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS)
add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui?cal=1"), F("name='cal' value='1'")); add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui?cal=1"), F("name='cal' value='1'"));
#endif #endif

View File

@ -1334,7 +1334,7 @@ void webHandleGuiConfig(AsyncWebServerRequest* request)
// httpMessage += // httpMessage +=
// F("<p><button type='submit' name='save' value='gui'>" D_HTTP_SAVE_SETTINGS "</button></p></form>"); // F("<p><button type='submit' name='save' value='gui'>" D_HTTP_SAVE_SETTINGS "</button></p></form>");
#if TOUCH_DRIVER == 2046 && defined(TOUCH_CS) #if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS)
add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui"), F("name='cal' value='1'")); add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui"), F("name='cal' value='1'"));
#endif #endif