Add optional cyd_35r (ESP32-3248S035) with 480x320 UI; default remains 2.8.
This commit is contained in:
@@ -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,15 +45,15 @@ if (-not (Test-Path $bootApp)) {
|
||||
}
|
||||
Copy-Item $bootApp (Join-Path $dst "boot_app0.bin") -Force
|
||||
|
||||
$git = (git -C $root rev-parse --short HEAD).Trim()
|
||||
$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 climate dashboard (cyd_28r)",
|
||||
"name: CYD temperature ($dstName)",
|
||||
"git: $git",
|
||||
"date: $date",
|
||||
"board: ESP32-2432S028R (ILI9341)",
|
||||
"dht: GPIO22",
|
||||
$boardLine,
|
||||
"flash_size: 4MB",
|
||||
"offsets:",
|
||||
" 0x1000 bootloader.bin",
|
||||
@@ -49,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)"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
; CYD ESP32-2432S028R — LVGL 温湿度仪表盘
|
||||
; CYD ESP32-2432S028R <EFBFBD><EFBFBD>?LVGL 温湿度仪表盘
|
||||
; DHT11 DATA -> GPIO22
|
||||
|
||||
[platformio]
|
||||
@@ -46,12 +46,12 @@ build_flags =
|
||||
-D LV_CONF_INCLUDE_SIMPLE=1
|
||||
-I include
|
||||
|
||||
; 标准 CYD 2.8" 电阻屏 (ILI9341)
|
||||
; 标准 CYD 2.8" 电阻<EFBFBD><EFBFBD>?(ILI9341)
|
||||
[env:cyd_28r]
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
|
||||
; 颜色反相版本(若画面色偏/发白可改用此环境)
|
||||
; 颜色反相版本(若画面色偏/发白可改用此环境<EFBFBD><EFBFBD>?
|
||||
[env:cyd_28r_inv]
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
@@ -65,3 +65,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
|
||||
|
||||
|
||||
28
src/main.cpp
28
src/main.cpp
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user