mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
Compare commits
6 Commits
0134c70d9b
...
143e7cb68f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
143e7cb68f | ||
|
|
e20601e177 | ||
|
|
ea76ce6cd5 | ||
|
|
d403044f76 | ||
|
|
e8bb650a38 | ||
|
|
d89b37cd10 |
@ -37,7 +37,7 @@ bool CrossPointSettings::saveToFile() const {
|
|||||||
|
|
||||||
serialization::writePod(outputFile, SETTINGS_FILE_VERSION);
|
serialization::writePod(outputFile, SETTINGS_FILE_VERSION);
|
||||||
serialization::writePod(outputFile, SETTINGS_COUNT);
|
serialization::writePod(outputFile, SETTINGS_COUNT);
|
||||||
serialization::writePod(outputFile, sleepScreen);
|
serialization::writePod(outputFile, sleepScreenMode);
|
||||||
serialization::writePod(outputFile, extraParagraphSpacing);
|
serialization::writePod(outputFile, extraParagraphSpacing);
|
||||||
serialization::writePod(outputFile, shortPwrBtn);
|
serialization::writePod(outputFile, shortPwrBtn);
|
||||||
serialization::writePod(outputFile, statusBar);
|
serialization::writePod(outputFile, statusBar);
|
||||||
@ -51,7 +51,6 @@ bool CrossPointSettings::saveToFile() const {
|
|||||||
serialization::writePod(outputFile, sleepTimeout);
|
serialization::writePod(outputFile, sleepTimeout);
|
||||||
serialization::writePod(outputFile, refreshFrequency);
|
serialization::writePod(outputFile, refreshFrequency);
|
||||||
serialization::writePod(outputFile, screenMargin);
|
serialization::writePod(outputFile, screenMargin);
|
||||||
serialization::writePod(outputFile, sleepScreenCoverMode);
|
|
||||||
serialization::writeString(outputFile, std::string(opdsServerUrl));
|
serialization::writeString(outputFile, std::string(opdsServerUrl));
|
||||||
serialization::writePod(outputFile, textAntiAliasing);
|
serialization::writePod(outputFile, textAntiAliasing);
|
||||||
serialization::writePod(outputFile, hideBatteryPercentage);
|
serialization::writePod(outputFile, hideBatteryPercentage);
|
||||||
@ -59,7 +58,7 @@ bool CrossPointSettings::saveToFile() const {
|
|||||||
serialization::writePod(outputFile, hyphenationEnabled);
|
serialization::writePod(outputFile, hyphenationEnabled);
|
||||||
serialization::writeString(outputFile, std::string(opdsUsername));
|
serialization::writeString(outputFile, std::string(opdsUsername));
|
||||||
serialization::writeString(outputFile, std::string(opdsPassword));
|
serialization::writeString(outputFile, std::string(opdsPassword));
|
||||||
serialization::writePod(outputFile, sleepScreenCoverFilter);
|
serialization::writePod(outputFile, sleepScreenFilter);
|
||||||
// New fields added at end for backward compatibility
|
// New fields added at end for backward compatibility
|
||||||
outputFile.close();
|
outputFile.close();
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ bool CrossPointSettings::loadFromFile() {
|
|||||||
// load settings that exist (support older files with fewer fields)
|
// load settings that exist (support older files with fewer fields)
|
||||||
uint8_t settingsRead = 0;
|
uint8_t settingsRead = 0;
|
||||||
do {
|
do {
|
||||||
readAndValidate(inputFile, sleepScreen, SLEEP_SCREEN_MODE_COUNT);
|
readAndValidate(inputFile, sleepScreenMode, SLEEP_SCREEN_MODE_COUNT);
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
@ -115,8 +114,6 @@ bool CrossPointSettings::loadFromFile() {
|
|||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
serialization::readPod(inputFile, screenMargin);
|
serialization::readPod(inputFile, screenMargin);
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
readAndValidate(inputFile, sleepScreenCoverMode, SLEEP_SCREEN_COVER_MODE_COUNT);
|
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
|
||||||
{
|
{
|
||||||
std::string urlStr;
|
std::string urlStr;
|
||||||
serialization::readString(inputFile, urlStr);
|
serialization::readString(inputFile, urlStr);
|
||||||
@ -146,7 +143,7 @@ bool CrossPointSettings::loadFromFile() {
|
|||||||
opdsPassword[sizeof(opdsPassword) - 1] = '\0';
|
opdsPassword[sizeof(opdsPassword) - 1] = '\0';
|
||||||
}
|
}
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
readAndValidate(inputFile, sleepScreenCoverFilter, SLEEP_SCREEN_COVER_FILTER_COUNT);
|
readAndValidate(inputFile, sleepScreenFilter, SLEEP_SCREEN_FILTER_COUNT);
|
||||||
if (++settingsRead >= fileSettingsCount) break;
|
if (++settingsRead >= fileSettingsCount) break;
|
||||||
// New fields added at end for backward compatibility
|
// New fields added at end for backward compatibility
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|||||||
@ -15,14 +15,8 @@ class CrossPointSettings {
|
|||||||
CrossPointSettings(const CrossPointSettings&) = delete;
|
CrossPointSettings(const CrossPointSettings&) = delete;
|
||||||
CrossPointSettings& operator=(const CrossPointSettings&) = delete;
|
CrossPointSettings& operator=(const CrossPointSettings&) = delete;
|
||||||
|
|
||||||
enum SLEEP_SCREEN_MODE { DARK = 0, LIGHT = 1, CUSTOM = 2, COVER = 3, BLANK = 4, SLEEP_SCREEN_MODE_COUNT };
|
enum SLEEP_SCREEN_MODE { LOGO = 0, CUSTOM = 1, COVER_CROP = 2, COVER_FIT = 3, BLANK = 4, SLEEP_SCREEN_MODE_COUNT };
|
||||||
enum SLEEP_SCREEN_COVER_MODE { FIT = 0, CROP = 1, SLEEP_SCREEN_COVER_MODE_COUNT };
|
enum SLEEP_SCREEN_FILTER { ORIGINAL = 0, CONTRAST = 1, NEGATIVE = 2, SLEEP_SCREEN_FILTER_COUNT };
|
||||||
enum SLEEP_SCREEN_COVER_FILTER {
|
|
||||||
NO_FILTER = 0,
|
|
||||||
BLACK_AND_WHITE = 1,
|
|
||||||
INVERTED_BLACK_AND_WHITE = 2,
|
|
||||||
SLEEP_SCREEN_COVER_FILTER_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
// Status bar display type enum
|
// Status bar display type enum
|
||||||
enum STATUS_BAR_MODE {
|
enum STATUS_BAR_MODE {
|
||||||
@ -98,11 +92,9 @@ class CrossPointSettings {
|
|||||||
enum HIDE_BATTERY_PERCENTAGE { HIDE_NEVER = 0, HIDE_READER = 1, HIDE_ALWAYS = 2, HIDE_BATTERY_PERCENTAGE_COUNT };
|
enum HIDE_BATTERY_PERCENTAGE { HIDE_NEVER = 0, HIDE_READER = 1, HIDE_ALWAYS = 2, HIDE_BATTERY_PERCENTAGE_COUNT };
|
||||||
|
|
||||||
// Sleep screen settings
|
// Sleep screen settings
|
||||||
uint8_t sleepScreen = DARK;
|
uint8_t sleepScreenMode = LOGO;
|
||||||
// Sleep screen cover mode settings
|
// Sleep screen filter
|
||||||
uint8_t sleepScreenCoverMode = FIT;
|
uint8_t sleepScreenFilter = NONE;
|
||||||
// Sleep screen cover filter
|
|
||||||
uint8_t sleepScreenCoverFilter = NO_FILTER;
|
|
||||||
// Status bar settings
|
// Status bar settings
|
||||||
uint8_t statusBar = FULL;
|
uint8_t statusBar = FULL;
|
||||||
// Text rendering settings
|
// Text rendering settings
|
||||||
|
|||||||
@ -18,15 +18,16 @@ void SleepActivity::onEnter() {
|
|||||||
|
|
||||||
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
|
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
|
||||||
|
|
||||||
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) {
|
if (SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) {
|
||||||
return renderBlankSleepScreen();
|
return renderBlankSleepScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::CUSTOM) {
|
if (SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::CUSTOM) {
|
||||||
return renderCustomSleepScreen();
|
return renderCustomSleepScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::COVER) {
|
if (SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_CROP ||
|
||||||
|
SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_FIT) {
|
||||||
return renderCoverSleepScreen();
|
return renderCoverSleepScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,8 +117,8 @@ void SleepActivity::renderDefaultSleepScreen() const {
|
|||||||
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2 + 70, "CrossPoint", true, EpdFontFamily::BOLD);
|
renderer.drawCenteredText(UI_10_FONT_ID, pageHeight / 2 + 70, "CrossPoint", true, EpdFontFamily::BOLD);
|
||||||
renderer.drawCenteredText(SMALL_FONT_ID, pageHeight / 2 + 95, "SLEEPING");
|
renderer.drawCenteredText(SMALL_FONT_ID, pageHeight / 2 + 95, "SLEEPING");
|
||||||
|
|
||||||
// Make sleep screen dark unless light is selected in settings
|
// Make sleep screen negative
|
||||||
if (SETTINGS.sleepScreen != CrossPointSettings::SLEEP_SCREEN_MODE::LIGHT) {
|
if (SETTINGS.sleepScreenFilter == CrossPointSettings::SLEEP_SCREEN_FILTER::NEGATIVE) {
|
||||||
renderer.invertScreen();
|
renderer.invertScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
|
|||||||
Serial.printf("[%lu] [SLP] bitmap ratio: %f, screen ratio: %f\n", millis(), ratio, screenRatio);
|
Serial.printf("[%lu] [SLP] bitmap ratio: %f, screen ratio: %f\n", millis(), ratio, screenRatio);
|
||||||
if (ratio > screenRatio) {
|
if (ratio > screenRatio) {
|
||||||
// image wider than viewport ratio, scaled down image needs to be centered vertically
|
// image wider than viewport ratio, scaled down image needs to be centered vertically
|
||||||
if (SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::CROP) {
|
if (SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_CROP) {
|
||||||
cropX = 1.0f - (screenRatio / ratio);
|
cropX = 1.0f - (screenRatio / ratio);
|
||||||
Serial.printf("[%lu] [SLP] Cropping bitmap x: %f\n", millis(), cropX);
|
Serial.printf("[%lu] [SLP] Cropping bitmap x: %f\n", millis(), cropX);
|
||||||
ratio = (1.0f - cropX) * static_cast<float>(bitmap.getWidth()) / static_cast<float>(bitmap.getHeight());
|
ratio = (1.0f - cropX) * static_cast<float>(bitmap.getWidth()) / static_cast<float>(bitmap.getHeight());
|
||||||
@ -150,7 +151,7 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
|
|||||||
Serial.printf("[%lu] [SLP] Centering with ratio %f to y=%d\n", millis(), ratio, y);
|
Serial.printf("[%lu] [SLP] Centering with ratio %f to y=%d\n", millis(), ratio, y);
|
||||||
} else {
|
} else {
|
||||||
// image taller than viewport ratio, scaled down image needs to be centered horizontally
|
// image taller than viewport ratio, scaled down image needs to be centered horizontally
|
||||||
if (SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::CROP) {
|
if (SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_CROP) {
|
||||||
cropY = 1.0f - (ratio / screenRatio);
|
cropY = 1.0f - (ratio / screenRatio);
|
||||||
Serial.printf("[%lu] [SLP] Cropping bitmap y: %f\n", millis(), cropY);
|
Serial.printf("[%lu] [SLP] Cropping bitmap y: %f\n", millis(), cropY);
|
||||||
ratio = static_cast<float>(bitmap.getWidth()) / ((1.0f - cropY) * static_cast<float>(bitmap.getHeight()));
|
ratio = static_cast<float>(bitmap.getWidth()) / ((1.0f - cropY) * static_cast<float>(bitmap.getHeight()));
|
||||||
@ -168,12 +169,12 @@ void SleepActivity::renderBitmapSleepScreen(const Bitmap& bitmap) const {
|
|||||||
Serial.printf("[%lu] [SLP] drawing to %d x %d\n", millis(), x, y);
|
Serial.printf("[%lu] [SLP] drawing to %d x %d\n", millis(), x, y);
|
||||||
renderer.clearScreen();
|
renderer.clearScreen();
|
||||||
|
|
||||||
const bool hasGreyscale = bitmap.hasGreyscale() &&
|
const bool hasGreyscale =
|
||||||
SETTINGS.sleepScreenCoverFilter == CrossPointSettings::SLEEP_SCREEN_COVER_FILTER::NO_FILTER;
|
bitmap.hasGreyscale() && SETTINGS.sleepScreenFilter == CrossPointSettings::SLEEP_SCREEN_FILTER::ORIGINAL;
|
||||||
|
|
||||||
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY);
|
renderer.drawBitmap(bitmap, x, y, pageWidth, pageHeight, cropX, cropY);
|
||||||
|
|
||||||
if (SETTINGS.sleepScreenCoverFilter == CrossPointSettings::SLEEP_SCREEN_COVER_FILTER::INVERTED_BLACK_AND_WHITE) {
|
if (SETTINGS.sleepScreenFilter == CrossPointSettings::SLEEP_SCREEN_FILTER::NEGATIVE) {
|
||||||
renderer.invertScreen();
|
renderer.invertScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ void SleepActivity::renderCoverSleepScreen() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string coverBmpPath;
|
std::string coverBmpPath;
|
||||||
bool cropped = SETTINGS.sleepScreenCoverMode == CrossPointSettings::SLEEP_SCREEN_COVER_MODE::CROP;
|
bool cropped = SETTINGS.sleepScreenMode == CrossPointSettings::SLEEP_SCREEN_MODE::COVER_CROP;
|
||||||
|
|
||||||
// Check if the current book is XTC, TXT, or EPUB
|
// Check if the current book is XTC, TXT, or EPUB
|
||||||
if (StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".xtc") ||
|
if (StringUtils::checkFileExtension(APP_STATE.openEpubPath, ".xtc") ||
|
||||||
@ -268,5 +269,9 @@ void SleepActivity::renderCoverSleepScreen() const {
|
|||||||
|
|
||||||
void SleepActivity::renderBlankSleepScreen() const {
|
void SleepActivity::renderBlankSleepScreen() const {
|
||||||
renderer.clearScreen();
|
renderer.clearScreen();
|
||||||
|
// Make blank screen negative
|
||||||
|
if (SETTINGS.sleepScreenFilter == CrossPointSettings::SLEEP_SCREEN_FILTER::NEGATIVE) {
|
||||||
|
renderer.invertScreen();
|
||||||
|
}
|
||||||
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -546,8 +546,8 @@ void WifiSelectionActivity::renderNetworkList() const {
|
|||||||
|
|
||||||
// Draw network name (truncate if too long)
|
// Draw network name (truncate if too long)
|
||||||
std::string displayName = network.ssid;
|
std::string displayName = network.ssid;
|
||||||
if (displayName.length() > 16) {
|
if (displayName.length() > 33) {
|
||||||
displayName.replace(13, displayName.length() - 13, "...");
|
displayName.replace(30, displayName.length() - 30, "...");
|
||||||
}
|
}
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, networkY, displayName.c_str());
|
renderer.drawText(UI_10_FONT_ID, 20, networkY, displayName.c_str());
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,12 @@
|
|||||||
const char* SettingsActivity::categoryNames[categoryCount] = {"Display", "Reader", "Controls", "System"};
|
const char* SettingsActivity::categoryNames[categoryCount] = {"Display", "Reader", "Controls", "System"};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
constexpr int displaySettingsCount = 6;
|
constexpr int displaySettingsCount = 5;
|
||||||
const SettingInfo displaySettings[displaySettingsCount] = {
|
const SettingInfo displaySettings[displaySettingsCount] = {
|
||||||
// Should match with SLEEP_SCREEN_MODE
|
// Should match with SLEEP_SCREEN_MODE
|
||||||
SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreen, {"Dark", "Light", "Custom", "Cover", "None"}),
|
SettingInfo::Enum("Sleep Screen", &CrossPointSettings::sleepScreenMode,
|
||||||
SettingInfo::Enum("Sleep Screen Cover Mode", &CrossPointSettings::sleepScreenCoverMode, {"Fit", "Crop"}),
|
{"Logo", "Custom", "Cover Crop", "Cover Fit", "None"}),
|
||||||
SettingInfo::Enum("Sleep Screen Cover Filter", &CrossPointSettings::sleepScreenCoverFilter,
|
SettingInfo::Enum("Sleep Screen Filter", &CrossPointSettings::sleepScreenFilter, {"None", "Contrast", "Negative"}),
|
||||||
{"None", "Contrast", "Inverted"}),
|
|
||||||
SettingInfo::Enum("Status Bar", &CrossPointSettings::statusBar,
|
SettingInfo::Enum("Status Bar", &CrossPointSettings::statusBar,
|
||||||
{"None", "No Progress", "Full w/ Percentage", "Full w/ Progress Bar", "Progress Bar"}),
|
{"None", "No Progress", "Full w/ Percentage", "Full w/ Progress Bar", "Progress Bar"}),
|
||||||
SettingInfo::Enum("Hide Battery %", &CrossPointSettings::hideBatteryPercentage, {"Never", "In Reader", "Always"}),
|
SettingInfo::Enum("Hide Battery %", &CrossPointSettings::hideBatteryPercentage, {"Never", "In Reader", "Always"}),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user