mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-04-19 12:57:19 +00:00
The addition of support for T-Panel (verified).
This commit is contained in:
parent
355e1dbdda
commit
52861a6a5d
43
boards/esp32s3_flash_16MB.json
Normal file
43
boards/esp32s3_flash_16MB.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DARDUINO_ESP32S3_DEV",
|
||||
"-DARDUINO_USB_MODE=1",
|
||||
"-DARDUINO_RUNNING_CORE=1",
|
||||
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||
],
|
||||
"f_cpu": "240000000L",
|
||||
"f_flash": "80000000L",
|
||||
"flash_mode": "qio",
|
||||
"mcu": "esp32s3",
|
||||
"variant": "esp32s3"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi"
|
||||
],
|
||||
"debug": {
|
||||
"default_tool": "esp-builtin",
|
||||
"onboard_tools": [
|
||||
"esp-builtin"
|
||||
],
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "ESP32-S3-FLASH-16MB",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 327680,
|
||||
"maximum_size": 16777216,
|
||||
"require_upload_port": true,
|
||||
"speed": 921600
|
||||
},
|
||||
"url": "null",
|
||||
"vendor": "null"
|
||||
}
|
@ -265,6 +265,136 @@ static const uint8_t st7701_sensecap_indicator_init_operations[] = {
|
||||
DELAY, 120,
|
||||
};
|
||||
|
||||
static const uint8_t st7701_t_panel_init_operations[] = {
|
||||
|
||||
BEGIN_WRITE,
|
||||
WRITE_COMMAND_8, 0xFF,
|
||||
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
|
||||
|
||||
WRITE_C8_D8, 0xEF, 0x08,
|
||||
|
||||
WRITE_COMMAND_8, 0xFF,
|
||||
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
|
||||
|
||||
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
|
||||
WRITE_C8_D16, 0xC1, 0x0B, 0x02,
|
||||
|
||||
WRITE_COMMAND_8, 0xC2,
|
||||
WRITE_BYTES, 3, 0x30, 0x02, 0x37,
|
||||
|
||||
WRITE_C8_D8, 0xCC, 0x10,
|
||||
|
||||
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
|
||||
WRITE_BYTES, 16,
|
||||
0x00, 0x0F, 0x16, 0x0E,
|
||||
0x11, 0x07, 0x09, 0x09,
|
||||
0x08, 0x23, 0x05, 0x11,
|
||||
0x0F, 0x28, 0x2D, 0x18,
|
||||
|
||||
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
|
||||
WRITE_BYTES, 16,
|
||||
0x00, 0x0F, 0x16, 0x0E,
|
||||
0x11, 0x07, 0x09, 0x08,
|
||||
0x09, 0x23, 0x05, 0x11,
|
||||
0x0F, 0x28, 0x2D, 0x18,
|
||||
|
||||
WRITE_COMMAND_8, 0xFF,
|
||||
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
|
||||
|
||||
WRITE_C8_D8, 0xB0, 0x4D,
|
||||
WRITE_C8_D8, 0xB1, 0x33,
|
||||
WRITE_C8_D8, 0xB2, 0x87,
|
||||
WRITE_C8_D8, 0xB5, 0x4B,
|
||||
WRITE_C8_D8, 0xB7, 0x8C,
|
||||
WRITE_C8_D8, 0xB8, 0x20,
|
||||
WRITE_C8_D8, 0xC1, 0x78,
|
||||
WRITE_C8_D8, 0xC2, 0x78,
|
||||
WRITE_C8_D8, 0xD0, 0x88,
|
||||
|
||||
WRITE_COMMAND_8, 0xE0,
|
||||
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
|
||||
|
||||
WRITE_COMMAND_8, 0xE1,
|
||||
WRITE_BYTES, 11,
|
||||
0x02, 0xF0, 0x00, 0x00,
|
||||
0x03, 0xF0, 0x00, 0x00,
|
||||
0x00, 0x44, 0x44,
|
||||
|
||||
WRITE_COMMAND_8, 0xE2,
|
||||
WRITE_BYTES, 12,
|
||||
0x10, 0x10, 0x40, 0x40,
|
||||
0xF2, 0xF0, 0x00, 0x00,
|
||||
0xF2, 0xF0, 0x00, 0x00,
|
||||
|
||||
WRITE_COMMAND_8, 0xE3,
|
||||
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
|
||||
|
||||
WRITE_C8_D16, 0xE4, 0x44, 0x44,
|
||||
|
||||
WRITE_COMMAND_8, 0xE5,
|
||||
WRITE_BYTES, 16,
|
||||
0x07, 0xEF, 0xF0, 0xF0,
|
||||
0x09, 0xF1, 0xF0, 0xF0,
|
||||
0x03, 0xF3, 0xF0, 0xF0,
|
||||
0x05, 0xED, 0xF0, 0xF0,
|
||||
|
||||
WRITE_COMMAND_8, 0xE6,
|
||||
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
|
||||
|
||||
WRITE_C8_D16, 0xE7, 0x44, 0x44,
|
||||
|
||||
WRITE_COMMAND_8, 0xE8,
|
||||
WRITE_BYTES, 16,
|
||||
0x08, 0xF0, 0xF0, 0xF0,
|
||||
0x0A, 0xF2, 0xF0, 0xF0,
|
||||
0x04, 0xF4, 0xF0, 0xF0,
|
||||
0x06, 0xEE, 0xF0, 0xF0,
|
||||
|
||||
WRITE_COMMAND_8, 0xEB,
|
||||
WRITE_BYTES, 7,
|
||||
0x00, 0x00, 0xE4, 0xE4,
|
||||
0x44, 0x88, 0x40,
|
||||
|
||||
WRITE_C8_D16, 0xEC, 0x78, 0x00,
|
||||
|
||||
WRITE_COMMAND_8, 0xED,
|
||||
WRITE_BYTES, 16,
|
||||
0x20, 0xF9, 0x87, 0x76,
|
||||
0x65, 0x54, 0x4F, 0xFF,
|
||||
0xFF, 0xF4, 0x45, 0x56,
|
||||
0x67, 0x78, 0x9F, 0x02,
|
||||
|
||||
WRITE_COMMAND_8, 0xEF,
|
||||
WRITE_BYTES, 6,
|
||||
0x10, 0x0D, 0x04, 0x08,
|
||||
0x3F, 0x1F,
|
||||
|
||||
// WRITE_C8_D8, 0xCD, 0x05,//Test
|
||||
|
||||
WRITE_C8_D8, 0x3A, 0x55,
|
||||
|
||||
WRITE_C8_D8, 0x36, 0x08,
|
||||
|
||||
WRITE_COMMAND_8, 0x11,
|
||||
|
||||
// WRITE_COMMAND_8, 0xFF,//Test
|
||||
// WRITE_BYTES, 5,
|
||||
// 0x77, 0x01, 0x00, 0x00,
|
||||
// 0x12,
|
||||
|
||||
// WRITE_C8_D8, 0xD1, 0x81,//Test
|
||||
// WRITE_C8_D8, 0xD2, 0x08,//Test
|
||||
|
||||
WRITE_COMMAND_8, 0x29, // Display On
|
||||
|
||||
// WRITE_C8_D8, 0x35, 0x00,//Test
|
||||
// WRITE_C8_D8, 0xCE, 0x04,//Test
|
||||
|
||||
// WRITE_COMMAND_8, 0xF2,//Test
|
||||
// WRITE_BYTES, 4,
|
||||
// 0xF0, 0xA3, 0xA3, 0x71,
|
||||
|
||||
END_WRITE};
|
||||
|
||||
class Arduino_RGB_Display_Mod : public Arduino_GFX{
|
||||
public:
|
||||
|
@ -37,8 +37,9 @@ void ArduinoGfx::init(int w, int h)
|
||||
);
|
||||
|
||||
#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_PANEL)
|
||||
Wire.begin(17, 18);
|
||||
Arduino_DataBus* bus = new Arduino_XL9535SWSPI(17 /* SDA */, 18 /* SCL */, -1 /* XL PWD */, 17 /* XL CS */,
|
||||
15 /* XL SCK */, 16 /* XL MOSI */);
|
||||
15 /* XL SCK */, 16 /* XL MOSI */,&Wire);
|
||||
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
|
||||
-1 /* DE */, TFT_VSYNC /* VSYNC */, TFT_HSYNC /* HSYNC */, TFT_PCLK /* PCLK */,
|
||||
TFT_B0 /* B0 */, TFT_B1 /* B1 */, TFT_B2 /* B2 */, TFT_B3 /* B3 */, TFT_B4 /* B4 */,
|
||||
@ -50,7 +51,7 @@ void ArduinoGfx::init(int w, int h)
|
||||
0 /* de_idle_high*/, 0 /* pclk_idle_high */);
|
||||
|
||||
tft = new Arduino_RGB_Display(TFT_WIDTH /* width */, TFT_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
|
||||
bus, -1 /* RST */, st7701_sensecap_indicator_init_operations, sizeof(st7701_sensecap_indicator_init_operations));
|
||||
bus, -1 /* RST */, st7701_t_panel_init_operations, sizeof(st7701_t_panel_init_operations));
|
||||
|
||||
#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_RGB)
|
||||
Wire.begin(8 /* SDA */, 48 /* SCL */, 800000L /* speed */);
|
||||
|
@ -90,6 +90,9 @@ class BaseTouch {
|
||||
#elif defined(LGFX_USE_V1)
|
||||
#warning Building for LovyanGfx Touch
|
||||
#include "touch_driver_lovyangfx.h"
|
||||
#elif TOUCH_DRIVER == 0x3240
|
||||
#warning Building for CST3240
|
||||
#include "touch_driver_cst3240.h"
|
||||
#else
|
||||
#warning Building for Generic Touch
|
||||
using dev::BaseTouch;
|
||||
|
72
src/drv/touch/touch_driver_cst3240.cpp
Normal file
72
src/drv/touch/touch_driver_cst3240.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#if defined(ARDUINO) && (TOUCH_DRIVER == 0x3240) && !defined(HASP_USE_LGFX_TOUCH)
|
||||
#include <Arduino.h>
|
||||
#include "ArduinoLog.h"
|
||||
#include "hasp_conf.h"
|
||||
#include "touch_driver_cst3240.h"
|
||||
|
||||
#include <Wire.h>
|
||||
#include "TouchLib.h"
|
||||
|
||||
#include "touch_driver.h" // base class
|
||||
#include "touch_helper.h" // i2c scanner
|
||||
|
||||
#include "../../hasp/hasp.h" // for hasp_sleep_state
|
||||
extern uint8_t hasp_sleep_state;
|
||||
|
||||
TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_ADDRESS);
|
||||
|
||||
namespace dev {
|
||||
|
||||
IRAM_ATTR bool TouchCst3240::read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
|
||||
{
|
||||
touch.read();
|
||||
TP_Point t = touch.getPoint(0);
|
||||
|
||||
if((touch.getPointNum() == 1) && (t.pressure > 0) && (t.state != 0)) {
|
||||
|
||||
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
|
||||
|
||||
#ifdef TOUCH_WIDTH
|
||||
data->point.x = map(t.x, 0, TOUCH_WIDTH - 1, 0, TFT_WIDTH - 1);
|
||||
#else
|
||||
data->point.x = t.x;
|
||||
#endif
|
||||
|
||||
#ifdef TOUCH_HEIGHT
|
||||
data->point.y = map(t.y, 0, TOUCH_HEIGHT - 1, 0, TFT_HEIGHT - 1);
|
||||
#else
|
||||
data->point.y = t.y;
|
||||
#endif
|
||||
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
hasp_set_sleep_offset(0); // Reset the offset
|
||||
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
/*Return `false` because we are not buffering and no more data to read*/
|
||||
return false;
|
||||
}
|
||||
|
||||
void TouchCst3240::init(int w, int h)
|
||||
{
|
||||
Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY);
|
||||
if(touch.init() == true) {
|
||||
LOG_INFO(TAG_DRVR, "CST3240 %s (480x480)", D_SERVICE_STARTED);
|
||||
} else {
|
||||
LOG_WARNING(TAG_DRVR, "CST3240 %s", D_SERVICE_START_FAILED);
|
||||
}
|
||||
|
||||
Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY);
|
||||
touch_scan(Wire); // The address could change during begin, so scan afterwards
|
||||
}
|
||||
|
||||
} // namespace dev
|
||||
|
||||
dev::TouchCst3240 haspTouch;
|
||||
|
||||
#endif // ARDUINO
|
26
src/drv/touch/touch_driver_cst3240.h
Normal file
26
src/drv/touch/touch_driver_cst3240.h
Normal file
@ -0,0 +1,26 @@
|
||||
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#ifndef HASP_CST3240_TOUCH_DRIVER_H
|
||||
#define HASP_CST3240_TOUCH_DRIVER_H
|
||||
|
||||
#ifdef ARDUINO
|
||||
#include "lvgl.h"
|
||||
#include "touch_driver.h"
|
||||
|
||||
namespace dev {
|
||||
|
||||
class TouchCst3240 : public BaseTouch {
|
||||
public:
|
||||
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data);
|
||||
void init(int w, int h);
|
||||
};
|
||||
|
||||
} // namespace dev
|
||||
|
||||
using dev::TouchCst3240;
|
||||
extern dev::TouchCst3240 haspTouch;
|
||||
|
||||
#endif // ARDUINO
|
||||
|
||||
#endif // HASP_CST3240_TOUCH_DRIVER_H
|
@ -5,11 +5,11 @@ board_build.mcu = esp32s3
|
||||
|
||||
ps_ram =
|
||||
-DBOARD_HAS_PSRAM
|
||||
-D HASP_USE_FREETYPE=1
|
||||
-D LV_USE_FREETYPE=1
|
||||
-D HASP_USE_FREETYPE=0
|
||||
-D LV_USE_FREETYPE=0
|
||||
no_ps_ram =
|
||||
-D HASP_USE_FREETYPE=1
|
||||
-D LV_USE_FREETYPE=1
|
||||
-D HASP_USE_FREETYPE=0
|
||||
-D LV_USE_FREETYPE=0
|
||||
|
||||
; -- The Arduino ESP32 v2.0.2 with 3 available flash sizes:
|
||||
[arduino_esp32s3_v2]
|
||||
@ -18,4 +18,5 @@ framework = arduino
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.05.01/platform-espressif32.zip
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.08.01/platform-espressif32.zip
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip
|
||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip
|
||||
; platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip
|
||||
platform = espressif32 @6.5.0
|
@ -8,8 +8,13 @@
|
||||
|
||||
[lilygo-t-panel]
|
||||
extends = arduino_esp32s3_v2
|
||||
board = esp32-s3-devkitc-1
|
||||
board_build.arduino.memory_type = qio_opi
|
||||
board = esp32s3_flash_16MB
|
||||
|
||||
; board_build.memory_type = qio_opi ;Enable internal PSRAM
|
||||
board_build.memory_type = qio_qspi ;Enable external PSRAM
|
||||
|
||||
board_upload.flash_size = 16MB
|
||||
board_build.partitions = default_16MB.csv
|
||||
|
||||
build_flags =
|
||||
-D HASP_MODEL="Lilygo T-Panel v1.2"
|
||||
@ -17,8 +22,16 @@ build_flags =
|
||||
${esp32s3.ps_ram}
|
||||
-DLILYGO_T_PANEL
|
||||
-D LILYGO_T_PANEL=1
|
||||
;-DARDUINO_USB_CDC_ON_BOOT
|
||||
;-DUSE_USB_CDC_CONSOLE
|
||||
|
||||
-Wall ;all errors that everybody could agree on
|
||||
-Wextra ;somebody agree on
|
||||
; -Werror ;Think of "Warning" as "Error".
|
||||
; -D CORE_DEBUG_LEVEL=1 ;Debug level 0-5
|
||||
-D BOARD_HAS_PSRAM ;Enable external PSRAM
|
||||
-D ARDUINO_USB_MODE=1
|
||||
-D ARDUINO_USB_CDC_ON_BOOT=0 ;1 is to use the USB port as a serial port
|
||||
-D ARDUINO_RUNNING_CORE=1 ; Arduino Runs On Core (setup, loop)
|
||||
-D ARDUINO_EVENT_RUNNING_CORE=1 ; Events Run On Core
|
||||
|
||||
;region -- ArduinoGFX build options ------------------------
|
||||
-D HASP_USE_ARDUINOGFX=1
|
||||
@ -49,27 +62,29 @@ build_flags =
|
||||
-D TFT_BCKL=14
|
||||
|
||||
; Touch Settings
|
||||
-D TOUCH_MODULES_CST_MUTUAL
|
||||
-D TOUCH_DRIVER=0x3240
|
||||
-D TOUCH_WIDTH=480
|
||||
-D TOUCH_HEIGHT=480
|
||||
-D TOUCH_SDA=17
|
||||
-D TOUCH_SCL=18
|
||||
-D TOUCH_INT=21
|
||||
-D TOUCH_RST=4
|
||||
-D TOUCH_RST=-1
|
||||
-D TOUCH_CS=-1
|
||||
-D TOUCH_DRIVER=0x3240
|
||||
; -D TOUCH_IRQ=
|
||||
; -D I2C_TOUCH_FREQUENCY=
|
||||
; -D I2C_TOUCH_ADDRESS=
|
||||
-D TOUCH_IRQ=TOUCH_INT
|
||||
-D I2C_TOUCH_FREQUENCY=400000UL
|
||||
-D I2C_TOUCH_ADDRESS=0x5A
|
||||
; -D I2C_TOUCH_PORT=
|
||||
|
||||
-D LV_DISP_DEF_REFR_PERIOD=10
|
||||
|
||||
;endregion
|
||||
|
||||
lib_deps =
|
||||
${arduino_esp32s3_v2.lib_deps}
|
||||
; moononournation/GFX Library for Arduino@1.4.0 ; Update needs modification of custom PCA class ; ${ft6336.lib_deps}
|
||||
; ; git+https://github.com/admarschoonen/TouchLib.git
|
||||
; moononournation/GFX Library for Arduino@1.4.0 ;
|
||||
git+https://github.com/mmMicky/TouchLib.git
|
||||
moononournation/GFX Library for Arduino@1.4.0
|
||||
[env:lilygo-t-panel_16MB]
|
||||
extends = lilygo-t-panel, flash_16mb
|
||||
monitor_port = COM8
|
||||
upload_port = COM8
|
||||
; monitor_port = COM8
|
||||
; upload_port = COM8
|
||||
|
Loading…
x
Reference in New Issue
Block a user