## Summary * **What is the goal of this PR?** fix edge case for definition ## Additional Context If loadFromFile() returns false (no state file exists — first boot, or SD missing), lastSleepImage is never set and contains garbage. [SleepActivity.cpp:83] then uses it in a while comparison to avoid repeating the same image. The JSON path (doc["lastSleepImage"] | (uint8_t)0) handles it, but only if the file exists. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _** NO **_
30 lines
633 B
C++
30 lines
633 B
C++
#pragma once
|
|
#include <cstdint>
|
|
#include <iosfwd>
|
|
#include <string>
|
|
|
|
class CrossPointState {
|
|
// Static instance
|
|
static CrossPointState instance;
|
|
|
|
public:
|
|
std::string openEpubPath;
|
|
uint8_t lastSleepImage = UINT8_MAX; // UINT8_MAX = unset sentinel
|
|
uint8_t readerActivityLoadCount = 0;
|
|
bool lastSleepFromReader = false;
|
|
~CrossPointState() = default;
|
|
|
|
// Get singleton instance
|
|
static CrossPointState& getInstance() { return instance; }
|
|
|
|
bool saveToFile() const;
|
|
|
|
bool loadFromFile();
|
|
|
|
private:
|
|
bool loadFromBinaryFile();
|
|
};
|
|
|
|
// Helper macro to access settings
|
|
#define APP_STATE CrossPointState::getInstance()
|