#include "../core/module.h" #include "../core/ui.h" #include // Bench Assistant: live system telemetry for THIS device (heap, temp, SD, // uptime) plus a quick self-test. Honest diagnostics — replaces the old // "active exploit" theater module. class BenchDiag : public Module { bool running = false; uint32_t freeHeap = 0, minHeap = 0; float tempC = 0; bool sdOk = false; char msg[3][40] = {{0},{0},{0}}; public: const char* name() const override { return "Bench Diag"; } const char* blurb() const override { return "self telemetry + selftest"; } void onEnter() override { running = false; say("[space] run self-test"); } void onExit() override { running = false; } bool onKey(char c) override { if (c == ' ') { running = true; say("self-test running..."); return true; } return false; } void tick() override { if (!running) return; freeHeap = ESP.getFreeHeap(); minHeap = ESP.getMinFreeHeap(); tempC = temperatureRead(); sdOk = SD.begin(); running = false; say("heap free %lu KB", (unsigned long)(freeHeap / 1024)); say("heap min %lu KB", (unsigned long)(minHeap / 1024)); say("temp %.1fC SD %s", tempC, sdOk ? "ok" : "MISSING"); say("self-test complete"); } void draw() override { ui::lineC(0, ui::accent(), "Bench Diag %s", running ? "TEST" : "ready"); ui::line(1, "heap: %lu KB (min %lu KB)", (unsigned long)(freeHeap / 1024), (unsigned long)(minHeap / 1024)); ui::line(2, "cpu temp: %.1f C", tempC); ui::line(3, "microSD: %s", sdOk ? "mounted" : "not detected"); ui::line(4, "uptime: %lu s", (unsigned long)(millis() / 1000)); for (int i = 0; i < 3; i++) ui::line(5 + i, "%s", msg[i]); if (running) ui::spinner(228, ui::BODY_Y + 1, ui::glow()); ui::hintBar("[space]test [`]back"); } private: void say(const char* fmt, ...) { for (int i = 2; i > 0; i--) strncpy(msg[i], msg[i-1], 39); va_list ap; va_start(ap, fmt); vsnprintf(msg[0], 40, fmt, ap); va_end(ap); } }; Module* makeActiveExploit() { return new BenchDiag(); }