Skip to content

Commit a67bcc3

Browse files
author
fvanroie
committed
2 parents 5f29881 + 12ec1a1 commit a67bcc3

21 files changed

+333
-39
lines changed

boards/esp32s3_flash_16MB.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld"
5+
},
6+
"core": "esp32",
7+
"extra_flags": [
8+
"-DARDUINO_ESP32S3_DEV",
9+
"-DARDUINO_USB_MODE=1",
10+
"-DARDUINO_RUNNING_CORE=1",
11+
"-DARDUINO_EVENT_RUNNING_CORE=1"
12+
],
13+
"f_cpu": "240000000L",
14+
"f_flash": "80000000L",
15+
"flash_mode": "qio",
16+
"mcu": "esp32s3",
17+
"variant": "esp32s3"
18+
},
19+
"connectivity": [
20+
"wifi"
21+
],
22+
"debug": {
23+
"default_tool": "esp-builtin",
24+
"onboard_tools": [
25+
"esp-builtin"
26+
],
27+
"openocd_target": "esp32s3.cfg"
28+
},
29+
"frameworks": [
30+
"arduino",
31+
"espidf"
32+
],
33+
"name": "ESP32-S3-FLASH-16MB",
34+
"upload": {
35+
"flash_size": "16MB",
36+
"maximum_ram_size": 327680,
37+
"maximum_size": 16777216,
38+
"require_upload_port": true,
39+
"speed": 921600
40+
},
41+
"url": "null",
42+
"vendor": "null"
43+
}

lib/Arduino_RPi_DPI_RGBPanel_mod/Arduino_RGB_Display_mod.h

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,136 @@ static const uint8_t st7701_sensecap_indicator_init_operations[] = {
265265
DELAY, 120,
266266
};
267267

