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

This commit is contained in:
2026-10-23 16:24:18 +08:00
parent 51a35f7553
commit 1b2fe27fd9
3 changed files with 97 additions and 25 deletions

View File

@@ -1,26 +1,43 @@
# Rebuild (optional) and refresh firmware/cyd_28r from PlatformIO build output.
# Usage:
# .\firmware\export_from_build.ps1
# .\firmware\export_from_build.ps1 -SkipBuild
# Export firmware bins from PlatformIO build.
# Default: 2.8" (cyd_28r -> firmware/cyd_28r)
# 3.5": .\firmware\export_from_build.ps1 -Env cyd_35r
# (only after: pio run -e cyd_35r)
param([switch]$SkipBuild)
param(
[switch]$SkipBuild,
[ValidateSet("cyd_28r", "cyd_35r")]
[string]$Env = "cyd_28r"
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $root
$env:Path = "C:\Users\dsx2016\AppData\Local\Programs\Python\Python312\Scripts;" + $env:Path
if (-not $SkipBuild) {
pio run -e cyd_28r
pio run -e $Env
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
$src = Join-Path $root ".pio\build\cyd_28r"
$dst = Join-Path $root "firmware\cyd_28r"
$src = Join-Path $root (".pio\build\" + $Env)
if ($Env -eq "cyd_35r") {
$dstName = "cyd_35r"
$boardLine = "board: ESP32-3248S035 (ST7796)"
$boardIdHint = "esp32-3248s035"
} else {
$dstName = "cyd_28r"
$boardLine = "board: ESP32-2432S028R (ILI9341)"
$boardIdHint = "esp32-2432s028"
}
$dst = Join-Path $root ("firmware\" + $dstName)
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item (Join-Path $src "bootloader.bin") $dst -Force
Copy-Item (Join-Path $src "partitions.bin") $dst -Force
Copy-Item (Join-Path $src "firmware.bin") $dst -Force
foreach ($f in @("bootloader.bin", "partitions.bin", "firmware.bin")) {
$p = Join-Path $src $f
if (-not (Test-Path $p)) { Write-Error "Missing build artifact: $p — build with: pio run -e $Env" }
Copy-Item $p $dst -Force
}
$bootApp = Join-Path $env:USERPROFILE ".platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin"
if (-not (Test-Path $bootApp)) {
@@ -28,20 +45,15 @@ if (-not (Test-Path $bootApp)) {
}
Copy-Item $bootApp (Join-Path $dst "boot_app0.bin") -Force
$git = "nogit"
try {
$git = (git -C $root rev-parse --short HEAD 2>$null).Trim()
if (-not $git) { $git = "nogit" }
} catch { $git = "nogit" }
$git = ""
try { $git = (git -C $root rev-parse --short HEAD).Trim() } catch { $git = "unknown" }
$date = Get-Date -Format "yyyy-MM-dd"
$hashes = Get-FileHash (Join-Path $dst "*.bin") -Algorithm SHA256
$hashes = Get-ChildItem (Join-Path $dst "*.bin") | Get-FileHash -Algorithm SHA256
$lines = @(
"name: CYD SGP30 air quality dashboard (cyd_28r)",
"name: CYD sgp30test ($dstName)",
"git: $git",
"date: $date",
"board: ESP32-2432S028R (ILI9341)",
"sgp30: SDA=GPIO22 SCL=GPIO27",
$boardLine,
"flash_size: 4MB",
"offsets:",
" 0x1000 bootloader.bin",
@@ -54,4 +66,22 @@ foreach ($h in $hashes) {
$lines += (" {0,-15} {1}" -f (Split-Path $h.Path -Leaf), $h.Hash)
}
$lines | Set-Content -Encoding utf8 (Join-Path $dst "VERSION.txt")
Write-Host "Exported -> $dst (git $git)"
# Keep / refresh meta.json boardId for catalog filtering
$metaPath = Join-Path $dst "meta.json"
if (Test-Path $metaPath) {
try {
$meta = Get-Content $metaPath -Raw | ConvertFrom-Json
$meta.boardId = $boardIdHint
if ($Env -eq "cyd_35r" -and $meta.name -notmatch "3\.5") {
$meta.name = ($meta.name -replace "\s*$","") + " (3.5\")"
}
$meta | ConvertTo-Json -Depth 8 | Set-Content -Encoding utf8 $metaPath
} catch {
Write-Host "meta.json update skipped: $_"
}
} elseif ($Env -eq "cyd_35r") {
Write-Host "Note: add firmware/cyd_35r/meta.json with boardId=$boardIdHint for the web catalog"
}
Write-Host "Exported -> $dst (env=$Env git=$git)"

View File

@@ -1,4 +1,4 @@
; CYD ESP32-2432S028R — LVGL SGP30 空气质量仪表盘
; CYD ESP32-2432S028R â€?LVGL SGP30 空气质é‡<EFBFBD>仪表ç›?
; SGP30 SDA -> GPIO22, SCL -> GPIO27
[platformio]
@@ -47,12 +47,12 @@ build_flags =
-D LV_CONF_INCLUDE_SIMPLE=1
-I include
; 标准 CYD 2.8" 电阻屏 (ILI9341)
; 标准 CYD 2.8" 电阻�(ILI9341)
[env:cyd_28r]
build_flags =
${env.build_flags}
; 颜色反相版本(若画面色偏/发白可改用此环境)
; 颜色å<EFBFBD><EFBFBD>相版本(若画é<EFBFBD>¢è‰²å<EFBFBD><EFBFBD>/å<>‘白å<C2BD>¯æ”¹ç”¨æ­¤çŽ¯å¢ƒï¼?
[env:cyd_28r_inv]
build_flags =
${env.build_flags}
@@ -66,3 +66,19 @@ build_flags =
-D ST7789_DRIVER=1
-D TFT_RGB_ORDER=TFT_BGR
-D TFT_INVERSION_ON=1
; Optional 3.5" CYD ESP32-3248S035 (ST7796 resistive). Default remains cyd_28r.
; Build: pio run -e cyd_35r
[env:cyd_35r]
build_flags =
${env.build_flags}
-U ILI9341_2_DRIVER
-D ST7796_DRIVER=1
-U TFT_WIDTH
-U TFT_HEIGHT
-D TFT_WIDTH=320
-D TFT_HEIGHT=480
-U TFT_BL
-D TFT_BL=27
-D CYD_BOARD_3248S035=1

View File

@@ -13,7 +13,11 @@
#define I2C_SDA 22
#define I2C_SCL 27
#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
@@ -21,8 +25,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 SGP_READ_MS 1000
#define SGP_FAIL_TOLERANCE 3
#define EMA_ALPHA 0.35f
@@ -35,16 +44,29 @@
#define TVOC_ARC_MAX 1000
/* 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
#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);
@@ -600,7 +622,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();