Adds margin setting and calibre web
Also made the menu items dynamic and capital case. Looks better from a design perspective but I suppose this is an optional thing to accept
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <HardwareSerial.h>
|
||||
#include <SDCardManager.h>
|
||||
#include <Serialization.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "fontIds.h"
|
||||
|
||||
@@ -12,7 +13,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 +39,8 @@ bool CrossPointSettings::saveToFile() const {
|
||||
serialization::writePod(outputFile, fontSize);
|
||||
serialization::writePod(outputFile, lineSpacing);
|
||||
serialization::writePod(outputFile, paragraphAlignment);
|
||||
serialization::writePod(outputFile, sideMargin);
|
||||
serialization::writeString(outputFile, std::string(opdsServerUrl));
|
||||
outputFile.close();
|
||||
|
||||
Serial.printf("[%lu] [CPS] Settings saved to file\n", millis());
|
||||
@@ -86,6 +89,15 @@ bool CrossPointSettings::loadFromFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, paragraphAlignment);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, sideMargin);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
{
|
||||
std::string urlStr;
|
||||
serialization::readString(inputFile, urlStr);
|
||||
strncpy(opdsServerUrl, urlStr.c_str(), sizeof(opdsServerUrl) - 1);
|
||||
opdsServerUrl[sizeof(opdsServerUrl) - 1] = '\0';
|
||||
}
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
} while (false);
|
||||
|
||||
inputFile.close();
|
||||
@@ -170,3 +182,17 @@ int CrossPointSettings::getReaderFontId() const {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CrossPointSettings::getReaderSideMargin() const {
|
||||
switch (sideMargin) {
|
||||
case MARGIN_NONE:
|
||||
return 0;
|
||||
case MARGIN_SMALL:
|
||||
default:
|
||||
return 5;
|
||||
case MARGIN_MEDIUM:
|
||||
return 20;
|
||||
case MARGIN_LARGE:
|
||||
return 30;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user