268+
static const uint8_t st7701_t_panel_init_operations[] = {
269+
270+
BEGIN_WRITE,
271+
WRITE_COMMAND_8, 0xFF,
272+
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x13,
273+
274+
WRITE_C8_D8, 0xEF, 0x08,
275+
276+
WRITE_COMMAND_8, 0xFF,
277+
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x10,
278+
279+
WRITE_C8_D16, 0xC0, 0x3B, 0x00,
280+
WRITE_C8_D16, 0xC1, 0x0B, 0x02,
281+
282+
WRITE_COMMAND_8, 0xC2,
283+
WRITE_BYTES, 3, 0x30, 0x02, 0x37,
284+
285+
WRITE_C8_D8, 0xCC, 0x10,
286+
287+
WRITE_COMMAND_8, 0xB0, // Positive Voltage Gamma Control
288+
WRITE_BYTES, 16,
289+
0x00, 0x0F, 0x16, 0x0E,
290+
0x11, 0x07, 0x09, 0x09,
291+
0x08, 0x23, 0x05, 0x11,
292+
0x0F, 0x28, 0x2D, 0x18,
293+
294+
WRITE_COMMAND_8, 0xB1, // Negative Voltage Gamma Control
295+
WRITE_BYTES, 16,
296+
0x00, 0x0F, 0x16, 0x0E,
297+
0x11, 0x07, 0x09, 0x08,
298+
0x09, 0x23, 0x05, 0x11,
299+
0x0F, 0x28, 0x2D, 0x18,
300+
301+
WRITE_COMMAND_8, 0xFF,
302+
WRITE_BYTES, 5, 0x77, 0x01, 0x00, 0x00, 0x11,
303+
304+
WRITE_C8_D8, 0xB0, 0x4D,
305+
WRITE_C8_D8, 0xB1, 0x33,
306+
WRITE_C8_D8, 0xB2, 0x87,
307+
WRITE_C8_D8, 0xB5, 0x4B,
308+
WRITE_C8_D8, 0xB7, 0x8C,
309+
WRITE_C8_D8, 0xB8, 0x20,
310+
WRITE_C8_D8, 0xC1, 0x78,
311+
WRITE_C8_D8, 0xC2, 0x78,
312+
WRITE_C8_D8, 0xD0, 0x88,
313+
314+
WRITE_COMMAND_8, 0xE0,
315+
WRITE_BYTES, 3, 0x00, 0x00, 0x02,
316+
317+
WRITE_COMMAND_8, 0xE1,
318+
WRITE_BYTES, 11,
319+
0x02, 0xF0, 0x00, 0x00,
320+
0x03, 0xF0, 0x00, 0x00,
321+
0x00, 0x44, 0x44,
322+
323+
WRITE_COMMAND_8, 0xE2,
324+
WRITE_BYTES, 12,
325+
0x10, 0x10, 0x40, 0x40,
326+
0xF2, 0xF0, 0x00, 0x00,
327+
0xF2, 0xF0, 0x00, 0x00,
328+
329+
WRITE_COMMAND_8, 0xE3,
330+
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
331+
332+
WRITE_C8_D16, 0xE4, 0x44, 0x44,
333+
334+
WRITE_COMMAND_8, 0xE5,
335+
WRITE_BYTES, 16,
336+
0x07, 0xEF, 0xF0, 0xF0,
337+
0x09, 0xF1, 0xF0, 0xF0,
338+
0x03, 0xF3, 0xF0, 0xF0,
339+
0x05, 0xED, 0xF0, 0xF0,
340+
341+
WRITE_COMMAND_8, 0xE6,
342+
WRITE_BYTES, 4, 0x00, 0x00, 0x11, 0x11,
343+
344+
WRITE_C8_D16, 0xE7, 0x44, 0x44,
345+
346+
WRITE_COMMAND_8, 0xE8,
347+
WRITE_BYTES, 16,
348+
0x08, 0xF0, 0xF0, 0xF0,
349+
0x0A, 0xF2, 0xF0, 0xF0,
350+
0x04, 0xF4, 0xF0, 0xF0,
351+
0x06, 0xEE, 0xF0, 0xF0,
352+
353+
WRITE_COMMAND_8, 0xEB,
354+
WRITE_BYTES, 7,
355+
0x00, 0x00, 0xE4, 0xE4,
356+
0x44, 0x88, 0x40,
357+
358+
WRITE_C8_D16, 0xEC, 0x78, 0x00,
359+
360+
WRITE_COMMAND_8, 0xED,
361+
WRITE_BYTES, 16,
362+
0x20, 0xF9, 0x87, 0x76,
363+
0x65, 0x54, 0x4F, 0xFF,
364+
0xFF, 0xF4, 0x45, 0x56,
365+
0x67, 0x78, 0x9F, 0x02,
366+
367+
WRITE_COMMAND_8, 0xEF,
368+
WRITE_BYTES, 6,
369+
0x10, 0x0D, 0x04, 0x08,
370+
0x3F, 0x1F,
371+
372+
// WRITE_C8_D8, 0xCD, 0x05,//Test
373+
374+
WRITE_C8_D8, 0x3A, 0x55,
375+
376+
WRITE_C8_D8, 0x36, 0x08,
377+
378+
WRITE_COMMAND_8, 0x11,
379+
380+
// WRITE_COMMAND_8, 0xFF,//Test
381+
// WRITE_BYTES, 5,
382+
// 0x77, 0x01, 0x00, 0x00,
383+
// 0x12,
384+
385+
// WRITE_C8_D8, 0xD1, 0x81,//Test
386+
// WRITE_C8_D8, 0xD2, 0x08,//Test
387+
388+
WRITE_COMMAND_8, 0x29, // Display On
389+
390+
// WRITE_C8_D8, 0x35, 0x00,//Test
391+
// WRITE_C8_D8, 0xCE, 0x04,//Test
392+
393+
// WRITE_COMMAND_8, 0xF2,//Test
394+
// WRITE_BYTES, 4,
395+
// 0xF0, 0xA3, 0xA3, 0x71,
396+
397+
END_WRITE};
268398

