merge upstream/master: logging pragma, screenshot retrieval, nbsp fix
Merge 3 upstream commits into mod/master: - feat: Allow screenshot retrieval from device (#820) - feat: Add central logging pragma (#843) - fix: Account for nbsp character as non-breaking space (#757) Conflict resolution: - src/main.cpp: kept mod's HalPowerManager + upstream's Logging/screenshot - SleepActivity.cpp: kept mod's letterbox fill rework, applied LOG_* pattern Additional changes for logging compatibility: - Converted remaining Serial.printf calls in mod files to LOG_* macros (HalPowerManager, BookSettings, BookmarkStore, GfxRenderer) - Added ENABLE_SERIAL_LOG and LOG_LEVEL=2 to [env:mod] build flags Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -200,8 +200,7 @@ void TxtReaderActivity::initializeReader() {
|
||||
linesPerPage = viewportHeight / lineHeight;
|
||||
if (linesPerPage < 1) linesPerPage = 1;
|
||||
|
||||
Serial.printf("[%lu] [TRS] Viewport: %dx%d, lines per page: %d\n", millis(), viewportWidth, viewportHeight,
|
||||
linesPerPage);
|
||||
LOG_DBG("TRS", "Viewport: %dx%d, lines per page: %d", viewportWidth, viewportHeight, linesPerPage);
|
||||
|
||||
// Try to load cached page index first
|
||||
if (!loadPageIndexCache()) {
|
||||
@@ -224,7 +223,7 @@ void TxtReaderActivity::buildPageIndex() {
|
||||
size_t offset = 0;
|
||||
const size_t fileSize = txt->getFileSize();
|
||||
|
||||
Serial.printf("[%lu] [TRS] Building page index for %zu bytes...\n", millis(), fileSize);
|
||||
LOG_DBG("TRS", "Building page index for %zu bytes...", fileSize);
|
||||
|
||||
GUI.drawPopup(renderer, "Indexing...");
|
||||
|
||||
@@ -253,7 +252,7 @@ void TxtReaderActivity::buildPageIndex() {
|
||||
}
|
||||
|
||||
totalPages = pageOffsets.size();
|
||||
Serial.printf("[%lu] [TRS] Built page index: %d pages\n", millis(), totalPages);
|
||||
LOG_DBG("TRS", "Built page index: %d pages", totalPages);
|
||||
}
|
||||
|
||||
bool TxtReaderActivity::loadPageAtOffset(size_t offset, std::vector<std::string>& outLines, size_t& nextOffset) {
|
||||
@@ -268,7 +267,7 @@ bool TxtReaderActivity::loadPageAtOffset(size_t offset, std::vector<std::string>
|
||||
size_t chunkSize = std::min(CHUNK_SIZE, fileSize - offset);
|
||||
auto* buffer = static_cast<uint8_t*>(malloc(chunkSize + 1));
|
||||
if (!buffer) {
|
||||
Serial.printf("[%lu] [TRS] Failed to allocate %zu bytes\n", millis(), chunkSize);
|
||||
LOG_ERR("TRS", "Failed to allocate %zu bytes", chunkSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -597,7 +596,7 @@ void TxtReaderActivity::loadProgress() {
|
||||
if (currentPage < 0) {
|
||||
currentPage = 0;
|
||||
}
|
||||
Serial.printf("[%lu] [TRS] Loaded progress: page %d/%d\n", millis(), currentPage, totalPages);
|
||||
LOG_DBG("TRS", "Loaded progress: page %d/%d", currentPage, totalPages);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
@@ -619,7 +618,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
std::string cachePath = txt->getCachePath() + "/index.bin";
|
||||
FsFile f;
|
||||
if (!Storage.openFileForRead("TRS", cachePath, f)) {
|
||||
Serial.printf("[%lu] [TRS] No page index cache found\n", millis());
|
||||
LOG_DBG("TRS", "No page index cache found");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -627,7 +626,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
uint32_t magic;
|
||||
serialization::readPod(f, magic);
|
||||
if (magic != CACHE_MAGIC) {
|
||||
Serial.printf("[%lu] [TRS] Cache magic mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache magic mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -635,7 +634,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
uint8_t version;
|
||||
serialization::readPod(f, version);
|
||||
if (version != CACHE_VERSION) {
|
||||
Serial.printf("[%lu] [TRS] Cache version mismatch (%d != %d), rebuilding\n", millis(), version, CACHE_VERSION);
|
||||
LOG_DBG("TRS", "Cache version mismatch (%d != %d), rebuilding", version, CACHE_VERSION);
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -643,7 +642,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
uint32_t fileSize;
|
||||
serialization::readPod(f, fileSize);
|
||||
if (fileSize != txt->getFileSize()) {
|
||||
Serial.printf("[%lu] [TRS] Cache file size mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache file size mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -651,7 +650,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
int32_t cachedWidth;
|
||||
serialization::readPod(f, cachedWidth);
|
||||
if (cachedWidth != viewportWidth) {
|
||||
Serial.printf("[%lu] [TRS] Cache viewport width mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache viewport width mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -659,7 +658,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
int32_t cachedLines;
|
||||
serialization::readPod(f, cachedLines);
|
||||
if (cachedLines != linesPerPage) {
|
||||
Serial.printf("[%lu] [TRS] Cache lines per page mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache lines per page mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -667,7 +666,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
int32_t fontId;
|
||||
serialization::readPod(f, fontId);
|
||||
if (fontId != cachedFontId) {
|
||||
Serial.printf("[%lu] [TRS] Cache font ID mismatch (%d != %d), rebuilding\n", millis(), fontId, cachedFontId);
|
||||
LOG_DBG("TRS", "Cache font ID mismatch (%d != %d), rebuilding", fontId, cachedFontId);
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -675,7 +674,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
int32_t margin;
|
||||
serialization::readPod(f, margin);
|
||||
if (margin != cachedScreenMargin) {
|
||||
Serial.printf("[%lu] [TRS] Cache screen margin mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache screen margin mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -683,7 +682,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
uint8_t alignment;
|
||||
serialization::readPod(f, alignment);
|
||||
if (alignment != cachedParagraphAlignment) {
|
||||
Serial.printf("[%lu] [TRS] Cache paragraph alignment mismatch, rebuilding\n", millis());
|
||||
LOG_DBG("TRS", "Cache paragraph alignment mismatch, rebuilding");
|
||||
f.close();
|
||||
return false;
|
||||
}
|
||||
@@ -703,7 +702,7 @@ bool TxtReaderActivity::loadPageIndexCache() {
|
||||
|
||||
f.close();
|
||||
totalPages = pageOffsets.size();
|
||||
Serial.printf("[%lu] [TRS] Loaded page index cache: %d pages\n", millis(), totalPages);
|
||||
LOG_DBG("TRS", "Loaded page index cache: %d pages", totalPages);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -711,7 +710,7 @@ void TxtReaderActivity::savePageIndexCache() const {
|
||||
std::string cachePath = txt->getCachePath() + "/index.bin";
|
||||
FsFile f;
|
||||
if (!Storage.openFileForWrite("TRS", cachePath, f)) {
|
||||
Serial.printf("[%lu] [TRS] Failed to save page index cache\n", millis());
|
||||
LOG_ERR("TRS", "Failed to save page index cache");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -732,5 +731,5 @@ void TxtReaderActivity::savePageIndexCache() const {
|
||||
}
|
||||
|
||||
f.close();
|
||||
Serial.printf("[%lu] [TRS] Saved page index cache: %d pages\n", millis(), totalPages);
|
||||
LOG_DBG("TRS", "Saved page index cache: %d pages", totalPages);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user