This commit is contained in:
fvanroie 2024-12-07 02:14:44 +01:00
commit a67bcc3fc0
21 changed files with 333 additions and 39 deletions

View 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"
}

View File

@ -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:

View File

@ -13,7 +13,7 @@
#include "hasplib.h"
#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code
#include "hasp_debug.h"

View File

@ -6,7 +6,7 @@
#include "hasplib.h"
#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code
#include "hasp_debug.h"

View File

@ -9,7 +9,7 @@
#define HASP_CUSTOM_H
#include "hasplib.h"
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
/* This function is called at boot */
void custom_setup();

View File

@ -26,10 +26,10 @@ void ArduinoGfx::init(int w, int h)
LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING));
#if(TFT_WIDTH == 170) && (TFT_HEIGHT == 320)
Arduino_DataBus *bus = new Arduino_ESP32PAR8Q(
Arduino_DataBus *bus = new Arduino_ESP32PAR8(
TFT_DC, TFT_CS, TFT_WR, TFT_RD,
TFT_D0, TFT_D1, TFT_D2, TFT_D3, TFT_D4, TFT_D5, TFT_D6, TFT_D7);
Arduino_GFX *gfx = new Arduino_ST7789(bus,
tft = new Arduino_ST7789(bus,
TFT_RST /* RST */, TFT_ROTATION /* rotation */, true /* IPS */,
TFT_WIDTH /* width */, TFT_HEIGHT /* height */,
35 /* col offset 1 */, 0 /* row offset 1 */,
@ -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 */);
@ -141,7 +142,7 @@ void ArduinoGfx::init(int w, int h)
/* TFT init */
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
tft->begin(GFX_NOT_DEFINED);
tft->begin(SPI_FREQUENCY);
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
// tft.setSwapBytes(true); /* set endianness */
LOG_INFO(TAG_TFT, F(D_SERVICE_STARTED));

View File

@ -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;

View 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

View 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

View File

@ -452,7 +452,7 @@ void dispatch_topic_payload(const char* topic, const char* payload, bool update,
}
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
if(topic == strstr_P(topic, PSTR(MQTT_TOPIC_CUSTOM "/"))) { // startsWith custom
topic += 7u;
custom_topic_payload(topic, (char*)payload, source);
@ -1295,7 +1295,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source)
haspDevice.get_sensors(doc);
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_get_sensors(doc);
#endif

View File

@ -32,7 +32,7 @@ void task_every_second_cb(lv_task_t* task)
telnetEverySecond();
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_every_second();
#endif
// debugEverySecond();
@ -53,7 +53,7 @@ void task_every_second_cb(lv_task_t* task)
break;
case 3:
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_every_5seconds();
#endif
break;

View File

@ -70,6 +70,6 @@
#endif
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
#include "custom/my_custom.h"
#endif

View File

@ -136,7 +136,7 @@ void setup()
slaveSetup();
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_setup();
#endif
@ -195,7 +195,7 @@ IRAM_ATTR void loop()
consoleLoop();
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_loop();
#endif
@ -222,7 +222,7 @@ IRAM_ATTR void loop()
telnetEverySecond();
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_every_second();
#endif
// debugEverySecond();
@ -243,7 +243,7 @@ IRAM_ATTR void loop()
// gpioEvery5Seconds();
#endif
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
custom_every_5seconds();
#endif
break;

View File

@ -371,7 +371,7 @@ void onMqttConnect(esp_mqtt_client_handle_t client)
// mqttSubscribeTo(mqttGroupTopic + subtopic);
// mqttSubscribeTo(mqttNodeTopic + subtopic);
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
String subtopic = F(MQTT_TOPIC_CUSTOM "/#");
mqttSubscribeTo(mqttGroupCommandTopic + subtopic);
mqttSubscribeTo(mqttNodeCommandTopic + subtopic);

View File

@ -328,7 +328,7 @@ static void onConnect(void* context, MQTTAsync_successData* response)
topic = mqttNodeTopic + "config/#";
mqtt_subscribe(mqtt_client, topic.c_str());
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
topic = mqttGroupTopic + MQTT_TOPIC_CUSTOM "/#";
mqtt_subscribe(mqtt_client, topic.c_str());

View File

@ -269,7 +269,7 @@ static void onConnect(void* context)
topic = mqttNodeTopic + "config/#";
mqtt_subscribe(mqtt_client, topic.c_str());
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
topic = mqttGroupTopic + MQTT_TOPIC_CUSTOM "/#";
mqtt_subscribe(mqtt_client, topic.c_str());

View File

@ -311,7 +311,7 @@ void mqttStart()
snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CONFIG "/#"), mqttNodeTopic);
mqttSubscribeTo(topic);
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttGroupTopic);
mqttSubscribeTo(topic);
snprintf_P(topic, sizeof(topic), PSTR("%s" MQTT_TOPIC_CUSTOM "/#"), mqttNodeTopic);

View File

@ -776,7 +776,7 @@ bool gpioIsSystemPin(uint8_t gpio)
return true;
}
#if defined(HASP_USE_CUSTOM)
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
if(custom_pin_in_use(gpio)) {
LOG_DEBUG(TAG_GPIO, F(D_BULLET D_GPIO_PIN " %d => Custom"), gpio);
return true;

View File

@ -19,3 +19,4 @@ framework = arduino
; 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 = espressif32 @6.5.0

View File

@ -26,6 +26,7 @@ build_flags =
;-D TFT_INVERSION_ON
;-D TFT_RGB_ORDER=0 ; Colour order Blue-Green-Red
;-D INVERT_COLORS=1 ; for inverted colors
-D SPI_FREQUENCY=16000000
-D TFT_RST=-1
-D TFT_CS=21
@ -44,12 +45,13 @@ build_flags =
; Touch Setttings
-D TOUCH_WIDTH=170
-D TOUCH_HEIGHT=320
-D TOUCH_DRIVER=0x911
-D TOUCH_DRIVER=0x6336
-D TOUCH_SCL=0
-D TOUCH_SDA=35
-D TOUCH_IRQ=-1
-D TOUCH_RST=-1
-D I2C_TOUCH_ADDRESS=0x5d ; or 0x14
-D I2C_TOUCH_ADDRESS=0x38
-D I2C_TOUCH_PORT=1
-D I2C_TOUCH_FREQUENCY=400000
;endregion
@ -60,6 +62,7 @@ lib_deps =
${arduino_esp32s3_v2.lib_deps}
${arduinogfx.lib_deps}
${goodix.lib_deps}
${ft6336.lib_deps}
lib_ignore =
${env.lib_ignore}

View File

@ -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