269399
class Arduino_RGB_Display_Mod : public Arduino_GFX{
270400
public:

src/custom/my_custom_fan_template.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "hasplib.h"
1515

16-
#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code
16+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code
1717

1818
#include "hasp_debug.h"
1919

src/custom/my_custom_template.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "hasplib.h"
88

9-
#if defined(HASP_USE_CUSTOM) && false // <-- set this to true in your code
9+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0 && false // <-- set this to true in your code
1010

1111
#include "hasp_debug.h"
1212

src/custom/my_custom_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define HASP_CUSTOM_H
1010

1111
#include "hasplib.h"
12-
#if defined(HASP_USE_CUSTOM)
12+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
1313

1414
/* This function is called at boot */
1515
void custom_setup();

src/drv/tft/tft_driver_arduinogfx.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@ void ArduinoGfx::init(int w, int h)
2626
LOG_TRACE(TAG_TFT, F(D_SERVICE_STARTING));
2727

2828
#if(TFT_WIDTH == 170) && (TFT_HEIGHT == 320)
29-
Arduino_DataBus *bus = new Arduino_ESP32PAR8Q(
29+
Arduino_DataBus *bus = new Arduino_ESP32PAR8(
3030
TFT_DC, TFT_CS, TFT_WR, TFT_RD,
3131
TFT_D0, TFT_D1, TFT_D2, TFT_D3, TFT_D4, TFT_D5, TFT_D6, TFT_D7);
32-
Arduino_GFX *gfx = new Arduino_ST7789(bus,
32+
tft = new Arduino_ST7789(bus,
3333
TFT_RST /* RST */, TFT_ROTATION /* rotation */, true /* IPS */,
3434
TFT_WIDTH /* width */, TFT_HEIGHT /* height */,
3535
35 /* col offset 1 */, 0 /* row offset 1 */,
3636
35 /* col offset 2 */, 0 /* row offset 2 */
3737
);
3838

3939
#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_PANEL)
40+
Wire.begin(17, 18);
4041
Arduino_DataBus* bus = new Arduino_XL9535SWSPI(17 /* SDA */, 18 /* SCL */, -1 /* XL PWD */, 17 /* XL CS */,
41-
15 /* XL SCK */, 16 /* XL MOSI */);
42+
15 /* XL SCK */, 16 /* XL MOSI */,&Wire);
4243
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
4344
-1 /* DE */, TFT_VSYNC /* VSYNC */, TFT_HSYNC /* HSYNC */, TFT_PCLK /* PCLK */,
4445
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)
5051
0 /* de_idle_high*/, 0 /* pclk_idle_high */);
5152

5253
tft = new Arduino_RGB_Display(TFT_WIDTH /* width */, TFT_HEIGHT /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */,
53-
bus, -1 /* RST */, st7701_sensecap_indicator_init_operations, sizeof(st7701_sensecap_indicator_init_operations));
54+
bus, -1 /* RST */, st7701_t_panel_init_operations, sizeof(st7701_t_panel_init_operations));
5455

5556
#elif(TFT_WIDTH == 480) && (TFT_HEIGHT == 480) && defined(LILYGO_T_RGB)
5657
Wire.begin(8 /* SDA */, 48 /* SCL */, 800000L /* speed */);
@@ -141,7 +142,7 @@ void ArduinoGfx::init(int w, int h)
141142

142143
/* TFT init */
143144
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
144-
tft->begin(GFX_NOT_DEFINED);
145+
tft->begin(SPI_FREQUENCY);
145146
LOG_DEBUG(TAG_TFT, F("%s - %d"), __FILE__, __LINE__);
146147
// tft.setSwapBytes(true); /* set endianness */
147148
LOG_INFO(TAG_TFT, F(D_SERVICE_STARTED));

