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>
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#pragma once
|
|
#include "Arduino.h"
|
|
#include <map>
|
|
|
|
// Shared sequence counter — incremented by each instrumented mock call
|
|
extern int g_call_seq;
|
|
extern int g_prefs_putint_seq; // sequence position of last putInt call
|
|
|
|
struct Preferences {
|
|
std::map<std::string, int32_t> ints;
|
|
std::map<std::string, std::string> strings;
|
|
bool _open = false;
|
|
|
|
void begin(const char*, bool) { _open = true; }
|
|
void end() { _open = false; }
|
|
|
|
int32_t getInt(const char* key, int32_t def = 0) {
|
|
auto it = ints.find(key);
|
|
return it != ints.end() ? it->second : def;
|
|
}
|
|
void putInt(const char* key, int32_t val) {
|
|
ints[key] = val;
|
|
// Record the sequence of the FIRST putInt call (ordering test uses this
|
|
// to verify NVS is written before epd_draw_image_from_file).
|
|
if (g_prefs_putint_seq < 0) g_prefs_putint_seq = g_call_seq;
|
|
g_call_seq++;
|
|
}
|
|
|
|
String getString(const char* key, const char* def = "") {
|
|
auto it = strings.find(key);
|
|
return it != strings.end() ? String(it->second) : String(def);
|
|
}
|
|
void putString(const char* key, const String& val) { strings[key] = val._s; }
|
|
void clear() { ints.clear(); strings.clear(); }
|
|
};
|