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;
|
CrossPointSettings CrossPointSettings::instance;
|
||||||
|
|
||||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
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";
|
constexpr char SETTINGS_FILE[] = "/sd/.crosspoint/settings.bin";
|
||||||
|
|
||||||
bool CrossPointSettings::saveToFile() const {
|
bool CrossPointSettings::saveToFile() const {
|
||||||
@ -23,6 +23,7 @@ bool CrossPointSettings::saveToFile() const {
|
|||||||
serialization::writePod(outputFile, SETTINGS_COUNT);
|
serialization::writePod(outputFile, SETTINGS_COUNT);
|
||||||
serialization::writePod(outputFile, whiteSleepScreen);
|
serialization::writePod(outputFile, whiteSleepScreen);
|
||||||
serialization::writePod(outputFile, extraParagraphSpacing);
|
serialization::writePod(outputFile, extraParagraphSpacing);
|
||||||
|
serialization::writePod(outputFile, autoResumeLastBook);
|
||||||
outputFile.close();
|
outputFile.close();
|
||||||
|
|
||||||
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
||||||
@ -48,15 +49,16 @@ bool CrossPointSettings::loadFromFile() {
|
|||||||
uint8_t fileSettingsCount = 0;
|
uint8_t fileSettingsCount = 0;
|
||||||
serialization::readPod(inputFile, fileSettingsCount);
|
serialization::readPod(inputFile, fileSettingsCount);
|
||||||
|
|
||||||
// load settings that exist
|
if (fileSettingsCount >= 1) {
|
||||||
switch (fileSettingsCount) {
|
serialization::readPod(inputFile, whiteSleepScreen);
|
||||||
case 1:
|
}
|
||||||
serialization::readPod(inputFile, whiteSleepScreen);
|
|
||||||
break;
|
if (fileSettingsCount >= 2) {
|
||||||
case 2:
|
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||||
serialization::readPod(inputFile, whiteSleepScreen);
|
}
|
||||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
|
||||||
break;
|
if (fileSettingsCount >= 3) {
|
||||||
|
serialization::readPod(inputFile, autoResumeLastBook);
|
||||||
}
|
}
|
||||||
|
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
|
|||||||
@ -21,6 +21,9 @@ class CrossPointSettings {
|
|||||||
// Text rendering settings
|
// Text rendering settings
|
||||||
uint8_t extraParagraphSpacing = 1;
|
uint8_t extraParagraphSpacing = 1;
|
||||||
|
|
||||||
|
// Resume behavior
|
||||||
|
uint8_t autoResumeLastBook = 1;
|
||||||
|
|
||||||
~CrossPointSettings() = default;
|
~CrossPointSettings() = default;
|
||||||
|
|
||||||
// Get singleton instance
|
// Get singleton instance
|
||||||
|
|||||||
@ -210,7 +210,7 @@ void setup() {
|
|||||||
|
|
||||||
SETTINGS.loadFromFile();
|
SETTINGS.loadFromFile();
|
||||||
appState.loadFromFile();
|
appState.loadFromFile();
|
||||||
if (!appState.openEpubPath.empty()) {
|
if (SETTINGS.autoResumeLastBook && !appState.openEpubPath.empty()) {
|
||||||
auto epub = loadEpub(appState.openEpubPath);
|
auto epub = loadEpub(appState.openEpubPath);
|
||||||
if (epub) {
|
if (epub) {
|
||||||
exitScreen();
|
exitScreen();
|
||||||
|
|||||||
@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
const SettingInfo SettingsScreen::settingsList[SettingsScreen::settingsCount] = {
|
const SettingInfo SettingsScreen::settingsList[SettingsScreen::settingsCount] = {
|
||||||
{"White Sleep Screen", &CrossPointSettings::whiteSleepScreen},
|
{"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) {
|
void SettingsScreen::taskTrampoline(void* param) {
|
||||||
auto* self = static_cast<SettingsScreen*>(param);
|
auto* self = static_cast<SettingsScreen*>(param);
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class SettingsScreen final : public Screen {
|
|||||||
const std::function<void()> onGoHome;
|
const std::function<void()> onGoHome;
|
||||||
|
|
||||||
// Static settings list
|
// 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 const SettingInfo settingsList[settingsCount];
|
||||||
|
|
||||||
static void taskTrampoline(void* param);
|
static void taskTrampoline(void* param);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user