Added 4inch AP

This commit is contained in:
atc1441
2025-01-08 20:03:48 +01:00
parent 0b064a9cee
commit b8c4d4420e
5 changed files with 264 additions and 57 deletions

View File

@@ -93,6 +93,46 @@ extern Arduino_RGB_Display *gfx;
#endif
#ifdef HAS_4inch_TPANEL
#define LV_ATTRIBUTE_TICK_INC IRAM_ATTR
#define TOUCH_MODULES_CST_MUTUAL
// esp32-4848S040
#define LCD_WIDTH 480
#define LCD_HEIGHT 480
#define LCD_VSYNC 17
#define LCD_HSYNC 16
#define LCD_PCLK 21
#define LCD_R0 11
#define LCD_R1 12
#define LCD_R2 13
#define LCD_R3 14
#define LCD_R4 0
#define LCD_G0 8
#define LCD_G1 20
#define LCD_G2 3
#define LCD_G3 46
#define LCD_G4 9
#define LCD_G5 10
#define LCD_B0 4
#define LCD_B1 5
#define LCD_B2 6
#define LCD_B3 7
#define LCD_B4 15
#define LCD_BL 38
#define LCD_DE 18
#define SPI_LCD_CS 39
#define SPI_LCD_SCLK 48
#define SPI_LCD_MOSI 47
#include "Arduino_GFX_Library.h"
extern Arduino_RGB_Display *gfx;
#endif
#ifdef HAS_TFT
extern TFT_eSPI tft2;

View File

@@ -219,6 +219,60 @@ board_upload.flash_size = 16MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an ESP32-S3 16MB Flash 8MB RAM
; ----------------------------------------------------------------------------------------
[env:ESP32_S3_16_8_4inch_AP]
board = esp32-s3-devkitc-1
board_build.partitions = large_spiffs_16MB.csv
monitor_dtr = 0
monitor_rts = 0
build_unflags =
-std=gnu++11
-D CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
lib_deps = ${env.lib_deps}
lib_extra_dirs = lib2/Arduino_GFX-1.3.7
build_flags =
-std=gnu++17
${env.build_flags}
-D HAS_TFT
-D HAS_4inch_TPANEL
-D CORE_DEBUG_LEVEL=1
-D CONFIG_ESP32S3_SPIRAM_SUPPORT=1
-D CONFIG_SPIRAM_USE_MALLOC=1
-D POWER_NO_SOFT_POWER
-D BOARD_HAS_PSRAM
-D CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
-D HAS_BLE_WRITER
-D FLASHER_AP_SS=-1
-D FLASHER_AP_CLK=-1
-D FLASHER_AP_MOSI=-1
-D FLASHER_AP_MISO=-1
-D FLASHER_AP_RESET=1
-D FLASHER_AP_POWER={-1}
-D FLASHER_AP_TEST=-1
-D FLASHER_AP_TXD=40
-D FLASHER_AP_RXD=44
-D FLASHER_DEBUG_TXD=19
-D FLASHER_DEBUG_RXD=45
-D FLASHER_DEBUG_PROG=2
-D FLASHER_LED=-1
-D TFT_HEIGHT=480
-D USE_HSPI_PORT
-D LOAD_FONT2
-D MD5_ENABLED=1
-D SERIAL_FLASHER_INTERFACE_UART=1
-D SERIAL_FLASHER_BOOT_HOLD_TIME_MS=200
-D SERIAL_FLASHER_RESET_HOLD_TIME_MS=200
-D HAS_SUBGHZ
build_src_filter =
+<*>-<usbflasher.cpp>-<swd.cpp>-<webflasher.cpp>
board_build.flash_mode=qio
board_build.arduino.memory_type = qio_opi ;Enable external PSRAM
board_build.psram_type=qspi_opi
board_upload.maximum_size = 16777216
board_upload.maximum_ram_size = 327680
board_upload.flash_size = 16MB
; ----------------------------------------------------------------------------------------
; !!! this configuration expects an ESP32-S3 16MB Flash 8MB RAM
; ----------------------------------------------------------------------------------------
[env:ESP32_S3_C6_BIG_AP]
board = esp32-s3-devkitc-1
board_build.partitions = large_spiffs_16MB.csv

View File

