Add optional cyd_35r (ESP32-3248S035) with 480x320 UI; default remains 2.8.

This commit is contained in:
2026-10-23 16:24:19 +08:00
parent 39081d2a2f
commit de177b281b
3 changed files with 98 additions and 21 deletions

View File

@@ -11,7 +11,11 @@
#include <math.h>
#define DHT_PIN 22
#if defined(CYD_BOARD_3248S035)
#define TFT_BL_PIN 27
#else
#define TFT_BL_PIN 21
#endif
#define XPT2046_IRQ 36
#define XPT2046_MOSI 32
@@ -19,8 +23,13 @@
#define XPT2046_CLK 25
#define XPT2046_CS 33
#if defined(CYD_BOARD_3248S035)
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 320
#else
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#endif
#define DHT_READ_MS 2500
#define DHT_FAIL_TOLERANCE 3
#define EMA_ALPHA 0.35f
@@ -28,16 +37,29 @@
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))
/* Layout grid — every region has exclusive space, no overlaps */
#if defined(CYD_BOARD_3248S035)
#define UI_M 10
#define UI_G 10
#define UI_HDR_H 32
#define UI_GAUGE_H 168
#define UI_GAUGE_W 225
#define UI_ARC 120
#else
#define UI_M 6
#define UI_G 6
#define UI_HDR_H 22 /* single-row header; must clear before gauges */
#define UI_HDR_H 22
#define UI_GAUGE_H 124
#define UI_GAUGE_W 151
#define UI_ARC 90
#endif
#define UI_BOT_Y (UI_HDR_H + UI_G + UI_GAUGE_H + UI_G) /* 158 */
#define UI_BOT_H (SCREEN_HEIGHT - UI_BOT_Y - UI_M) /* 76 */
#define UI_BOT_W (SCREEN_WIDTH - 2 * UI_M) /* 308 */
#if defined(CYD_BOARD_3248S035)
#define UI_INFO_W 180
#else
#define UI_INFO_W 124
#endif
#define UI_CHART_W (UI_BOT_W - 12 - UI_INFO_W - UI_G) /* ~160 */
static const lv_color_t COL_BG = lv_color_hex(0x0A1018);
@@ -566,7 +588,11 @@ void setup() {
touchscreen.begin(touchscreenSPI);
touchscreen.setRotation(2);
#if defined(CYD_BOARD_3248S035)
lv_display_t *disp = lv_tft_espi_create(320, 480, draw_buf, sizeof(draw_buf));
#else
lv_display_t *disp = lv_tft_espi_create(240, 320, draw_buf, sizeof(draw_buf));
#endif
lv_display_set_rotation(disp, LV_DISPLAY_ROTATION_270);
lv_indev_t *indev = lv_indev_create();