dd0970ed7c
Three bugs fixed: - NVS img_id now written before epd_init/draw; new draw_needed flag in NVS survives power-loss mid-refresh so next boot re-draws from LittleFS instead of showing stale content - epd_sleep() now only called when display was initialized this cycle, preventing a 60 s wait_busy() timeout on every 304 poll - esp_task_wdt_reset() added to wait_busy() loop so the ~20 s 6-color refresh no longer triggers the task watchdog Also extracts normal_operation into operation.h template and adds a native PlatformIO test suite (16 tests) covering the full response matrix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
996 B
C++
40 lines
996 B
C++
#pragma once
|
|
#include "Arduino.h"
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
struct File {
|
|
std::string* _buf = nullptr;
|
|
bool _valid = false;
|
|
bool _write = false;
|
|
size_t _pos = 0;
|
|
|
|
explicit operator bool() const { return _valid; }
|
|
void close() { _valid = false; }
|
|
size_t write(const uint8_t* data, size_t len) {
|
|
if (_buf && _write) { _buf->append((const char*)data, len); return len; }
|
|
return 0;
|
|
}
|
|
int read() {
|
|
if (_buf && _pos < _buf->size()) return (uint8_t)(*_buf)[_pos++];
|
|
return -1;
|
|
}
|
|
size_t size() { return _buf ? _buf->size() : 0; }
|
|
};
|
|
|
|
struct LittleFSClass {
|
|
std::map<std::string, std::string> files;
|
|
|
|
bool begin(bool) { return true; }
|
|
|
|
File open(const char* path, const char* mode, bool create = false) {
|
|
File f;
|
|
f._valid = true;
|
|
f._write = (mode[0] == 'w');
|
|
f._buf = &files[path];
|
|
if (f._write) f._buf->clear();
|
|
f._pos = 0;
|
|
return f;
|
|
}
|
|
} LittleFS;
|