@@ -19,9 +19,9 @@ uint8_t YellowSense = 0;
bool tftLogscreen = true;
bool tftOverride = false;
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
#if defined HAS_LILYGO_TPANEL
static const uint8_t st7701_type9_init_operations_lilygo[] = {
BEGIN_WRITE,
@@ -41,14 +41,14 @@ static const uint8_t st7701_type9_init_operations_lilygo[] = {
WRITE_C8_D8, 0xCC, 0x10,
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
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_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x0F, 0x16, 0x0E,
0x11, 0x07, 0x09, 0x08,
@@ -142,7 +142,7 @@ static const uint8_t st7701_type9_init_operations_lilygo[] = {
// WRITE_C8_D8, 0xD1, 0x81,//Test
// WRITE_C8_D8, 0xD2, 0x08,//Test
WRITE_COMMAND_8, 0x29, // Display On
WRITE_COMMAND_8, 0x29, // Display On
// WRITE_C8_D8, 0x35, 0x00,//Test
// WRITE_C8_D8, 0xCE, 0x04,//Test
@@ -152,41 +152,155 @@ static const uint8_t st7701_type9_init_operations_lilygo[] = {
// 0xF0, 0xA3, 0xA3, 0x71,
END_WRITE};
Arduino_DataBus *bus = new Arduino_XL9535SWSPI(IIC_SDA /* SDA */, IIC_SCL /* SCL */, -1 /* XL PWD */,
Arduino_DataBus* bus = new Arduino_XL9535SWSPI(IIC_SDA /* SDA */, IIC_SCL /* SCL */, -1 /* XL PWD */,
XL95X5_CS /* XL CS */, XL95X5_SCLK /* XL SCK */, XL95X5_MOSI /* XL MOSI */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
-1 /* DE */, LCD_VSYNC /* VSYNC */, LCD_HSYNC /* HSYNC */, LCD_PCLK /* PCLK */,
LCD_B0 /* B0 */, LCD_B1 /* B1 */, LCD_B2 /* B2 */, LCD_B3 /* B3 */, LCD_B4 /* B4 */,
LCD_G0 /* G0 */, LCD_G1 /* G1 */, LCD_G2 /* G2 */, LCD_G3 /* G3 */, LCD_G4 /* G4 */, LCD_G5 /* G5 */,
LCD_R0 /* R0 */, LCD_R1 /* R1 */, LCD_R2 /* R2 */, LCD_R3 /* R3 */, LCD_R4 /* R4 */,
1 /* hsync_polarity */, 20 /* hsync_front_porch */, 2 /* hsync_pulse_width */, 0 /* hsync_back_porch */,
1 /* vsync_polarity */, 30 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 1 /* vsync_back_porch */,
10 /* pclk_active_neg */, 6000000L /* prefer_speed */, true /* useBigEndian */,
0 /* de_idle_high*/, 0 /* pclk_idle_high */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
LCD_WIDTH /* width */, LCD_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, -1 /* RST */, st7701_type9_init_operations_lilygo, sizeof(st7701_type9_init_operations_lilygo));
Arduino_ESP32RGBPanel* rgbpanel = new Arduino_ESP32RGBPanel(
-1 /* DE */, LCD_VSYNC /* VSYNC */, LCD_HSYNC /* HSYNC */, LCD_PCLK /* PCLK */,
LCD_B0 /* B0 */, LCD_B1 /* B1 */, LCD_B2 /* B2 */, LCD_B3 /* B3 */, LCD_B4 /* B4 */,
LCD_G0 /* G0 */, LCD_G1 /* G1 */, LCD_G2 /* G2 */, LCD_G3 /* G3 */, LCD_G4 /* G4 */, LCD_G5 /* G5 */,
LCD_R0 /* R0 */, LCD_R1 /* R1 */, LCD_R2 /* R2 */, LCD_R3 /* R3 */, LCD_R4 /* R4 */,
1 /* hsync_polarity */, 20 /* hsync_front_porch */, 2 /* hsync_pulse_width */, 0 /* hsync_back_porch */,
1 /* vsync_polarity */, 30 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 1 /* vsync_back_porch */,
10 /* pclk_active_neg */, 6000000L /* prefer_speed */, true /* useBigEndian */,
0 /* de_idle_high*/, 0 /* pclk_idle_high */);
Arduino_RGB_Display* gfx = new Arduino_RGB_Display(
LCD_WIDTH /* width */, LCD_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, -1 /* RST */, st7701_4848S040_init, sizeof(st7701_4848S040_init));
#else
static const uint8_t st7701_4848S040_init[] = {
BEGIN_WRITE,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
WRITE_C8_D16, 0xC1, 0x0D, 0x02,
WRITE_C8_D16, 0xC2, 0x31, 0x05,
WRITE_C8_D8, 0xCD, 0x00, // 0xCD, 0x08 !!
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x18, 0x0E, 0x11, 0x06, 0x07, 0x08,
0x07, 0x22, 0x04, 0x12, 0x0F, 0xAA, 0x31, 0x18,
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
WRITE_BYTES, 16,
0x00, 0x11, 0x19, 0x0E, 0x12, 0x07, 0x08, 0x08,
0x08, 0x22, 0x04, 0x11, 0x11, 0xA9, 0x32, 0x18,
// PAGE1
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
WRITE_C8_D8, 0xB0, 0x60, // Vop=4.7375v
WRITE_C8_D8, 0xB1, 0x32, // VCOM=32
WRITE_C8_D8, 0xB2, 0x07, // VGH=15v
WRITE_C8_D8, 0xB3, 0x80,
WRITE_C8_D8, 0xB5, 0x49, // VGL=-10.17v
WRITE_C8_D8, 0xB7, 0x85,
WRITE_C8_D8, 0xB8, 0x21, // AVDD=6.6 & AVCL=-4.6
WRITE_C8_D8, 0xC1, 0x78,
WRITE_C8_D8, 0xC2, 0x78,
WRITE_COMMAND_8, 0xE0,
WRITE_BYTES, 3, 0x00, 0x1B, 0x02,
WRITE_COMMAND_8, 0xE1,
WRITE_BYTES, 11,
0x08, 0xA0, 0x00, 0x00,
0x07, 0xA0, 0x00, 0x00,
0x00, 0x44, 0x44,
WRITE_COMMAND_8, 0xE2,
WRITE_BYTES, 12,
0x11, 0x11, 0x44, 0x44,
0xED, 0xA0, 0x00, 0x00,
0xEC, 0xA0, 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,
0x0A, 0xE9, 0xD8, 0xA0, 0x0C, 0xEB, 0xD8, 0xA0,
0x0E, 0xED, 0xD8, 0xA0, 0x10, 0xEF, 0xD8, 0xA0,
WRITE_COMMAND_8, 0xE6,
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
WRITE_C8_D16, 0xE7, 0x44, 0x44,
WRITE_COMMAND_8, 0xE8,
WRITE_BYTES, 16,
0x09, 0xE8, 0xD8, 0xA0,
0x0B, 0xEA, 0xD8, 0xA0,
0x0D, 0xEC, 0xD8, 0xA0,
0x0F, 0xEE, 0xD8, 0xA0,
WRITE_COMMAND_8, 0xEB,
WRITE_BYTES, 7, 0x02, 0x00, 0xE4, 0xE4, 0x88, 0x00, 0x40,
WRITE_C8_D16, 0xEC, 0x3C, 0x00,
WRITE_COMMAND_8, 0xED,
WRITE_BYTES, 16,
0xAB, 0x89, 0x76, 0x54, 0x02, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x20, 0x45, 0x67, 0x98, 0xBA,
//-----------VAP & VAN---------------
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
WRITE_C8_D8, 0xE5, 0xE4,
WRITE_COMMAND_8, 0xFF,
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x00,
// WRITE_COMMAND_8, 0x21, // 0x20 normal, 0x21 IPS !!
WRITE_C8_D8, 0x3A, 0x50, // 0x70 RGB888, 0x60 RGB666, 0x50 RGB565
WRITE_COMMAND_8, 0x11, // Sleep Out
END_WRITE,
DELAY, 120,
BEGIN_WRITE,
WRITE_COMMAND_8, 0x29, // Display On
END_WRITE};
Arduino_DataBus* bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, SPI_LCD_CS /* CS */, SPI_LCD_SCLK /* SCK */, SPI_LCD_MOSI /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel* rgbpanel = new Arduino_ESP32RGBPanel(
LCD_DE /* DE */, LCD_VSYNC /* VSYNC */, LCD_HSYNC /* HSYNC */, LCD_PCLK /* PCLK */,
LCD_R0 /* B0 */, LCD_R1 /* B1 */, LCD_R2 /* B2 */, LCD_R3 /* B3 */, LCD_R4 /* B4 */,
LCD_G0 /* G0 */, LCD_G1 /* G1 */, LCD_G2 /* G2 */, LCD_G3 /* G3 */, LCD_G4 /* G4 */, LCD_G5 /* G5 */,
LCD_B0 /* R0 */, LCD_B1 /* R1 */, LCD_B2 /* R2 */, LCD_B3 /* R3 */, LCD_B4 /* R4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */,
10 /* pclk_active_neg */, 6000000L /* prefer_speed */, true);
Arduino_RGB_Display* gfx = new Arduino_RGB_Display(
LCD_WIDTH /* width */, LCD_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
bus, -1 /* RST */, st7701_4848S040_init, sizeof(st7701_4848S040_init));
#endif
#endif
void TFTLog(String text) {
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
gfx->setTextSize(2);
gfx->setTextSize(2);
if (tftLogscreen == false) {
gfx->fillScreen(BLACK);
gfx->setCursor(0, 0);
tftLogscreen = true;
}
}
if (text.isEmpty()) return;
gfx->setTextColor(WHITE);
gfx->println(text);
#else
#else
if (tftLogscreen == false) {
tft2.fillScreen(TFT_BLACK);
tft2.setCursor(0, 0, (tft2.width() == 160 ? 1 : 2));
@@ -220,7 +334,7 @@ void TFTLog(String text) {
tft2.setTextColor(TFT_GREEN);
}
tft2.println(text);
#endif
#endif
}
int32_t findId(uint8_t mac[8]) {
@@ -240,11 +354,11 @@ void sendAvail(uint8_t wakeupReason) {
memcpy(&eadr.src, mac, 6);
eadr.adr.lastPacketRSSI = WiFi.RSSI();
eadr.adr.currentChannel = config.channel;
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
eadr.adr.hwType = 0xE2;
#else
#else
eadr.adr.hwType = (tft2.width() == 160 ? 0xE1 : 0xE0);
#endif
#endif
eadr.adr.wakeupReason = wakeupReason;
eadr.adr.capabilities = 0;
eadr.adr.tagSoftwareVersion = 0;
@@ -253,10 +367,9 @@ void sendAvail(uint8_t wakeupReason) {
}
void yellow_ap_display_init(void) {
#ifdef HAS_LILYGO_TPANEL
tftLogscreen = true;
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
tftLogscreen = true;
pinMode(LCD_BL, OUTPUT);
digitalWrite(LCD_BL, HIGH);
@@ -264,14 +377,14 @@ void yellow_ap_display_init(void) {
ledcAttachPin(LCD_BL, 1);
ledcSetup(1, 1000, 8);
ledcWrite(1, config.tft); // brightness
ledcWrite(1, config.tft); // brightness
#if defined HAS_LILYGO_TPANEL
Wire.begin(IIC_SDA, IIC_SCL);
#endif
gfx->begin();
gfx->fillScreen(BLACK);
#else
#else
pinMode(YELLOW_SENSE, INPUT_PULLDOWN);
vTaskDelay(100 / portTICK_PERIOD_MS);
if (digitalRead(YELLOW_SENSE) == HIGH) YellowSense = 1;
@@ -279,12 +392,12 @@ void yellow_ap_display_init(void) {
digitalWrite(TFT_BACKLIGHT, LOW);
tft2.init();
#ifdef ST7735_NANO_TLSR
#ifdef ST7735_NANO_TLSR
YellowSense = 0;
tft2.setRotation(1);
#else
#else
tft2.setRotation(YellowSense == 1 ? 1 : 3);
#endif
#endif
tft2.fillScreen(TFT_BLACK);
tft2.setCursor(12, 0, (tft2.width() == 160 ? 1 : 2));
tft2.setTextColor(TFT_WHITE);
@@ -296,7 +409,7 @@ void yellow_ap_display_init(void) {
GPIO.func_out_sel_cfg[TFT_BACKLIGHT].inv_sel = 1;
}
ledcWrite(6, config.tft);
#endif
#endif
}
void yellow_ap_display_loop(void) {
@@ -338,19 +451,19 @@ void yellow_ap_display_loop(void) {
void* spriteData = spr.getPointer();
size_t bytesRead = file.readBytes((char*)spriteData, spr.width() * spr.height() * 2);
file.close();
#ifdef HAS_LILYGO_TPANEL
long dy = spr.height();
long dx = spr.width();
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
long dy = spr.height();
long dx = spr.width();
uint16_t* data = static_cast<uint16_t*>(const_cast<void*>(spriteData));
gfx->draw16bitRGBBitmap(0, 0, (uint16_t *)spriteData, dx, dy);
spr.deleteSprite();
#else
gfx->draw16bitRGBBitmap(0, 0, (uint16_t*)spriteData, dx, dy);
spr.deleteSprite();
#else
spr.pushSprite(0, 0);
#endif
#endif
tftLogscreen = false;
struct espXferComplete xfc = {0};

View File

@@ -133,7 +133,7 @@ void rgbIdleStep() {
void setBrightness(int brightness) {
maxledbrightness = brightness;
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
ledcWrite(1, config.tft);
#else
#ifdef HAS_TFT
@@ -150,7 +150,7 @@ void updateBrightnessFromConfig() {
if (newbrightness != maxledbrightness) {
setBrightness(newbrightness);
}
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
ledcWrite(1, config.tft);
#else
#ifdef HAS_TFT

View File

@@ -386,7 +386,7 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
size_t dataSize = spr.width() * spr.height() * (spr.getColorDepth() / 8);
memcpy(spriteData2, spriteData, dataSize);
#ifdef HAS_LILYGO_TPANEL
#if defined HAS_LILYGO_TPANEL || defined HAS_4inch_TPANEL
if (spr.getColorDepth() == 16) {
long dy = spr.height();
long dx = spr.width();