Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

### Fixed

- Small images that are scaled up, such as a short progressive JPEG, are now cached after the first draw instead of being decoded again on every screen refresh.
- The serial log no longer reports errors for normal events: a missing image, section or dictionary cache file on first open, an outdated section cache being rebuilt, and a device without a clock chip or motion sensor. Log lines that were missing a line break now end cleanly, and SD, display, TLS and frontlight messages use the standard log format.
- X4 Pro light-sleep firmware shows its real version (for example `1.6.0-x4-pro`) instead of "dev" in Settings, on the boot screen, and in the web and OTA version checks.
- Background Library indexing and the reader's next-page draw-ahead run at full CPU speed again instead of the lowest idle clock.
- USB Drive no longer reads ahead into the sectors a computer is about to write, so copying files to the card is not slowed by background reads.
Expand Down
6 changes: 3 additions & 3 deletions lib/Epub/Epub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,10 +1578,10 @@ bool Epub::seedOptimizerImageCache(const std::string& itemHref, const int expect
return false;
}
// Existing exact-layout output always wins, even if the optional transport is corrupt.
FsFile existing;
FsFile existing = Storage.open(destPxcPath.c_str()); // quiet: a miss is expected
uint16_t w = 0, h = 0;
bool cached = Storage.openFileForRead("EBP", destPxcPath, existing) && readPxcHeader(existing, w, h) &&
w == expectedWidth && h == expectedHeight && existing.size() == pxcByteCount(w, h);
bool cached = existing && readPxcHeader(existing, w, h) && w == expectedWidth && h == expectedHeight &&
existing.size() == pxcByteCount(w, h);
existing.close();
if (cached) {
Storage.remove(backup.c_str());
Expand Down
7 changes: 5 additions & 2 deletions lib/Epub/Epub/Section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ bool Section::writeSectionFileHeader(const ReaderRenderSpec& spec) {
}

bool Section::loadSectionFile(const ReaderRenderSpec& spec) {
if (!Storage.openFileForRead("SCT", filePath, file)) {
// Quiet open: no section file yet is the normal first-open case.
file = Storage.open(filePath.c_str());
if (!file) {
return false;
}

Expand Down Expand Up @@ -286,7 +288,8 @@ bool Section::loadSectionFile(const ReaderRenderSpec& spec) {
if (version != SECTION_FILE_VERSION && version != SECTION_FILE_PARTIAL_VERSION) {
// Explicit close() required: member variable persists beyond function scope
file.close();
LOG_ERR("SCT", "Deserialization failed: Unknown version %u", version);
LOG_INF("SCT", "Stale section cache v%u (want v%u), rebuilding", static_cast<unsigned>(version),
static_cast<unsigned>(SECTION_FILE_VERSION));
clearCache();
return false;
}
Expand Down
9 changes: 5 additions & 4 deletions lib/Epub/Epub/blocks/ImageBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ bool renderFromCache(GfxRenderer& renderer, const std::string& cachePath, int x,
return renderCachedPixels(renderer, retained->pixels.get(), retained->width, retained->height, x, y);
}

FsFile cacheFile;
if (!Storage.openFileForRead("IMG", cachePath, cacheFile)) {
// Quiet open: a missing cache is the normal first-render case.
FsFile cacheFile = Storage.open(cachePath.c_str());
if (!cacheFile) {
invalidateRetainedPxcPath(cachePath);
return false;
}
Expand Down Expand Up @@ -412,8 +413,8 @@ bool renderFromCache(GfxRenderer& renderer, const std::string& cachePath, int x,

bool ImageBlock::hasValidCache() const {
const auto cachePath = getCachePath(imagePath);
FsFile cacheFile;
if (!Storage.openFileForRead("IMG", cachePath, cacheFile)) {
FsFile cacheFile = Storage.open(cachePath.c_str()); // quiet: a miss is expected
if (!cacheFile) {
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions lib/Epub/Epub/converters/PixelCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ struct PixelCache {
flushedRows = 0;
ok = false;

// The decoder clamps every block to the image height, so a block never
// writes more than h rows. Without this, a short upscaled image (a DC-only
// progressive JPEG block can span 121 rows for a 67-row image) never gets
// a cache and is re-decoded on every render pass.
if (maxBlockDstRows > h) maxBlockDstRows = h;

int wantRows = maxBlockDstRows + 2;
if (wantRows < MIN_BAND_ROWS) wantRows = MIN_BAND_ROWS;
if (wantRows > h) wantRows = h;
Expand Down
2 changes: 1 addition & 1 deletion lib/hal/HalClock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void adjustDateByDays(uint16_t& year, uint8_t& month, uint8_t& day, const int da

void HalClock::begin() {
_available = _sdkRtc.begin();
LOG_INF("CLK", _available ? "SDK RTC found" : "RTC not found");
LOG_INF("CLK", "%s", _available ? "SDK RTC found" : "RTC not found");
}

bool HalClock::refresh(const bool needDate) const {
Expand Down
2 changes: 1 addition & 1 deletion lib/hal/HalTiltSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void HalTiltSensor::begin() {
LOG_INF("GYR", "SDK IMU initialized");
return;
}
LOG_ERR("GYR", "SDK IMU not found");
LOG_INF("GYR", "SDK IMU not found");
}

bool HalTiltSensor::wake() {
Expand Down
10 changes: 6 additions & 4 deletions src/CrossPointSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,13 @@ bool CrossPointSettings::loadFromFile() {
}
if (result && (resave || migrateToCurrentPath)) {
if (saveToFile()) {
LOG_DBG("CPS", migrateToCurrentPath ? "Migrated legacy settings.json to crossink-settings.json"
: "Resaved settings to update format");
LOG_DBG("CPS", "%s",
migrateToCurrentPath ? "Migrated legacy settings.json to crossink-settings.json"
: "Resaved settings to update format");
} else {
LOG_ERR("CPS", migrateToCurrentPath ? "Failed to save migrated settings to crossink-settings.json"
: "Failed to resave settings after format update");
LOG_ERR("CPS", "%s",
migrateToCurrentPath ? "Failed to save migrated settings to crossink-settings.json"
: "Failed to resave settings after format update");
}
}
migrateLanguageBinaryFile();
Expand Down
9 changes: 5 additions & 4 deletions src/util/Dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ std::string Dictionary::readConfiguredDictPath(const char* cachePath) {
// Try per-book dictionary.bin first when cachePath is provided.
if (cachePath && cachePath[0] != '\0') {
snprintf(binPath, sizeof(binPath), "%s/%s", cachePath, DICT_BIN);
HalFile f;
if (Storage.openFileForRead("DICT", binPath, f)) {
// Quiet probe: a missing per-book file just means "Use Global".
HalFile f = Storage.open(binPath);
if (f) {
const int sz = static_cast<int>(f.fileSize());
if (sz > 0) {
std::string result(sz, '\0');
Expand All @@ -155,8 +156,8 @@ std::string Dictionary::readConfiguredDictPath(const char* cachePath) {

// Read global dictionary.bin.
snprintf(binPath, sizeof(binPath), "%s/%s", GLOBAL_DICT_DIR, DICT_BIN);
HalFile f;
if (!Storage.openFileForRead("DICT", binPath, f)) return "";
HalFile f = Storage.open(binPath); // quiet probe: no global dictionary configured
if (!f) return "";
const int sz = static_cast<int>(f.fileSize());
if (sz <= 0) {
f.close();
Expand Down
2 changes: 1 addition & 1 deletion test/memory_policy/stubs/HalStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class HalStorage {
return true;
}

HalFile open(const char* path, oflag_t) {
HalFile open(const char* path, oflag_t = O_RDONLY) {
const auto found = files_.find(path);
return found == files_.end() ? HalFile{} : HalFile(found->second);
}
Expand Down
2 changes: 1 addition & 1 deletion test/pxc_v2/stubs/HalStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class HalStorage {
return true;
}

HalFile open(const char* path, oflag_t) {
HalFile open(const char* path, oflag_t = O_RDONLY) {
const auto found = files_.find(path);
return found == files_.end() ? HalFile{} : HalFile(found->second);
}
Expand Down
2 changes: 1 addition & 1 deletion test/section_persistence/stubs/HalStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class HalStorage {
return true;
}

HalFile open(const char* path, oflag_t) {
HalFile open(const char* path, oflag_t = O_RDONLY) {
const auto found = files_.find(path);
return found == files_.end() ? HalFile{} : HalFile(found->second);
}
Expand Down
Loading