fix: resolve mod build errors after upstream sync

- Update open-x4-sdk submodule to 9f76376 (BatteryMonitor ESP-IDF 5.x compat)
- Add RTC_NOINIT bounds check for logHead in Logging.cpp
- Add drawTextRotated90CCW to GfxRenderer for dictionary UI
- Add getWordXpos() accessor to TextBlock for dictionary word selection
- Fix bare include paths (ActivityResult.h, RenderLock.h) across 10 files
- Fix rvalue ref binding in setResult() lambdas (std::move pattern)
- Fix std::max type mismatch (uint8_t vs int) in EpubReaderActivity
- Fix FsFile forward declaration conflict in Dictionary.h
- Restore StringUtils::checkFileExtension() and sortFileList()
- Restore RecentBooksStore::removeBook()

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-07 20:56:40 -05:00
parent 9464df1727
commit 4627ec95f9
22 changed files with 180 additions and 34 deletions

View File

@@ -28,6 +28,7 @@ class TextBlock final : public Block {
void setBlockStyle(const BlockStyle& blockStyle) { this->blockStyle = blockStyle; }
const BlockStyle& getBlockStyle() const { return blockStyle; }
const std::vector<std::string>& getWords() const { return words; }
const std::vector<int16_t>& getWordXpos() const { return wordXpos; }
bool isEmpty() override { return words.empty(); }
size_t wordCount() const { return words.size(); }
// given a renderer works out where to break the words into lines

View File

@@ -61,7 +61,7 @@ static inline void rotateCoordinates(const GfxRenderer::Orientation orientation,
}
}
enum class TextRotation { None, Rotated90CW };
enum class TextRotation { None, Rotated90CW, Rotated90CCW };
// Shared glyph rendering logic for normal and rotated text.
// Coordinate mapping and cursor advance direction are selected at compile time via the template parameter.
@@ -91,6 +91,9 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
if constexpr (rotation == TextRotation::Rotated90CW) {
outerBase = cursorX + fontData->ascender - top; // screenX = outerBase + glyphY
innerBase = cursorY - left; // screenY = innerBase - glyphX
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
outerBase = cursorX + fontData->advanceY - 1 - fontData->ascender + top; // screenX = outerBase - glyphY
innerBase = cursorY + left; // screenY = innerBase + glyphX
} else {
outerBase = cursorY - top; // screenY = outerBase + glyphY
innerBase = cursorX + left; // screenX = innerBase + glyphX
@@ -99,12 +102,16 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
if (is2Bit) {
int pixelPosition = 0;
for (int glyphY = 0; glyphY < height; glyphY++) {
const int outerCoord = outerBase + glyphY;
const int outerCoord =
(rotation == TextRotation::Rotated90CCW) ? outerBase - glyphY : outerBase + glyphY;
for (int glyphX = 0; glyphX < width; glyphX++, pixelPosition++) {
int screenX, screenY;
if constexpr (rotation == TextRotation::Rotated90CW) {
screenX = outerCoord;
screenY = innerBase - glyphX;
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
screenX = outerCoord;
screenY = innerBase + glyphX;
} else {
screenX = innerBase + glyphX;
screenY = outerCoord;
@@ -133,12 +140,16 @@ static void renderCharImpl(const GfxRenderer& renderer, GfxRenderer::RenderMode
} else {
int pixelPosition = 0;
for (int glyphY = 0; glyphY < height; glyphY++) {
const int outerCoord = outerBase + glyphY;
const int outerCoord =
(rotation == TextRotation::Rotated90CCW) ? outerBase - glyphY : outerBase + glyphY;
for (int glyphX = 0; glyphX < width; glyphX++, pixelPosition++) {
int screenX, screenY;
if constexpr (rotation == TextRotation::Rotated90CW) {
screenX = outerCoord;
screenY = innerBase - glyphX;
} else if constexpr (rotation == TextRotation::Rotated90CCW) {
screenX = outerCoord;
screenY = innerBase + glyphX;
} else {
screenX = innerBase + glyphX;
screenY = outerCoord;
@@ -1243,6 +1254,64 @@ void GfxRenderer::drawTextRotated90CW(const int fontId, const int x, const int y
}
}
void GfxRenderer::drawTextRotated90CCW(const int fontId, const int x, const int y, const char* text, const bool black,
const EpdFontFamily::Style style) const {
if (text == nullptr || *text == '\0') {
return;
}
const auto fontIt = fontMap.find(fontId);
if (fontIt == fontMap.end()) {
LOG_ERR("GFX", "Font %d not found", fontId);
return;
}
const auto& font = fontIt->second;
int32_t yPosFP = fp4::fromPixel(y);
int lastBaseY = y;
int lastBaseAdvanceFP = 0;
int lastBaseTop = 0;
constexpr int MIN_COMBINING_GAP_PX = 1;
uint32_t cp;
uint32_t prevCp = 0;
while ((cp = utf8NextCodepoint(reinterpret_cast<const uint8_t**>(&text)))) {
if (utf8IsCombiningMark(cp)) {
const EpdGlyph* combiningGlyph = font.getGlyph(cp, style);
int raiseBy = 0;
if (combiningGlyph) {
const int currentGap = combiningGlyph->top - combiningGlyph->height - lastBaseTop;
if (currentGap < MIN_COMBINING_GAP_PX) {
raiseBy = MIN_COMBINING_GAP_PX - currentGap;
}
}
const int combiningX = x + raiseBy;
const int combiningY = lastBaseY + fp4::toPixel(lastBaseAdvanceFP / 2);
renderCharImpl<TextRotation::Rotated90CCW>(*this, renderMode, font, cp, combiningX, combiningY, black, style);
continue;
}
cp = font.applyLigatures(cp, text, style);
if (prevCp != 0) {
yPosFP += font.getKerning(prevCp, cp, style); // add for CCW (opposite of CW)
}
lastBaseY = fp4::toPixel(yPosFP);
const EpdGlyph* glyph = font.getGlyph(cp, style);
lastBaseAdvanceFP = glyph ? glyph->advanceX : 0;
lastBaseTop = glyph ? glyph->top : 0;
renderCharImpl<TextRotation::Rotated90CCW>(*this, renderMode, font, cp, x, lastBaseY, black, style);
if (glyph) {
yPosFP += glyph->advanceX; // add for CCW (opposite of CW)
}
prevCp = cp;
}
}
uint8_t* GfxRenderer::getFrameBuffer() const { return frameBuffer; }
size_t GfxRenderer::getBufferSize() { return HalDisplay::BUFFER_SIZE; }

View File

@@ -135,9 +135,11 @@ class GfxRenderer {
std::vector<std::string> wrappedText(int fontId, const char* text, int maxWidth, int maxLines,
EpdFontFamily::Style style = EpdFontFamily::REGULAR) const;
// Helper for drawing rotated text (90 degrees clockwise, for side buttons)
// Helpers for drawing rotated text (for side buttons)
void drawTextRotated90CW(int fontId, int x, int y, const char* text, bool black = true,
EpdFontFamily::Style style = EpdFontFamily::REGULAR) const;
void drawTextRotated90CCW(int fontId, int x, int y, const char* text, bool black = true,
EpdFontFamily::Style style = EpdFontFamily::REGULAR) const;
int getTextHeight(int fontId) const;
// Grayscale functions

View File

@@ -10,7 +10,10 @@ RTC_NOINIT_ATTR char logMessages[MAX_LOG_LINES][MAX_ENTRY_LEN];
RTC_NOINIT_ATTR size_t logHead = 0;
void addToLogRingBuffer(const char* message) {
// Add the message to the ring buffer, overwriting old messages if necessary
// RTC_NOINIT memory may contain garbage after flash erase or power loss
if (logHead >= MAX_LOG_LINES) {
logHead = 0;
}
strncpy(logMessages[logHead], message, MAX_ENTRY_LEN - 1);
logMessages[logHead][MAX_ENTRY_LEN - 1] = '\0';
logHead = (logHead + 1) % MAX_LOG_LINES;