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.
|
# Export firmware bins from PlatformIO build.
|
||||||
# Usage:
|
# Default: 2.8" (cyd_28r -> firmware/cyd_28r)
|
||||||
# .\firmware\export_from_build.ps1
|
# 3.5": .\firmware\export_from_build.ps1 -Env cyd_35r
|
||||||
# .\firmware\export_from_build.ps1 -SkipBuild
|
# (only after: pio run -e cyd_35r)
|
||||||
|
|
||||||
param([switch]$SkipBuild)
|
param(
|
||||||
|
[switch]$SkipBuild,
|
||||||
|
[ValidateSet("cyd_28r", "cyd_35r")]
|
||||||
|
[string]$Env = "cyd_28r"
|
||||||
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||||
Set-Location $root
|
Set-Location $root
|
||||||
|
|
||||||
|
$env:Path = "C:\Users\dsx2016\AppData\Local\Programs\Python\Python312\Scripts;" + $env:Path
|
||||||
|
|
||||||
if (-not $SkipBuild) {
|
if (-not $SkipBuild) {
|
||||||
pio run -e cyd_28r
|
pio run -e $Env
|
||||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||||
}
|
}
|
||||||
|
|
||||||
$src = Join-Path $root ".pio\build\cyd_28r"
|
$src = Join-Path $root (".pio\build\" + $Env)
|
||||||
$dst = Join-Path $root "firmware\cyd_28r"
|
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
|
New-Item -ItemType Directory -Force -Path $dst | Out-Null
|
||||||
|
|
||||||
Copy-Item (Join-Path $src "bootloader.bin") $dst -Force
|
foreach ($f in @("bootloader.bin", "partitions.bin", "firmware.bin")) {
|
||||||
Copy-Item (Join-Path $src "partitions.bin") $dst -Force
|
$p = Join-Path $src $f
|
||||||
Copy-Item (Join-Path $src "firmware.bin") $dst -Force
|
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"
|
$bootApp = Join-Path $env:USERPROFILE ".platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin"
|
||||||
if (-not (Test-Path $bootApp)) {
|
if (-not (Test-Path $bootApp)) {
|
||||||
@@ -28,20 +45,15 @@ if (-not (Test-Path $bootApp)) {
|
|||||||
}
|
}
|
||||||
Copy-Item $bootApp (Join-Path $dst "boot_app0.bin") -Force
|
Copy-Item $bootApp (Join-Path $dst "boot_app0.bin") -Force
|
||||||
|
|
||||||
$git = "nogit"
|
$git = ""
|
||||||
try {
|
try { $git = (git -C $root rev-parse --short HEAD).Trim() } catch { $git = "unknown" }
|
||||||
$git = (git -C $root rev-parse --short HEAD 2>$null).Trim()
|
|
||||||
if (-not $git) { $git = "nogit" }
|
|
||||||
} catch { $git = "nogit" }
|
|
||||||
|
|
||||||
$date = Get-Date -Format "yyyy-MM-dd"
|
$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 = @(
|
$lines = @(
|
||||||
"name: CYD GY30 light dashboard (cyd_28r)",
|
"name: CYD gy30test ($dstName)",
|
||||||
"git: $git",
|
"git: $git",
|
||||||
"date: $date",
|
"date: $date",
|
||||||
"board: ESP32-2432S028R (ILI9341)",
|
$boardLine,
|
||||||
"gy30: SDA=GPIO22 SCL=GPIO27",
|
|
||||||
"flash_size: 4MB",
|
"flash_size: 4MB",
|
||||||
"offsets:",
|
"offsets:",
|
||||||
" 0x1000 bootloader.bin",
|
" 0x1000 bootloader.bin",
|
||||||
@@ -54,4 +66,22 @@ foreach ($h in $hashes) {
|
|||||||
$lines += (" {0,-15} {1}" -f (Split-Path $h.Path -Leaf), $h.Hash)
|
$lines += (" {0,-15} {1}" -f (Split-Path $h.Path -Leaf), $h.Hash)
|
||||||
}
|
}
|
||||||
$lines | Set-Content -Encoding utf8 (Join-Path $dst "VERSION.txt")
|
$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 GY30(BH1750) 光照仪表盘
|
; CYD ESP32-2432S028R �LVGL GY30(BH1750) 光照仪表�
|
||||||
; GY30 SDA -> GPIO22, SCL -> GPIO27
|
; GY30 SDA -> GPIO22, SCL -> GPIO27
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
@@ -46,12 +46,12 @@ build_flags =
|
|||||||
-D LV_CONF_INCLUDE_SIMPLE=1
|
-D LV_CONF_INCLUDE_SIMPLE=1
|
||||||
-I include
|
-I include
|
||||||
|
|
||||||
; 标准 CYD 2.8" 电阻屏 (ILI9341)
|
; æ ‡å‡† CYD 2.8" 电阻å±?(ILI9341)
|
||||||
[env:cyd_28r]
|
[env:cyd_28r]
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
|
|
||||||
; 颜色反相版本(若画面色偏/发白可改用此环境)
|
; 颜色å<EFBFBD><EFBFBD>相版本(若画é<EFBFBD>¢è‰²å<EFBFBD><EFBFBD>/å<>‘白å<C2BD>¯æ”¹ç”¨æ¤çŽ¯å¢ƒï¼?
|
||||||
[env:cyd_28r_inv]
|
[env:cyd_28r_inv]
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
@@ -65,3 +65,19 @@ build_flags =
|
|||||||
-D ST7789_DRIVER=1
|
-D ST7789_DRIVER=1
|
||||||
-D TFT_RGB_ORDER=TFT_BGR
|
-D TFT_RGB_ORDER=TFT_BGR
|
||||||
-D TFT_INVERSION_ON=1
|
-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
|
||||||
|
|
||||||
|
|||||||
26
src/main.cpp
26
src/main.cpp
@@ -13,7 +13,11 @@
|
|||||||
|
|
||||||
#define I2C_SDA 22
|
#define I2C_SDA 22
|
||||||
#define I2C_SCL 27
|
#define I2C_SCL 27
|
||||||
|
#if defined(CYD_BOARD_3248S035)
|
||||||
|
#define TFT_BL_PIN 27
|
||||||
|
#else
|
||||||
#define TFT_BL_PIN 21
|
#define TFT_BL_PIN 21
|
||||||
|
#endif
|
||||||
|
|
||||||
#define XPT2046_IRQ 36
|
#define XPT2046_IRQ 36
|
||||||
#define XPT2046_MOSI 32
|
#define XPT2046_MOSI 32
|
||||||
@@ -21,8 +25,13 @@
|
|||||||
#define XPT2046_CLK 25
|
#define XPT2046_CLK 25
|
||||||
#define XPT2046_CS 33
|
#define XPT2046_CS 33
|
||||||
|
|
||||||
|
#if defined(CYD_BOARD_3248S035)
|
||||||
|
#define SCREEN_WIDTH 480
|
||||||
|
#define SCREEN_HEIGHT 320
|
||||||
|
#else
|
||||||
#define SCREEN_WIDTH 320
|
#define SCREEN_WIDTH 320
|
||||||
#define SCREEN_HEIGHT 240
|
#define SCREEN_HEIGHT 240
|
||||||
|
#endif
|
||||||
#define GY_READ_MS 500
|
#define GY_READ_MS 500
|
||||||
#define GY_FAIL_TOLERANCE 3
|
#define GY_FAIL_TOLERANCE 3
|
||||||
#define EMA_ALPHA 0.35f
|
#define EMA_ALPHA 0.35f
|
||||||
@@ -31,16 +40,29 @@
|
|||||||
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))
|
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))
|
||||||
|
|
||||||
/* Layout grid — every region has exclusive space, no overlaps */
|
/* 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_M 6
|
||||||
#define UI_G 6
|
#define UI_G 6
|
||||||
#define UI_HDR_H 22
|
#define UI_HDR_H 22
|
||||||
#define UI_GAUGE_H 124
|
#define UI_GAUGE_H 124
|
||||||
#define UI_GAUGE_W 151
|
#define UI_GAUGE_W 151
|
||||||
#define UI_ARC 90
|
#define UI_ARC 90
|
||||||
|
#endif
|
||||||
#define UI_BOT_Y (UI_HDR_H + UI_G + UI_GAUGE_H + UI_G) /* 158 */
|
#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_H (SCREEN_HEIGHT - UI_BOT_Y - UI_M) /* 76 */
|
||||||
#define UI_BOT_W (SCREEN_WIDTH - 2 * UI_M) /* 308 */
|
#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
|
#define UI_INFO_W 124
|
||||||
|
#endif
|
||||||
#define UI_CHART_W (UI_BOT_W - 12 - UI_INFO_W - UI_G) /* ~160 */
|
#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);
|
static const lv_color_t COL_BG = lv_color_hex(0x0A1018);
|
||||||
@@ -569,7 +591,11 @@ void setup() {
|
|||||||
touchscreen.begin(touchscreenSPI);
|
touchscreen.begin(touchscreenSPI);
|
||||||
touchscreen.setRotation(2);
|
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));
|
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_display_set_rotation(disp, LV_DISPLAY_ROTATION_270);
|
||||||
|
|
||||||
lv_indev_t *indev = lv_indev_create();
|
lv_indev_t *indev = lv_indev_create();
|
||||||
|
|||||||
Reference in New Issue
Block a user