src/drv/touch/touch_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class BaseTouch {
9090
#elif defined(LGFX_USE_V1)
9191
#warning Building for LovyanGfx Touch
9292
#include "touch_driver_lovyangfx.h"
93+
#elif TOUCH_DRIVER == 0x3240
94+
#warning Building for CST3240
95+
#include "touch_driver_cst3240.h"
9396
#else
9497
#warning Building for Generic Touch
9598
using dev::BaseTouch;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
2+
For full license information read the LICENSE file in the project folder */
3+
4+
#if defined(ARDUINO) && (TOUCH_DRIVER == 0x3240) && !defined(HASP_USE_LGFX_TOUCH)
5+
#include <Arduino.h>
6+
#include "ArduinoLog.h"
7+
#include "hasp_conf.h"
8+
#include "touch_driver_cst3240.h"
9+
10+
#include <Wire.h>
11+
#include "TouchLib.h"
12+
13+
#include "touch_driver.h" // base class
14+
#include "touch_helper.h" // i2c scanner
15+
16+
#include "../../hasp/hasp.h" // for hasp_sleep_state
17+
extern uint8_t hasp_sleep_state;
18+
19+
TouchLib touch(Wire, TOUCH_SDA, TOUCH_SCL, I2C_TOUCH_ADDRESS);
20+
21+
namespace dev {
22+
23+
IRAM_ATTR bool TouchCst3240::read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
24+
{
25+
touch.read();
26+
TP_Point t = touch.getPoint(0);
27+
28+
if((touch.getPointNum() == 1) && (t.pressure > 0) && (t.state != 0)) {
29+
30+
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
31+
32+
#ifdef TOUCH_WIDTH
33+
data->point.x = map(t.x, 0, TOUCH_WIDTH - 1, 0, TFT_WIDTH - 1);
34+
#else
35+
data->point.x = t.x;
36+
#endif
37+
38+
#ifdef TOUCH_HEIGHT
39+
data->point.y = map(t.y, 0, TOUCH_HEIGHT - 1, 0, TFT_HEIGHT - 1);
40+
#else
41+
data->point.y = t.y;
42+
#endif
43+
44+
data->state = LV_INDEV_STATE_PR;
45+
hasp_set_sleep_offset(0); // Reset the offset
46+
47+
} else {
48+
data->state = LV_INDEV_STATE_REL;
49+
}
50+
51+
/*Return `false` because we are not buffering and no more data to read*/
52+
return false;
53+
}
54+
55+
void TouchCst3240::init(int w, int h)
56+
{
57+
Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY);
58+
if(touch.init() == true) {
59+
LOG_INFO(TAG_DRVR, "CST3240 %s (480x480)", D_SERVICE_STARTED);
60+
} else {
61+
LOG_WARNING(TAG_DRVR, "CST3240 %s", D_SERVICE_START_FAILED);
62+
}
63+
64+
Wire.begin(TOUCH_SDA, TOUCH_SCL, (uint32_t)I2C_TOUCH_FREQUENCY);
65+
touch_scan(Wire); // The address could change during begin, so scan afterwards
66+
}
67+
68+
} // namespace dev
69+
70+
dev::TouchCst3240 haspTouch;
71+
72+
#endif // ARDUINO

src/drv/touch/touch_driver_cst3240.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
2+
For full license information read the LICENSE file in the project folder */
3+
4+
#ifndef HASP_CST3240_TOUCH_DRIVER_H
5+
#define HASP_CST3240_TOUCH_DRIVER_H
6+
7+
#ifdef ARDUINO
8+
#include "lvgl.h"
9+
#include "touch_driver.h"
10+
11+
namespace dev {
12+
13+
class TouchCst3240 : public BaseTouch {
14+
public:
15+
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data);
16+
void init(int w, int h);
17+
};
18+
19+
} // namespace dev
20+
21+
using dev::TouchCst3240;
22+
extern dev::TouchCst3240 haspTouch;
23+
24+
#endif // ARDUINO
25+
26+
#endif // HASP_CST3240_TOUCH_DRIVER_H

src/hasp/hasp_dispatch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void dispatch_topic_payload(const char* topic, const char* payload, bool update,
452452
}
453453
#endif
454454

455-
#if defined(HASP_USE_CUSTOM)
455+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
456456
if(topic == strstr_P(topic, PSTR(MQTT_TOPIC_CUSTOM "/"))) { // startsWith custom
457457
topic += 7u;
458458
custom_topic_payload(topic, (char*)payload, source);
@@ -1295,7 +1295,7 @@ void dispatch_send_sensordata(const char*, const char*, uint8_t source)
12951295

12961296
haspDevice.get_sensors(doc);
12971297

1298-
#if defined(HASP_USE_CUSTOM)
1298+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
12991299
custom_get_sensors(doc);
13001300
#endif
13011301

src/hasp/hasp_task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void task_every_second_cb(lv_task_t* task)
3232
telnetEverySecond();
3333
#endif
3434

35-
#if defined(HASP_USE_CUSTOM)
35+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
3636
custom_every_second();
3737
#endif
3838
// debugEverySecond();
@@ -53,7 +53,7 @@ void task_every_second_cb(lv_task_t* task)
5353
break;
5454

5555
case 3:
56-
#if defined(HASP_USE_CUSTOM)
56+
#if defined(HASP_USE_CUSTOM) && HASP_USE_CUSTOM > 0
5757
custom_every_5seconds();
5858
#endif
5959
break;

0 commit comments

Comments
 (0)