test: add sim-yellow and sim-red envs for visual border verification

Two pio envs that build a tiny sketch reading /img.bin from LittleFS and
calling epd_draw_image_with_border with the chosen color. Lets us verify
the actual on-device pixel composition of the sync-fail (yellow) and
no-WiFi (red) borders without standing up a server failure or pulling
the WiFi cable.

Each sim sets NVS err_border=1 before halting, so flashing back to the
normal env afterwards exercises the 304 → clean repaint recovery path
end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-06 13:41:22 -04:00
parent db50ce1d0a
commit 3fb7eb6ac3
2 changed files with 102 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
// Visual hardware test for sync-fail / no-WiFi border rendering.
//
// Built only by env:sim-yellow and env:sim-red in platformio.ini. Reads the
// last cached image from LittleFS, draws it through epd_draw_image_with_border
// with the configured color, and sets NVS_KEY_ERR_BORDER=1 so that flashing
// the normal firmware afterwards exercises the recovery path (next 304
// repaints the image clean).
//
// Usage:
// pio run -e sim-yellow --target upload
// pio run -e sim-red --target upload
// pio run -e esp32dev --target upload # back to normal — verifies recovery
#ifdef SIM_BORDER
#include <Arduino.h>
#include <SPI.h>
#include <LittleFS.h>
#include <Preferences.h>
#include "config.h"
#include "epd.h"
#ifndef SIM_BORDER_COLOR
#error "sim_border.cpp built without SIM_BORDER_COLOR — set it in platformio.ini"
#endif
void setup() {
Serial.begin(115200);
Serial.println("[sim_border] boot");
pinMode(PIN_CS, OUTPUT);
pinMode(PIN_DC, OUTPUT);
pinMode(PIN_RST, OUTPUT);
pinMode(PIN_BUSY, INPUT);
pinMode(PIN_BTN_RESET, INPUT_PULLUP);
SPI.begin(PIN_SCK, -1, PIN_MOSI, PIN_CS);
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
LittleFS.begin(true);
epd_init();
File f = LittleFS.open(IMAGE_PATH, "r");
if (f) {
Serial.printf("[sim_border] /img.bin %u bytes — drawing with border color 0x%X\n",
(unsigned)f.size(), (unsigned)SIM_BORDER_COLOR);
epd_draw_image_with_border(f, SIM_BORDER_COLOR, BORDER_THICKNESS_PX);
f.close();
} else {
Serial.println("[sim_border] no /img.bin — falling back to full fill");
epd_fill(SIM_BORDER_COLOR);
}
epd_sleep();
// Mark err_border so the next normal-firmware boot will trigger the
// 304-based clean repaint and we can confirm recovery end-to-end.
Preferences prefs;
prefs.begin(NVS_NAMESPACE, false);
prefs.putInt(NVS_KEY_ERR_BORDER, 1);
prefs.end();
Serial.println("[sim_border] done — halting (deep sleep, button-reset to wake)");
esp_deep_sleep_start();
}
void loop() {}
#endif // SIM_BORDER