2025-12-15 13:16:46 +01:00
|
|
|
#include "CrossPointSettings.h"
|
|
|
|
|
|
2026-02-08 21:29:14 +01:00
|
|
|
#include <HalStorage.h>
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
#include <JsonSettingsIO.h>
|
2026-02-13 12:16:39 +01:00
|
|
|
#include <Logging.h>
|
2025-12-15 13:16:46 +01:00
|
|
|
#include <Serialization.h>
|
|
|
|
|
|
2026-01-07 03:58:37 -05:00
|
|
|
#include <cstring>
|
2026-02-16 12:11:26 +01:00
|
|
|
#include <string>
|
2026-01-07 03:58:37 -05:00
|
|
|
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
#include "fontIds.h"
|
|
|
|
|
|
2025-12-15 13:16:46 +01:00
|
|
|
// Initialize the static instance
|
|
|
|
|
CrossPointSettings CrossPointSettings::instance;
|
|
|
|
|
|
2026-01-27 13:08:58 +01:00
|
|
|
void readAndValidate(FsFile& file, uint8_t& member, const uint8_t maxValue) {
|
|
|
|
|
uint8_t tempValue;
|
|
|
|
|
serialization::readPod(file, tempValue);
|
|
|
|
|
if (tempValue < maxValue) {
|
|
|
|
|
member = tempValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-17 23:32:18 +11:00
|
|
|
namespace {
|
2025-12-15 13:16:46 +01:00
|
|
|
constexpr uint8_t SETTINGS_FILE_VERSION = 1;
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
constexpr char SETTINGS_FILE_BIN[] = "/.crosspoint/settings.bin";
|
|
|
|
|
constexpr char SETTINGS_FILE_JSON[] = "/.crosspoint/settings.json";
|
|
|
|
|
constexpr char SETTINGS_FILE_BAK[] = "/.crosspoint/settings.bin.bak";
|
2026-02-05 14:37:17 +03:00
|
|
|
|
|
|
|
|
// Convert legacy front button layout into explicit logical->hardware mapping.
|
|
|
|
|
void applyLegacyFrontButtonLayout(CrossPointSettings& settings) {
|
|
|
|
|
switch (static_cast<CrossPointSettings::FRONT_BUTTON_LAYOUT>(settings.frontButtonLayout)) {
|
|
|
|
|
case CrossPointSettings::LEFT_RIGHT_BACK_CONFIRM:
|
|
|
|
|
settings.frontButtonBack = CrossPointSettings::FRONT_HW_LEFT;
|
|
|
|
|
settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_RIGHT;
|
|
|
|
|
settings.frontButtonLeft = CrossPointSettings::FRONT_HW_BACK;
|
|
|
|
|
settings.frontButtonRight = CrossPointSettings::FRONT_HW_CONFIRM;
|
|
|
|
|
break;
|
|
|
|
|
case CrossPointSettings::LEFT_BACK_CONFIRM_RIGHT:
|
|
|
|
|
settings.frontButtonBack = CrossPointSettings::FRONT_HW_CONFIRM;
|
|
|
|
|
settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_LEFT;
|
|
|
|
|
settings.frontButtonLeft = CrossPointSettings::FRONT_HW_BACK;
|
|
|
|
|
settings.frontButtonRight = CrossPointSettings::FRONT_HW_RIGHT;
|
|
|
|
|
break;
|
|
|
|
|
case CrossPointSettings::BACK_CONFIRM_RIGHT_LEFT:
|
|
|
|
|
settings.frontButtonBack = CrossPointSettings::FRONT_HW_BACK;
|
|
|
|
|
settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_CONFIRM;
|
|
|
|
|
settings.frontButtonLeft = CrossPointSettings::FRONT_HW_RIGHT;
|
|
|
|
|
settings.frontButtonRight = CrossPointSettings::FRONT_HW_LEFT;
|
|
|
|
|
break;
|
|
|
|
|
case CrossPointSettings::BACK_CONFIRM_LEFT_RIGHT:
|
|
|
|
|
default:
|
|
|
|
|
settings.frontButtonBack = CrossPointSettings::FRONT_HW_BACK;
|
|
|
|
|
settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_CONFIRM;
|
|
|
|
|
settings.frontButtonLeft = CrossPointSettings::FRONT_HW_LEFT;
|
|
|
|
|
settings.frontButtonRight = CrossPointSettings::FRONT_HW_RIGHT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-25 10:06:38 +00:00
|
|
|
|
2025-12-17 23:32:18 +11:00
|
|
|
} // namespace
|
2025-12-15 13:16:46 +01:00
|
|
|
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
void CrossPointSettings::validateFrontButtonMapping(CrossPointSettings& settings) {
|
|
|
|
|
const uint8_t mapping[] = {settings.frontButtonBack, settings.frontButtonConfirm, settings.frontButtonLeft,
|
|
|
|
|
settings.frontButtonRight};
|
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
|
for (size_t j = i + 1; j < 4; j++) {
|
|
|
|
|
if (mapping[i] == mapping[j]) {
|
|
|
|
|
settings.frontButtonBack = FRONT_HW_BACK;
|
|
|
|
|
settings.frontButtonConfirm = FRONT_HW_CONFIRM;
|
|
|
|
|
settings.frontButtonLeft = FRONT_HW_LEFT;
|
|
|
|
|
settings.frontButtonRight = FRONT_HW_RIGHT;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-02-16 12:11:26 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-15 13:16:46 +01:00
|
|
|
bool CrossPointSettings::saveToFile() const {
|
2026-02-08 21:29:14 +01:00
|
|
|
Storage.mkdir("/.crosspoint");
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
return JsonSettingsIO::saveSettings(*this, SETTINGS_FILE_JSON);
|
|
|
|
|
}
|
2025-12-15 13:16:46 +01:00
|
|
|
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
bool CrossPointSettings::loadFromFile() {
|
|
|
|
|
// Try JSON first
|
|
|
|
|
if (Storage.exists(SETTINGS_FILE_JSON)) {
|
|
|
|
|
String json = Storage.readFile(SETTINGS_FILE_JSON);
|
|
|
|
|
if (!json.isEmpty()) {
|
|
|
|
|
bool resave = false;
|
|
|
|
|
bool result = JsonSettingsIO::loadSettings(*this, json.c_str(), &resave);
|
|
|
|
|
if (result && resave) {
|
|
|
|
|
if (saveToFile()) {
|
|
|
|
|
LOG_DBG("CPS", "Resaved settings to update format");
|
|
|
|
|
} else {
|
|
|
|
|
LOG_ERR("CPS", "Failed to resave settings after format update");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2025-12-23 14:14:10 +11:00
|
|
|
}
|
|
|
|
|
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
// Fall back to binary migration
|
|
|
|
|
if (Storage.exists(SETTINGS_FILE_BIN)) {
|
|
|
|
|
if (loadFromBinaryFile()) {
|
|
|
|
|
if (saveToFile()) {
|
|
|
|
|
Storage.rename(SETTINGS_FILE_BIN, SETTINGS_FILE_BAK);
|
|
|
|
|
LOG_DBG("CPS", "Migrated settings.bin to settings.json");
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
LOG_ERR("CPS", "Failed to save migrated settings to JSON");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-15 13:16:46 +01:00
|
|
|
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
return false;
|
2025-12-15 13:16:46 +01:00
|
|
|
}
|
|
|
|
|
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
bool CrossPointSettings::loadFromBinaryFile() {
|
2025-12-30 15:09:30 +10:00
|
|
|
FsFile inputFile;
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
if (!Storage.openFileForRead("CPS", SETTINGS_FILE_BIN, inputFile)) {
|
2025-12-15 13:16:46 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t version;
|
|
|
|
|
serialization::readPod(inputFile, version);
|
|
|
|
|
if (version != SETTINGS_FILE_VERSION) {
|
2026-02-13 12:16:39 +01:00
|
|
|
LOG_ERR("CPS", "Deserialization failed: Unknown version %u", version);
|
2025-12-15 13:16:46 +01:00
|
|
|
inputFile.close();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t fileSettingsCount = 0;
|
|
|
|
|
serialization::readPod(inputFile, fileSettingsCount);
|
|
|
|
|
|
2025-12-19 13:37:34 +01:00
|
|
|
uint8_t settingsRead = 0;
|
2026-02-05 14:37:17 +03:00
|
|
|
bool frontButtonMappingRead = false;
|
2025-12-19 13:37:34 +01:00
|
|
|
do {
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, sleepScreen, SLEEP_SCREEN_MODE_COUNT);
|
2025-12-19 13:37:34 +01:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
serialization::readPod(inputFile, extraParagraphSpacing);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, shortPwrBtn, SHORT_PWRBTN_COUNT);
|
2025-12-19 13:37:34 +01:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-02-25 10:06:38 +00:00
|
|
|
readAndValidate(inputFile, statusBar, STATUS_BAR_MODE_COUNT); // legacy
|
2025-12-27 17:48:27 -06:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, orientation, ORIENTATION_COUNT);
|
Rotation Support (#77)
• What is the goal of this PR?
Implement a horizontal EPUB reading mode so books can be read in
landscape orientation (both 90° and 270°), while keeping the rest of the
UI in portrait.
• What changes are included?
◦ Rendering / Display
▪ Added an orientation model to GfxRenderer (Portrait, LandscapeNormal,
LandscapeFlipped) and made:
▪ drawPixel, drawImage, displayWindow map logical coordinates
differently depending on orientation.
▪ getScreenWidth() / getScreenHeight() return orientation‑aware logical
dimensions (480×800 in portrait, 800×480 in landscape).
◦ Settings / Configuration
▪ Extended CrossPointSettings with:
▪ landscapeReading (toggle for portrait vs. landscape EPUB reading).
▪ landscapeFlipped (toggle to flip landscape 180° so both horizontal
holding directions are supported).
▪ Updated settings serialization/deserialization to persist these fields
while remaining backward‑compatible with existing settings files.
▪ Updated SettingsActivity to expose two new toggles:
▪ “Landscape Reading”
▪ “Flip Landscape (swap top/bottom)”
◦ EPUB Reader
▪ In EpubReaderActivity:
▪ On onEnter, set GfxRenderer orientation based on the new settings
(Portrait, LandscapeNormal, or LandscapeFlipped).
▪ On onExit, reset orientation back to Portrait so Home, WiFi, Settings,
etc. continue to render as before.
▪ Adjusted renderStatusBar to position the status bar and battery
indicator relative to GfxRenderer::getScreenHeight() instead of
hard‑coded Y coordinates, so it stays correctly at the bottom in both
portrait and landscape.
◦ EPUB Caching / Layout
▪ Extended Section cache metadata (section.bin) to include the logical
screenWidth and screenHeight used when pages were generated; bumped
SECTION_FILE_VERSION.
▪ Updated loadCacheMetadata to compare:
▪ font/margins/line compression/extraParagraphSpacing and screen
dimensions; mismatches now invalidate and clear the cache.
▪ Updated persistPageDataToSD and all call sites in EpubReaderActivity
to pass the current GfxRenderer::getScreenWidth() / getScreenHeight() so
portrait and landscape caches are kept separate and correctly sized.
Additional Context
• Cache behavior / migration
◦ Existing section.bin files (old SECTION_FILE_VERSION) will be detected
as incompatible and their caches cleared and rebuilt once per chapter
when first opened after this change.
◦ Within a given orientation, caches will be reused as before. Switching
orientation (portrait ↔ landscape) will cause a one‑time re‑index of
each chapter in the new orientation.
• Scope and risks
◦ Orientation changes are scoped to the EPUB reader; the Home screen,
Settings, WiFi selection, sleep screens, and web server UI continue to
assume portrait orientation.
◦ The renderer’s orientation is a static/global setting; if future code
uses GfxRenderer outside the reader while a reader instance is active,
it should be aware that orientation is no longer implicitly fixed.
◦ All drawing primitives now go through orientation‑aware coordinate
transforms; any code that previously relied on edge‑case behavior or
out‑of‑bounds writes might surface as logged “Outside range” warnings
instead.
• Testing suggestions / areas to focus on
◦ Verify in hardware:
▪ Portrait mode still renders correctly (boot, home, settings, WiFi,
reader).
▪ Landscape reading in both directions:
▪ Landscape Reading = ON, Flip Landscape = OFF.
▪ Landscape Reading = ON, Flip Landscape = ON.
▪ Status bar (page X/Y, % progress, battery icon) is fully visible and
aligned at the bottom in all three combinations.
◦ Open the same book:
▪ In portrait first, then switch to landscape and reopen it.
▪ Confirm that:
▪ Old portrait caches are rebuilt once for landscape (you should see the
“Indexing…” page).
▪ Progress save/restore still works (resume opens to the correct page in
the current orientation).
◦ Ensure grayscale rendering (the secondary pass in
EpubReaderActivity::renderContents) still looks correct in both
orientations.
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2025-12-28 05:33:20 -05:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
readAndValidate(inputFile, frontButtonLayout, FRONT_BUTTON_LAYOUT_COUNT);
|
2025-12-28 21:59:14 -06:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, sideButtonLayout, SIDE_BUTTON_LAYOUT_COUNT);
|
2025-12-29 11:17:10 +01:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, fontFamily, FONT_FAMILY_COUNT);
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, fontSize, FONT_SIZE_COUNT);
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, lineSpacing, LINE_COMPRESSION_COUNT);
|
2025-12-30 18:34:46 +10:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, paragraphAlignment, PARAGRAPH_ALIGNMENT_COUNT);
|
2026-01-02 01:21:48 -06:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, sleepTimeout, SLEEP_TIMEOUT_COUNT);
|
2026-01-03 08:33:42 +00:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, refreshFrequency, REFRESH_FREQUENCY_COUNT);
|
2026-01-03 08:33:42 +00:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-07 20:02:33 +11:00
|
|
|
serialization::readPod(inputFile, screenMargin);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, sleepScreenCoverMode, SLEEP_SCREEN_COVER_MODE_COUNT);
|
2026-01-07 20:02:33 +11:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-07 03:58:37 -05:00
|
|
|
{
|
|
|
|
|
std::string urlStr;
|
|
|
|
|
serialization::readString(inputFile, urlStr);
|
|
|
|
|
strncpy(opdsServerUrl, urlStr.c_str(), sizeof(opdsServerUrl) - 1);
|
|
|
|
|
opdsServerUrl[sizeof(opdsServerUrl) - 1] = '\0';
|
|
|
|
|
}
|
2026-01-19 17:56:26 +05:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-07 10:14:35 +01:00
|
|
|
serialization::readPod(inputFile, textAntiAliasing);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:08:58 +01:00
|
|
|
readAndValidate(inputFile, hideBatteryPercentage, HIDE_BATTERY_PERCENTAGE_COUNT);
|
2026-01-12 10:53:58 +01:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-14 06:47:24 -05:00
|
|
|
serialization::readPod(inputFile, longPressChapterSkip);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-19 17:56:26 +05:00
|
|
|
serialization::readPod(inputFile, hyphenationEnabled);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 06:02:38 -05:00
|
|
|
{
|
|
|
|
|
std::string usernameStr;
|
|
|
|
|
serialization::readString(inputFile, usernameStr);
|
|
|
|
|
strncpy(opdsUsername, usernameStr.c_str(), sizeof(opdsUsername) - 1);
|
|
|
|
|
opdsUsername[sizeof(opdsUsername) - 1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
{
|
|
|
|
|
std::string passwordStr;
|
|
|
|
|
serialization::readString(inputFile, passwordStr);
|
|
|
|
|
strncpy(opdsPassword, passwordStr.c_str(), sizeof(opdsPassword) - 1);
|
|
|
|
|
opdsPassword[sizeof(opdsPassword) - 1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-01-27 13:21:59 +00:00
|
|
|
readAndValidate(inputFile, sleepScreenCoverFilter, SLEEP_SCREEN_COVER_FILTER_COUNT);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
feat: UI themes, Lyra (#528)
## Summary
### What is the goal of this PR?
- Visual UI overhaul
- UI theme selection
### What changes are included?
- Added a setting "UI Theme": Classic, Lyra
- The classic theme is the current Crosspoint theme
- The Lyra theme implements these mockups:
https://www.figma.com/design/UhxoV4DgUnfrDQgMPPTXog/Lyra-Theme?node-id=2003-7596&t=4CSOZqf0n9uQMxDt-0
by Discord users yagofarias, ruby and gan_shu
- New functions in GFXRenderer to render rounded rectangles, greyscale
fills (using dithering) and thick lines
- Basic UI components are factored into BaseTheme methods which can be
overridden by each additional theme. Methods that are not overridden
will fallback to BaseTheme behavior. This means any new
features/components in CrossPoint only need to be developed for the
"Classic" BaseTheme.
- Additional themes can easily be developed by the community using this
foundation



## Additional Context
- Only the Home, Library and main Settings screens have been implemented
so far, this will be extended to the transfer screens and chapter
selection screen later on, but we need to get the ball rolling somehow
:)
- Loading extra covers on the home screen in the Lyra theme takes a
little more time (about 2 seconds), I added a loading bar popup (reusing
the Indexing progress bar from the reader view, factored into a neat UI
component) but the popup adds ~400ms to the loading time.
- ~~Home screen thumbnails will need to be generated separately for each
theme, because they are displayed in different sizes. Because we're
using dithering, displaying a thumb with the wrong size causes the
picture to look janky or dark as it does on the screenshots above. No
worries this will be fixed in a future PR.~~ Thumbs are now generated
with a size parameter
- UI Icons will need to be implemented in a future PR.
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _**PARTIALLY**_
This is not a vibe coded PR. Copilot was used for autocompletion to save
time but I reviewed, understood and edited all generated code.
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-05 17:50:11 +07:00
|
|
|
serialization::readPod(inputFile, uiTheme);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-02-05 14:37:17 +03:00
|
|
|
readAndValidate(inputFile, frontButtonBack, FRONT_BUTTON_HARDWARE_COUNT);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
readAndValidate(inputFile, frontButtonConfirm, FRONT_BUTTON_HARDWARE_COUNT);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
readAndValidate(inputFile, frontButtonLeft, FRONT_BUTTON_HARDWARE_COUNT);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
readAndValidate(inputFile, frontButtonRight, FRONT_BUTTON_HARDWARE_COUNT);
|
|
|
|
|
frontButtonMappingRead = true;
|
2026-02-05 13:32:05 +01:00
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
|
|
|
|
serialization::readPod(inputFile, fadingFix);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2026-02-06 02:49:04 -05:00
|
|
|
serialization::readPod(inputFile, embeddedStyle);
|
|
|
|
|
if (++settingsRead >= fileSettingsCount) break;
|
2025-12-19 13:37:34 +01:00
|
|
|
} while (false);
|
2025-12-15 13:16:46 +01:00
|
|
|
|
2026-02-05 14:37:17 +03:00
|
|
|
if (frontButtonMappingRead) {
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
CrossPointSettings::validateFrontButtonMapping(*this);
|
2026-02-05 14:37:17 +03:00
|
|
|
} else {
|
|
|
|
|
applyLegacyFrontButtonLayout(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-15 13:16:46 +01:00
|
|
|
inputFile.close();
|
feat: Migrate binary settings to json (#920)
## Summary
* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
- Settings files are now JSON and can be easily read/edited manually
- Easier to inspect application state and settings during development
- JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data
## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
- CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
- RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
- Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
- HalStorage: Added rename() method for backup operations
---
### AI Usage
While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.
Did you use AI tools to help write this code? _** YES**_
---------
Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 07:18:25 +01:00
|
|
|
LOG_DBG("CPS", "Settings loaded from binary file");
|
2025-12-15 13:16:46 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
|
2025-12-30 18:34:46 +10:00
|
|
|
float CrossPointSettings::getReaderLineCompression() const {
|
|
|
|
|
switch (fontFamily) {
|
2025-12-31 01:28:25 +10:00
|
|
|
case BOOKERLY:
|
2025-12-30 18:34:46 +10:00
|
|
|
default:
|
|
|
|
|
switch (lineSpacing) {
|
|
|
|
|
case TIGHT:
|
|
|
|
|
return 0.95f;
|
|
|
|
|
case NORMAL:
|
|
|
|
|
default:
|
|
|
|
|
return 1.0f;
|
|
|
|
|
case WIDE:
|
|
|
|
|
return 1.1f;
|
|
|
|
|
}
|
|
|
|
|
case NOTOSANS:
|
|
|
|
|
switch (lineSpacing) {
|
|
|
|
|
case TIGHT:
|
|
|
|
|
return 0.90f;
|
|
|
|
|
case NORMAL:
|
|
|
|
|
default:
|
|
|
|
|
return 0.95f;
|
|
|
|
|
case WIDE:
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
case OPENDYSLEXIC:
|
|
|
|
|
switch (lineSpacing) {
|
|
|
|
|
case TIGHT:
|
|
|
|
|
return 0.90f;
|
|
|
|
|
case NORMAL:
|
|
|
|
|
default:
|
|
|
|
|
return 0.95f;
|
|
|
|
|
case WIDE:
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-03 08:33:42 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
int CrossPointSettings::getReaderFontId() const {
|
|
|
|
|
switch (fontFamily) {
|
2025-12-31 01:28:25 +10:00
|
|
|
case BOOKERLY:
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
default:
|
|
|
|
|
switch (fontSize) {
|
|
|
|
|
case SMALL:
|
2025-12-31 01:28:25 +10:00
|
|
|
return BOOKERLY_12_FONT_ID;
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
case MEDIUM:
|
|
|
|
|
default:
|
2025-12-31 01:28:25 +10:00
|
|
|
return BOOKERLY_14_FONT_ID;
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
case LARGE:
|
2025-12-31 01:28:25 +10:00
|
|
|
return BOOKERLY_16_FONT_ID;
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
case EXTRA_LARGE:
|
2025-12-31 01:28:25 +10:00
|
|
|
return BOOKERLY_18_FONT_ID;
|
Aleo, Noto Sans, Open Dyslexic fonts (#163)
## Summary
* Swap out Bookerly font due to licensing issues, replace default font
with Aleo
* I did a bunch of searching around for a nice replacement font, and
this trumped several other like Literata, Merriwether, Vollkorn, etc
* Add Noto Sans, and Open Dyslexic as font options
* They can be selected in the settings screen
* Add font size options (Small, Medium, Large, Extra Large)
* Adjustable in settings
* Swap out uses of reader font in headings and replaced with slightly
larger Ubuntu font
* Replaced PixelArial14 font as it was difficult to track down, replace
with Space Grotesk
* Remove auto formatting on generated font files
* Massively speeds up formatting step now that there is a lot more CPP
font source
* Include fonts with their licenses in the repo
## Additional Context
Line compression setting will follow
| Font | Small | Medium | Large | X Large |
| --- | --- | --- | --- | --- |
| Aleo |

|

|

|

|
| Noto Sans |

|

|

|

|
| Open Dyslexic |

|

|

|

|
2025-12-30 18:21:47 +10:00
|
|
|
}
|
|
|
|
|
case NOTOSANS:
|
|
|
|
|
switch (fontSize) {
|
|
|
|
|
case SMALL:
|
|
|
|
|
return NOTOSANS_12_FONT_ID;
|
|
|
|
|
case MEDIUM:
|
|
|
|
|
default:
|
|
|
|
|
return NOTOSANS_14_FONT_ID;
|
|
|
|
|
case LARGE:
|
|
|
|
|
return NOTOSANS_16_FONT_ID;
|
|
|
|
|
case EXTRA_LARGE:
|
|
|
|
|
return NOTOSANS_18_FONT_ID;
|
|
|
|
|
}
|
|
|
|
|
case OPENDYSLEXIC:
|
|
|
|
|
switch (fontSize) {
|
|
|
|
|
case SMALL:
|
|
|
|
|
return OPENDYSLEXIC_8_FONT_ID;
|
|
|
|
|
case MEDIUM:
|
|
|
|
|
default:
|
|
|
|
|
return OPENDYSLEXIC_10_FONT_ID;
|
|
|
|
|
case LARGE:
|
|
|
|
|
return OPENDYSLEXIC_12_FONT_ID;
|
|
|
|
|
case EXTRA_LARGE:
|
|
|
|
|
return OPENDYSLEXIC_14_FONT_ID;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-05 11:07:27 +01:00
|
|
|
}
|