Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fvanroie committed Dec 7, 2024
2 parents 5f29881 + 12ec1a1 commit a67bcc3
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 39 deletions.
43 changes: 43 additions & 0 deletions boards/esp32s3_flash_16MB.json
Original file line number Diff line number Diff line change
@@ -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"
}
130 changes: 130 additions & 0 deletions lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/custom/my_custom_fan_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/custom/my_custom_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/custom/my_custom_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 6 additions & 5 deletions src/drv/tft/tft_driver_arduinogfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ 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 */,
35 /* col offset 2 */, 0 /* row offset 2 */
);

#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 */,
Expand All @@ -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 */);
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions src/drv/touch/touch_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
72 changes: 72 additions & 0 deletions src/drv/touch/touch_driver_cst3240.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 0 deletions src/drv/touch/touch_driver_cst3240.h
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/hasp/hasp_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/hasp/hasp_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
Loading

0 comments on commit a67bcc3

Please sign in to comment.