d900083398
To validate the PIN_PWR rail-cut change (e2c9d8f) without a bench
multimeter, have the device report its previous cycle's awake time
and panel-init time on each poll:
X-Prev-Awake-Ms — millis() at the moment esp_deep_sleep_start
armed, last cycle. Total awake duration
since reset, ~5–10 s steady-state.
X-Prev-Panel-Init-Ms — duration of epd_init() last cycle. Spikes
here would suggest the rail isn't coming
back up cleanly after the GPIO-hold release.
Headers are sent only when the cached NVS values are non-zero (skips
the first boot under this firmware). All call sites marked `// TEMP:
power-monitor` for clean removal once the change is validated. Two
new NVS keys (tm_awk, tm_pin) sit alongside the existing ones; mock
Preferences extended with getUInt/putUInt to match.
Server side logs the headers via `device.poll.power_telemetry`
(separate commit in pictureFrame-webApp).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.5 KiB
C++
43 lines
1.5 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, uint32_t> uints;
|
|
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++;
|
|
}
|
|
|
|
uint32_t getUInt(const char* key, uint32_t def = 0) {
|
|
auto it = uints.find(key);
|
|
return it != uints.end() ? it->second : def;
|
|
}
|
|
void putUInt(const char* key, uint32_t val) { uints[key] = val; }
|
|
|
|
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(); uints.clear(); strings.clear(); }
|
|
};
|