Add adjustable sleep timer and file browser settings
Implemented the adjustable sleep timer feature as requested. Updated the settings storage to include refresh interval and default folder preferences. Modified the state file version to accommodate new fields for last browsed folder.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <Serialization.h>
|
||||
|
||||
namespace {
|
||||
constexpr uint8_t STATE_FILE_VERSION = 1;
|
||||
constexpr uint8_t STATE_FILE_VERSION = 2;
|
||||
constexpr char STATE_FILE[] = "/.crosspoint/state.bin";
|
||||
} // namespace
|
||||
|
||||
@@ -19,6 +19,7 @@ bool CrossPointState::saveToFile() const {
|
||||
|
||||
serialization::writePod(outputFile, STATE_FILE_VERSION);
|
||||
serialization::writeString(outputFile, openEpubPath);
|
||||
serialization::writeString(outputFile, lastBrowsedFolder);
|
||||
outputFile.close();
|
||||
return true;
|
||||
}
|
||||
@@ -31,14 +32,20 @@ bool CrossPointState::loadFromFile() {
|
||||
|
||||
uint8_t version;
|
||||
serialization::readPod(inputFile, version);
|
||||
if (version != STATE_FILE_VERSION) {
|
||||
if (version == 1) {
|
||||
// Version 1: only had openEpubPath
|
||||
serialization::readString(inputFile, openEpubPath);
|
||||
lastBrowsedFolder = "/"; // Default for old version
|
||||
} else if (version == STATE_FILE_VERSION) {
|
||||
// Version 2: has openEpubPath and lastBrowsedFolder
|
||||
serialization::readString(inputFile, openEpubPath);
|
||||
serialization::readString(inputFile, lastBrowsedFolder);
|
||||
} else {
|
||||
Serial.printf("[%lu] [CPS] Deserialization failed: Unknown version %u\n", millis(), version);
|
||||
inputFile.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
serialization::readString(inputFile, openEpubPath);
|
||||
|
||||
inputFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user