Feat/sleep and refresh settings (#209)
## Summary * **What is the goal of this PR?** (e.g., Fixes a bug in the user authentication module, Implements the new feature for file uploading.) * **What changes are included?** ## Additional Context * Add any other information that might be helpful for the reviewer (e.g., performance implications, potential risks, specific areas to focus on). --------- Co-authored-by: ratedcounsel <hello@ratedcounsel.com> Co-authored-by: Dave Allie <dave@daveallie.com>
This commit is contained in:
@@ -12,7 +12,7 @@ CrossPointSettings CrossPointSettings::instance;
|
||||
namespace {
|
||||
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
||||
// Increment this when adding new persisted settings fields
|
||||
constexpr uint8_t SETTINGS_COUNT = 11;
|
||||
constexpr uint8_t SETTINGS_COUNT = 13;
|
||||
constexpr char SETTINGS_FILE[] = "/.crosspoint/settings.bin";
|
||||
} // namespace
|
||||
|
||||
@@ -38,6 +38,8 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, fontSize);
|
||||
serialization::writePod(outputFile, lineSpacing);
|
||||
serialization::writePod(outputFile, paragraphAlignment);
|
||||
serialization::writePod(outputFile, sleepTimeout);
|
||||
serialization::writePod(outputFile, refreshFrequency);
|
||||
outputFile.close();
|
||||
|
||||
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
||||
@@ -86,6 +88,10 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, paragraphAlignment);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, sleepTimeout);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, refreshFrequency);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
} while (false);
|
||||
|
||||
inputFile.close();
|
||||
@@ -129,6 +135,38 @@ float CrossPointSettings::getReaderLineCompression() const {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long CrossPointSettings::getSleepTimeoutMs() const {
|
||||
switch (sleepTimeout) {
|
||||
case SLEEP_1_MIN:
|
||||
return 1UL * 60 * 1000;
|
||||
case SLEEP_5_MIN:
|
||||
return 5UL * 60 * 1000;
|
||||
case SLEEP_10_MIN:
|
||||
default:
|
||||
return 10UL * 60 * 1000;
|
||||
case SLEEP_15_MIN:
|
||||
return 15UL * 60 * 1000;
|
||||
case SLEEP_30_MIN:
|
||||
return 30UL * 60 * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
int CrossPointSettings::getRefreshFrequency() const {
|
||||
switch (refreshFrequency) {
|
||||
case REFRESH_1:
|
||||
return 1;
|
||||
case REFRESH_5:
|
||||
return 5;
|
||||
case REFRESH_10:
|
||||
return 10;
|
||||
case REFRESH_15:
|
||||
default:
|
||||
return 15;
|
||||
case REFRESH_30:
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
|
||||
int CrossPointSettings::getReaderFontId() const {
|
||||
switch (fontFamily) {
|
||||
case BOOKERLY:
|
||||
|
||||
Reference in New Issue
Block a user