Skip to content
C

add version selector and bump 1.2.5 for tyre-temp support

YU CHIH CHANG482db7bb5343
diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml
index ff4f6f3..5b51537 100644
--- a/.github/workflows/deploy-pages.yml
+++ b/.github/workflows/deploy-pages.yml
@@ -41,6 +41,7 @@ jobs:
const installerRoot = resolve("installer");
const indexPath = resolve(installerRoot, "index.html");
const manifestPath = resolve(installerRoot, "manifest.json");
+ const releasesPath = resolve(installerRoot, "releases.json");
async function requireNonEmptyFile(filePath, label) {
let details;
@@ -61,12 +62,12 @@ jobs:
}
}
- function installerPath(manifestPartPath) {
+ function installerPath(manifestDirectory, manifestPartPath) {
if (typeof manifestPartPath !== "string" || manifestPartPath.length === 0) {
throw new Error("Every manifest part must have a non-empty string path.");
}
- const resolvedPath = resolve(installerRoot, manifestPartPath);
+ const resolvedPath = resolve(manifestDirectory, manifestPartPath);
const relativePath = relative(installerRoot, resolvedPath);
if (
isAbsolute(relativePath) ||
@@ -81,14 +82,28 @@ jobs:
async function main() {
await requireNonEmptyFile(indexPath, "Installer index");
await requireNonEmptyFile(manifestPath, "Installer manifest");
+ await requireNonEmptyFile(releasesPath, "Installer release index");
- const manifestNames = (await readdir(installerRoot)).filter((name) =>
+ const rootManifestNames = (await readdir(installerRoot)).filter((name) =>
/^manifest(?:-[a-z0-9-]+)?\.json$/i.test(name),
);
+ const releaseIndex = JSON.parse(await readFile(releasesPath, "utf8"));
+ const releases = Array.isArray(releaseIndex.versions) ? releaseIndex.versions : [];
+
+ if (releases.length === 0 || releases.length > 5) {
+ throw new Error("installer/releases.json must contain between 1 and 5 versions.");
+ }
+
+ const manifestPaths = [
+ ...rootManifestNames.map((name) => resolve(installerRoot, name)),
+ ...releases.flatMap((release) =>
+ Object.values(release.manifests ?? {}).map((path) => resolve(installerRoot, path)),
+ ),
+ ];
let binaryCount = 0;
- for (const manifestName of manifestNames) {
- const currentManifestPath = resolve(installerRoot, manifestName);
+ for (const currentManifestPath of manifestPaths) {
+ const manifestName = relative(installerRoot, currentManifestPath);
await requireNonEmptyFile(currentManifestPath, `Installer manifest "${manifestName}"`);
let manifest;
@@ -109,7 +124,7 @@ jobs:
}
for (const part of parts) {
- const binaryPath = installerPath(part?.path);
+ const binaryPath = installerPath(resolve(currentManifestPath, ".."), part?.path);
await requireNonEmptyFile(
binaryPath,
`${manifestName} binary "${part.path}"`,
@@ -119,7 +134,7 @@ jobs:
}
console.log(
- `Validated installer, ${manifestNames.length} manifests, and ${binaryCount} binary references.`,
+ `Validated installer, ${manifestPaths.length} manifests, and ${binaryCount} binary references.`,
);
}
diff --git a/README.md b/README.md
index 77f45f8..50450c1 100644
--- a/README.md
+++ b/README.md
@@ -197,6 +197,11 @@ The application images are generated at:
For a release build that also synchronizes the version, copies both images into
`installer/firmware/`, and validates both installer manifests, run:
+First add a short change summary for the new version to
+`installer/release-notes.json`. The publish command archives both display
+variants for the installer and automatically keeps only the five most recent
+versions.
+
```bash
npm run publish:firmware -- 1.2.5
```
diff --git a/README.zh-TW.md b/README.zh-TW.md
index 29d72e2..42c0a8e 100644
--- a/README.zh-TW.md
+++ b/README.zh-TW.md
@@ -193,6 +193,9 @@ pio run -e esp32 -e esp32-st7789
若要建立正式發佈版本,同時同步版本號、複製兩份 image 到
`installer/firmware/`,並驗證兩份 installer manifest,請執行:
+請先在 `installer/release-notes.json` 加入新版本的簡短差異說明。發布指令會將
+兩種螢幕版本封存給 Installer 使用,並自動只保留最近五個版本。
+
```bash
npm run publish:firmware -- 1.2.5
```
diff --git a/VERSION b/VERSION
index e8ea05d..c813fe1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.4
+1.2.5
diff --git a/include/version.h b/include/version.h
index 458eb85..df9f2ca 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1,3 +1,3 @@
#pragma once
-inline constexpr char GT7_DASH_VERSION[] = "1.2.4";
+inline constexpr char GT7_DASH_VERSION[] = "1.2.5";
diff --git a/installer/firmware/firmware-ili9341.bin b/installer/firmware/firmware-ili9341.bin
index f0ca128..81a3046 100644
Binary files a/installer/firmware/firmware-ili9341.bin and b/installer/firmware/firmware-ili9341.bin differ
diff --git a/installer/firmware/firmware-st7789.bin b/installer/firmware/firmware-st7789.bin
index 0bd5bce..d85c2fa 100644
Binary files a/installer/firmware/firmware-st7789.bin and b/installer/firmware/firmware-st7789.bin differ
diff --git a/installer/index.html b/installer/index.html
index 5271e5a..2cc3697 100644
--- a/installer/index.html
+++ b/installer/index.html
@@ -103,15 +103,21 @@
.release-version {
display: inline-flex;
align-items: center;
+ gap: 7px;
padding: 6px 10px;
border: 1px solid rgba(56, 189, 248, 0.28);
border-radius: 999px;
background: rgba(14, 165, 233, 0.1);
color: #bae6fd;
+ cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
font-size: 0.85rem;
}
+ .release-version:hover { background: rgba(14, 165, 233, 0.18); }
+
+ .version-chevron { font-size: 0.7rem; }
+
.version-actions {
display: flex;
flex-wrap: wrap;
@@ -207,6 +213,87 @@
text-align: center;
}
+ .version-dialog {
+ width: min(calc(100% - 32px), 460px);
+ padding: 0;
+ border: 1px solid rgba(148, 163, 184, 0.28);
+ border-radius: 18px;
+ background: #111c2c;
+ color: #e7eef8;
+ box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
+ }
+
+ .version-dialog::backdrop { background: rgba(2, 6, 23, 0.72); }
+
+ .version-dialog-content { padding: 22px; }
+
+ .version-dialog-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ }
+
+ .version-dialog h2 { margin: 0; font-size: 1.15rem; }
+
+ .version-dialog-close {
+ border: 0;
+ background: transparent;
+ color: #94a3b8;
+ cursor: pointer;
+ font-size: 1.35rem;
+ }
+
+ .version-list { display: grid; gap: 9px; margin-top: 18px; }
+
+ .version-option {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ width: 100%;
+ padding: 12px 14px;
+ border: 1px solid rgba(148, 163, 184, 0.22);
+ border-radius: 10px;
+ background: #172033;
+ color: #e7eef8;
+ cursor: pointer;
+ font: inherit;
+ text-align: left;
+ }
+
+ .version-option:hover { border-color: rgba(56, 189, 248, 0.5); }
+
+ .version-option[aria-current="true"] {
+ border-color: #38bdf8;
+ background: rgba(14, 165, 233, 0.13);
+ }
+
+ .version-option small { color: #7dd3fc; }
+
+ .version-notes {
+ margin: 14px 0 0;
+ padding-left: 20px;
+ color: #b7c5d8;
+ font-size: 0.85rem;
+ line-height: 1.55;
+ }
+
+ .version-dialog-confirm {
+ width: 100%;
+ margin-top: 18px;
+ padding: 11px 16px;
+ border: 0;
+ border-radius: 10px;
+ background: #0ea5e9;
+ color: #fff;
+ cursor: pointer;
+ font: inherit;
+ font-weight: 750;
+ }
+
+ .version-dialog-confirm:hover { background: #38bdf8; }
+
.connect-button {
width: 280px;
max-width: 100%;
@@ -324,11 +411,13 @@
<div class="title-copy">
<h1>ESP32 GT7 Dashboard</h1>
<div class="version-actions">
- <span
+ <button
class="release-version"
- id="release-version"
+ id="version-menu-button"
+ type="button"
+ aria-haspopup="dialog"
aria-live="polite"
- >Version loading…</span>
+ ><span id="release-version">Version loading…</span><span class="version-chevron" aria-hidden="true">▼</span></button>
<a
class="kofi-button"
href="https://ko-fi.com/caa1211"
@@ -362,8 +451,8 @@
<div class="firmware-choice">
<label for="display-controller">Display controller</label>
<select id="display-controller">
- <option value="manifest.json">ILI9341 (standard)</option>
- <option value="manifest-st7789.json">ST7789 (alternate)</option>
+ <option value="ili9341">ILI9341 (standard)</option>
+ <option value="st7789">ST7789 (alternate)</option>
</select>
<p>Select the controller fitted to your ESP32-2432S028.</p>
</div>
@@ -408,32 +497,111 @@
</footer>
</main>
+ <dialog class="version-dialog" id="version-dialog">
+ <div class="version-dialog-content">
+ <div class="version-dialog-header">
+ <h2>Select firmware version</h2>
+ <button class="version-dialog-close" id="version-dialog-close" type="button" aria-label="Close">×</button>
+ </div>
+ <div class="version-list" id="version-list"></div>
+ <ul class="version-notes" id="version-notes"></ul>
+ <button class="version-dialog-confirm" id="version-dialog-confirm" type="button">Use selected version</button>
+ </div>
+ </dialog>
+
<script>
const controllerSelect = document.getElementById("display-controller");
const installButton = document.getElementById("install-button");
const versionLabel = document.getElementById("release-version");
+ const versionMenuButton = document.getElementById("version-menu-button");
+ const versionDialog = document.getElementById("version-dialog");
+ const versionDialogClose = document.getElementById("version-dialog-close");
+ const versionDialogConfirm = document.getElementById("version-dialog-confirm");
+ const versionList = document.getElementById("version-list");
+ const versionNotes = document.getElementById("version-notes");
+ let releases = [];
+ let selectedVersion = "";
+ let previewVersion = "";
- function selectManifest(manifestPath) {
- installButton.setAttribute("manifest", manifestPath);
+ function selectedRelease() {
+ return releases.find((release) => release.version === selectedVersion);
+ }
- fetch(manifestPath, { cache: "no-store" })
- .then((response) => {
- if (!response.ok) throw new Error(`HTTP ${response.status}`);
- return response.json();
- })
- .then((manifest) => {
- versionLabel.textContent = `Version ${manifest.version}`;
- })
- .catch(() => {
- versionLabel.textContent = "Version unavailable";
+ function selectManifest() {
+ const release = selectedRelease();
+ if (!release) return;
+
+ const manifestPath = release.manifests[controllerSelect.value];
+ installButton.setAttribute("manifest", manifestPath);
+ versionLabel.textContent = `Version ${release.version}`;
+
+ }
+
+ function renderVersionDialog() {
+ const release = releases.find((item) => item.version === previewVersion);
+ if (!release) return;
+
+ versionList.replaceChildren();
+ releases.forEach((item, index) => {
+ const option = document.createElement("button");
+ option.type = "button";
+ option.className = "version-option";
+ option.dataset.version = item.version;
+ option.setAttribute("aria-current", String(item.version === previewVersion));
+ const label = document.createElement("span");
+ label.textContent = `Version ${item.version}`;
+ const status = document.createElement("small");
+ status.textContent = index === 0 ? "Latest" : "";
+ option.append(label, status);
+ option.addEventListener("click", () => {
+ previewVersion = item.version;
+ renderVersionDialog();
});
+ versionList.append(option);
+ });
+
+ versionNotes.replaceChildren();
+ for (const note of release.notes ?? []) {
+ const item = document.createElement("li");
+ item.textContent = note;
+ versionNotes.append(item);
+ }
+
+ versionDialogConfirm.textContent = `Use Version ${release.version}`;
}
controllerSelect.addEventListener("change", () => {
- selectManifest(controllerSelect.value);
+ selectManifest();
+ });
+
+ versionMenuButton.addEventListener("click", () => {
+ if (releases.length === 0) return;
+ previewVersion = selectedVersion;
+ renderVersionDialog();
+ versionDialog.showModal();
+ });
+
+ versionDialogClose.addEventListener("click", () => versionDialog.close());
+ versionDialogConfirm.addEventListener("click", () => {
+ selectedVersion = previewVersion;
+ selectManifest();
+ versionDialog.close();
});
- selectManifest(controllerSelect.value);
+ fetch("releases.json", { cache: "no-store" })
+ .then((response) => {
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
+ return response.json();
+ })
+ .then((releaseIndex) => {
+ releases = releaseIndex.versions.slice(0, 5);
+ selectedVersion = releases[0]?.version ?? "";
+ selectManifest();
+ })
+ .catch(() => {
+ versionLabel.textContent = "Version unavailable";
+ versionMenuButton.disabled = true;
+ });
</script>
</body>
</html>
diff --git a/installer/manifest-st7789.json b/installer/manifest-st7789.json
index a667d85..3034f50 100644
--- a/installer/manifest-st7789.json
+++ b/installer/manifest-st7789.json
@@ -1,6 +1,6 @@
{
"name": "ESP32 GT7 Dashboard (ST7789)",
- "version": "1.2.4",
+ "version": "1.2.5",
"new_install_prompt_erase": true,
"builds": [
{
diff --git a/installer/manifest.json b/installer/manifest.json
index 2d9160f..4b03b87 100644
--- a/installer/manifest.json
+++ b/installer/manifest.json
@@ -1,6 +1,6 @@
{
"name": "ESP32 GT7 Dashboard (ILI9341)",
- "version": "1.2.4",
+ "version": "1.2.5",
"new_install_prompt_erase": true,
"builds": [
{
diff --git a/installer/release-notes.json b/installer/release-notes.json
new file mode 100644
index 0000000..96d7e38
--- /dev/null
+++ b/installer/release-notes.json
@@ -0,0 +1,8 @@
+{
+ "1.2.5": [
+ "Added tyre-temperature colour display."
+ ],
+ "1.2.4": [
+ "Added ST7789 display support."
+ ]
+}
diff --git a/installer/releases.json b/installer/releases.json
new file mode 100644
index 0000000..3dcb32f
--- /dev/null
+++ b/installer/releases.json
@@ -0,0 +1,24 @@
+{
+ "versions": [
+ {
+ "version": "1.2.5",
+ "notes": [
+ "Added tyre-temperature colour display."
+ ],
+ "manifests": {
+ "ili9341": "versions/1.2.5/manifest-ili9341.json",
+ "st7789": "versions/1.2.5/manifest-st7789.json"
+ }
+ },
+ {
+ "version": "1.2.4",
+ "notes": [
+ "Added ST7789 display support."
+ ],
+ "manifests": {
+ "ili9341": "versions/1.2.4/manifest-ili9341.json",
+ "st7789": "versions/1.2.4/manifest-st7789.json"
+ }
+ }
+ ]
+}
diff --git a/installer/versions/1.2.4/boot_app0.bin b/installer/versions/1.2.4/boot_app0.bin
new file mode 100644
index 0000000..13562ca
Binary files /dev/null and b/installer/versions/1.2.4/boot_app0.bin differ
diff --git a/installer/versions/1.2.4/bootloader.bin b/installer/versions/1.2.4/bootloader.bin
new file mode 100644
index 0000000..d592359
Binary files /dev/null and b/installer/versions/1.2.4/bootloader.bin differ
diff --git a/installer/versions/1.2.4/firmware-ili9341.bin b/installer/versions/1.2.4/firmware-ili9341.bin
new file mode 100644
index 0000000..f0ca128
Binary files /dev/null and b/installer/versions/1.2.4/firmware-ili9341.bin differ
diff --git a/installer/versions/1.2.4/firmware-st7789.bin b/installer/versions/1.2.4/firmware-st7789.bin
new file mode 100644
index 0000000..0bd5bce
Binary files /dev/null and b/installer/versions/1.2.4/firmware-st7789.bin differ
diff --git a/installer/versions/1.2.4/firmware.bin b/installer/versions/1.2.4/firmware.bin
new file mode 100644
index 0000000..a3b79d6
Binary files /dev/null and b/installer/versions/1.2.4/firmware.bin differ
diff --git a/installer/versions/1.2.4/manifest-ili9341.json b/installer/versions/1.2.4/manifest-ili9341.json
new file mode 100644
index 0000000..a7b4be7
--- /dev/null
+++ b/installer/versions/1.2.4/manifest-ili9341.json
@@ -0,0 +1,16 @@
+{
+ "name": "ESP32 GT7 Dashboard (ILI9341)",
+ "version": "1.2.4",
+ "new_install_prompt_erase": true,
+ "builds": [
+ {
+ "chipFamily": "ESP32",
+ "parts": [
+ { "path": "bootloader.bin", "offset": 4096 },
+ { "path": "partitions.bin", "offset": 32768 },
+ { "path": "boot_app0.bin", "offset": 57344 },
+ { "path": "firmware-ili9341.bin", "offset": 65536 }
+ ]
+ }
+ ]
+}
diff --git a/installer/versions/1.2.4/manifest-st7789.json b/installer/versions/1.2.4/manifest-st7789.json
new file mode 100644
index 0000000..fe2c807
--- /dev/null
+++ b/installer/versions/1.2.4/manifest-st7789.json
@@ -0,0 +1,16 @@
+{
+ "name": "ESP32 GT7 Dashboard (ST7789)",
+ "version": "1.2.4",
+ "new_install_prompt_erase": true,
+ "builds": [
+ {
+ "chipFamily": "ESP32",
+ "parts": [
+ { "path": "bootloader.bin", "offset": 4096 },
+ { "path": "partitions.bin", "offset": 32768 },
+ { "path": "boot_app0.bin", "offset": 57344 },
+ { "path": "firmware-st7789.bin", "offset": 65536 }
+ ]
+ }
+ ]
+}
diff --git a/installer/versions/1.2.4/partitions.bin b/installer/versions/1.2.4/partitions.bin
new file mode 100644
index 0000000..1954582
Binary files /dev/null and b/installer/versions/1.2.4/partitions.bin differ
diff --git a/installer/versions/1.2.5/boot_app0.bin b/installer/versions/1.2.5/boot_app0.bin
new file mode 100644
index 0000000..13562ca
Binary files /dev/null and b/installer/versions/1.2.5/boot_app0.bin differ
diff --git a/installer/versions/1.2.5/bootloader.bin b/installer/versions/1.2.5/bootloader.bin
new file mode 100644
index 0000000..d592359
Binary files /dev/null and b/installer/versions/1.2.5/bootloader.bin differ
diff --git a/installer/versions/1.2.5/firmware-ili9341.bin b/installer/versions/1.2.5/firmware-ili9341.bin
new file mode 100644
index 0000000..81a3046
Binary files /dev/null and b/installer/versions/1.2.5/firmware-ili9341.bin differ
diff --git a/installer/versions/1.2.5/firmware-st7789.bin b/installer/versions/1.2.5/firmware-st7789.bin
new file mode 100644
index 0000000..d85c2fa
Binary files /dev/null and b/installer/versions/1.2.5/firmware-st7789.bin differ
diff --git a/installer/versions/1.2.5/manifest-ili9341.json b/installer/versions/1.2.5/manifest-ili9341.json
new file mode 100644
index 0000000..5c4fe8f
--- /dev/null
+++ b/installer/versions/1.2.5/manifest-ili9341.json
@@ -0,0 +1,28 @@
+{
+ "name": "ESP32 GT7 Dashboard (ILI9341)",
+ "version": "1.2.5",
+ "new_install_prompt_erase": true,
+ "builds": [
+ {
+ "chipFamily": "ESP32",
+ "parts": [
+ {
+ "path": "bootloader.bin",
+ "offset": 4096
+ },
+ {
+ "path": "partitions.bin",
+ "offset": 32768
+ },
+ {
+ "path": "boot_app0.bin",
+ "offset": 57344
+ },
+ {
+ "path": "firmware-ili9341.bin",
+ "offset": 65536
+ }
+ ]
+ }
+ ]
+}
diff --git a/installer/versions/1.2.5/manifest-st7789.json b/installer/versions/1.2.5/manifest-st7789.json
new file mode 100644
index 0000000..207287d
--- /dev/null
+++ b/installer/versions/1.2.5/manifest-st7789.json
@@ -0,0 +1,28 @@
+{
+ "name": "ESP32 GT7 Dashboard (ST7789)",
+ "version": "1.2.5",
+ "new_install_prompt_erase": true,
+ "builds": [
+ {
+ "chipFamily": "ESP32",
+ "parts": [
+ {
+ "path": "bootloader.bin",
+ "offset": 4096
+ },
+ {
+ "path": "partitions.bin",
+ "offset": 32768
+ },
+ {
+ "path": "boot_app0.bin",
+ "offset": 57344
+ },
+ {
+ "path": "firmware-st7789.bin",
+ "offset": 65536
+ }
+ ]
+ }
+ ]
+}
diff --git a/installer/versions/1.2.5/partitions.bin b/installer/versions/1.2.5/partitions.bin
new file mode 100644
index 0000000..1954582
Binary files /dev/null and b/installer/versions/1.2.5/partitions.bin differ
diff --git a/scripts/publish-firmware.mjs b/scripts/publish-firmware.mjs
index 5f64645..4dbe1bc 100644
--- a/scripts/publish-firmware.mjs
+++ b/scripts/publish-firmware.mjs
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { createHash } from "node:crypto";
-import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
+import { copyFile, mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
import { homedir } from "node:os";
import { dirname, join, relative, resolve } from "node:path";
import { spawnSync } from "node:child_process";
@@ -29,6 +29,10 @@ const manifestPaths = [
manifestPath,
join(projectDirectory, "installer", "manifest-st7789.json"),
];
+const releasesPath = join(projectDirectory, "installer", "releases.json");
+const releaseNotesPath = join(projectDirectory, "installer", "release-notes.json");
+const versionsDirectory = join(projectDirectory, "installer", "versions");
+const retainedReleaseCount = 5;
const versionPattern = /^\d+\.\d+\.\d+$/;
function displayPath(path) {
@@ -238,6 +242,82 @@ async function copyVerifiedBinary(source, destinationName, copiedFiles) {
console.log(`${destinationName}: ${size} bytes, SHA-256 ${await sha256(destination)}`);
}
+async function archiveRelease(version, manifests, copiedFiles, modifiedFiles) {
+ const notesByVersion = JSON.parse(await readFile(releaseNotesPath, "utf8"));
+ const notes = notesByVersion[version];
+
+ if (!Array.isArray(notes) || notes.length === 0) {
+ throw new Error(
+ `Add at least one short entry for ${version} to installer/release-notes.json.`,
+ );
+ }
+
+ const versionDirectory = join(versionsDirectory, version);
+ await mkdir(versionDirectory, { recursive: true });
+
+ for (const binaryName of [
+ "bootloader.bin",
+ "partitions.bin",
+ "boot_app0.bin",
+ ...variants.map((variant) => variant.firmwareName),
+ ]) {
+ const source = join(firmwareDirectory, binaryName);
+ const destination = join(versionDirectory, binaryName);
+ await copyFile(source, destination);
+ await verifyNonEmpty(destination);
+ copiedFiles.push(displayPath(destination));
+ }
+
+ const archivedManifests = {};
+ for (const { manifest } of manifests) {
+ const variant = manifest.name.includes("ST7789") ? variants[1] : variants[0];
+ const archivedManifestName = `manifest-${variant.id}.json`;
+ const archivedManifest = structuredClone(manifest);
+
+ for (const build of archivedManifest.builds ?? []) {
+ for (const part of build.parts ?? []) {
+ part.path = part.path.replace(/^firmware\//, "");
+ }
+ }
+
+ await writeIfChanged(
+ join(versionDirectory, archivedManifestName),
+ `${JSON.stringify(archivedManifest, null, 2)}\n`,
+ modifiedFiles,
+ );
+ archivedManifests[variant.id] = `versions/${version}/${archivedManifestName}`;
+ }
+
+ const existingReleases = JSON.parse(
+ (await fileContents(releasesPath)) ?? '{"versions":[]}',
+ );
+ const releaseEntry = {
+ version,
+ notes,
+ manifests: archivedManifests,
+ };
+ const versions = [
+ releaseEntry,
+ ...(existingReleases.versions ?? []).filter((entry) => entry.version !== version),
+ ].slice(0, retainedReleaseCount);
+
+ await writeIfChanged(
+ releasesPath,
+ `${JSON.stringify({ versions }, null, 2)}\n`,
+ modifiedFiles,
+ );
+
+ const retainedVersions = new Set(versions.map((entry) => entry.version));
+ for (const previousRelease of existingReleases.versions ?? []) {
+ if (!retainedVersions.has(previousRelease.version)) {
+ await rm(join(versionsDirectory, previousRelease.version), {
+ recursive: true,
+ force: true,
+ });
+ }
+ }
+}
+
async function main() {
const { suppliedVersion, skipBuild } = parseArguments();
const version = await resolveVersion(suppliedVersion);
@@ -286,6 +366,7 @@ async function main() {
manifests = await verifySynchronizedVersion(version);
await verifyManifestBinaries(manifests);
+ await archiveRelease(version, manifests, copiedFiles, modifiedFiles);
printSummary({ version, skipBuild, copiedFiles, modifiedFiles });
}
diff --git a/src/SHCustomProtocol.h b/src/SHCustomProtocol.h
index e55aaf4..cebbb8a 100644
--- a/src/SHCustomProtocol.h
+++ b/src/SHCustomProtocol.h
@@ -120,6 +120,7 @@ private:
String brakeBias = "0";
String brake = "0";
String lapInvalidated = "False";
+ float tyreTemperatures[4] = {NAN, NAN, NAN, NAN};
uint16_t touchX, touchY; // definisce i due interi per gestione touchscreen
int numButtons = 6; // Variabile per il numero di pulsanti
@@ -431,6 +432,11 @@ public:
brakeBias = String(fuelPercent, 0);
fuelAlertActive = String(fuelPercent, 1);
+ for (int tyreIndex = 0; tyreIndex < 4; tyreIndex++)
+ {
+ tyreTemperatures[tyreIndex] = data.tyreTemp[tyreIndex];
+ }
+
// 由獨立 library 估算剩餘油量圈數。
// 注意:GT7FuelEstimator 接收的是公升,不是百分比。
derivedMetrics.fuel.update(
@@ -1001,6 +1007,12 @@ public:
{
drawRpmMeter(0, 0, SCREEN_WIDTH, HALF_CELL_HEIGHT);
drawGear(COL[2], COL[1]);
+ drawTyreTemperatureStrip(
+ COL[2] + 1,
+ ROW[3] - 22,
+ CELL_WIDTH - 2,
+ 18,
+ forceUpdate);
drawLapCellSprite(
COL[0],
@@ -1487,6 +1499,118 @@ public:
}
}
+ uint16_t interpolateTyreColor(
+ uint8_t redStart,
+ uint8_t greenStart,
+ uint8_t blueStart,
+ uint8_t redEnd,
+ uint8_t greenEnd,
+ uint8_t blueEnd,
+ float amount)
+ {
+ amount = constrain(amount, 0.0f, 1.0f);
+
+ return tft.color565(
+ static_cast<uint8_t>(redStart + (redEnd - redStart) * amount),
+ static_cast<uint8_t>(greenStart + (greenEnd - greenStart) * amount),
+ static_cast<uint8_t>(blueStart + (blueEnd - blueStart) * amount));
+ }
+
+ uint16_t tyreTemperatureColor(float temperature)
+ {
+ if (!isfinite(temperature) || temperature <= 0.0f)
+ {
+ return TFT_DARKGREY;
+ }
+
+ if (temperature <= 50.0f)
+ {
+ return tft.color565(0, 20, 120);
+ }
+
+ if (temperature < 65.0f)
+ {
+ return interpolateTyreColor(
+ 0, 20, 120,
+ 0, 200, 255,
+ (temperature - 50.0f) / 15.0f);
+ }
+
+ if (temperature < 85.0f)
+ {
+ return interpolateTyreColor(
+ 0, 200, 255,
+ 0, 220, 60,
+ (temperature - 65.0f) / 20.0f);
+ }
+
+ if (temperature < 92.5f)
+ {
+ return interpolateTyreColor(
+ 0, 220, 60,
+ 255, 220, 0,
+ (temperature - 85.0f) / 7.5f);
+ }
+
+ if (temperature < 100.0f)
+ {
+ return interpolateTyreColor(
+ 255, 220, 0,
+ 255, 0, 0,
+ (temperature - 92.5f) / 7.5f);
+ }
+
+ return TFT_RED;
+ }
+
+ void drawTyreTemperatureStrip(
+ int32_t x,
+ int32_t y,
+ int width,
+ int height,
+ bool forceUpdate = false)
+ {
+ const int gap = 2;
+ const int blockWidth = (width - gap) / 2;
+ const int blockHeight = (height - gap) / 2;
+ const String gearId = "tyreTemperatureGear";
+ const bool gearChanged = prevData[gearId] != gear;
+
+ for (int tyreIndex = 0; tyreIndex < 4; tyreIndex++)
+ {
+ const int column = tyreIndex % 2;
+ const int row = tyreIndex / 2;
+ const int blockX = x + column * (blockWidth + gap);
+ const int blockY = y + row * (blockHeight + gap);
+ const int currentWidth = column == 1
+ ? width - blockWidth - gap
+ : blockWidth;
+ const int currentHeight = row == 1
+ ? height - blockHeight - gap
+ : blockHeight;
+ const float temperature = tyreTemperatures[tyreIndex];
+ const uint16_t color = tyreTemperatureColor(temperature);
+ const String colorId = "tyreTemperatureColor" + String(tyreIndex);
+
+ if (!forceUpdate && !gearChanged && prevColor[colorId] == color)
+ {
+ continue;
+ }
+
+ tft.fillRoundRect(
+ blockX,
+ blockY,
+ currentWidth,
+ currentHeight,
+ 2,
+ color);
+
+ prevColor[colorId] = color;
+ }
+
+ prevData[gearId] = gear;
+ }
+
void drawLapCellSprite(
int32_t x,
int32_t y,