mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 15:17:42 +03:00
Merge 989930c51b into 67da8139b3
This commit is contained in:
commit
a3efa6d104
@ -11,7 +11,7 @@
|
||||
CrossPointSettings CrossPointSettings::instance;
|
||||
|
||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
||||
constexpr uint8_t SETTINGS_COUNT = 2;
|
||||
constexpr uint8_t SETTINGS_COUNT = 3;
|
||||
constexpr char SETTINGS_FILE[] = "/sd/.crosspoint/settings.bin";
|
||||
|
||||
bool CrossPointSettings::saveToFile() const {
|
||||
@ -23,6 +23,7 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, SETTINGS_COUNT);
|
||||
serialization::writePod(outputFile, whiteSleepScreen);
|
||||
serialization::writePod(outputFile, extraParagraphSpacing);
|
||||
serialization::writePod(outputFile, autoResumeLastBook);
|
||||
outputFile.close();
|
||||
|
||||
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
||||
@ -48,15 +49,16 @@ bool CrossPointSettings::loadFromFile() {
|
||||
uint8_t fileSettingsCount = 0;
|
||||
serialization::readPod(inputFile, fileSettingsCount);
|
||||
|
||||
// load settings that exist
|
||||
switch (fileSettingsCount) {
|
||||
case 1:
|
||||
serialization::readPod(inputFile, whiteSleepScreen);
|
||||
break;
|
||||
case 2:
|
||||
serialization::readPod(inputFile, whiteSleepScreen);
|
||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||
break;
|
||||
if (fileSettingsCount >= 1) {
|
||||
serialization::readPod(inputFile, whiteSleepScreen);
|
||||
}
|
||||
|
||||
if (fileSettingsCount >= 2) {
|
||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||
}
|
||||
|
||||
if (fileSettingsCount >= 3) {
|
||||
serialization::readPod(inputFile, autoResumeLastBook);
|
||||
}
|
||||
|
||||
inputFile.close();
|
||||
|
||||
@ -21,6 +21,9 @@ class CrossPointSettings {
|
||||
// Text rendering settings
|
||||
uint8_t extraParagraphSpacing = 1;
|
||||
|
||||
// Resume behavior
|
||||
uint8_t autoResumeLastBook = 1;
|
||||
|
||||
~CrossPointSettings() = default;
|
||||
|
||||
// Get singleton instance
|
||||
|
||||
@ -210,7 +210,7 @@ void setup() {
|
||||
|
||||
SETTINGS.loadFromFile();
|
||||
appState.loadFromFile();
|
||||
if (!appState.openEpubPath.empty()) {
|
||||
if (SETTINGS.autoResumeLastBook && !appState.openEpubPath.empty()) {
|
||||
auto epub = loadEpub(appState.openEpubPath);
|
||||
if (epub) {
|
||||
exitScreen();
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
|
||||
const SettingInfo SettingsScreen::settingsList[SettingsScreen::settingsCount] = {
|
||||
{"White Sleep Screen", &CrossPointSettings::whiteSleepScreen},
|
||||
{"Extra Paragraph Spacing", &CrossPointSettings::extraParagraphSpacing}};
|
||||
{"Extra Paragraph Spacing", &CrossPointSettings::extraParagraphSpacing},
|
||||
{"Auto-Resume Last Book", &CrossPointSettings::autoResumeLastBook}};
|
||||
|
||||
void SettingsScreen::taskTrampoline(void* param) {
|
||||
auto* self = static_cast<SettingsScreen*>(param);
|
||||
|
||||
@ -25,7 +25,7 @@ class SettingsScreen final : public Screen {
|
||||
const std::function<void()> onGoHome;
|
||||
|
||||
// Static settings list
|
||||
static constexpr int settingsCount = 2; // Number of settings
|
||||
static constexpr int settingsCount = 3; // Number of settings
|
||||
static const SettingInfo settingsList[settingsCount];
|
||||
|
||||
static void taskTrampoline(void* param);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user