Compare commits

...

4 Commits

Author SHA1 Message Date
pablohc
89b5e1b24b
Merge fcec6a0b97 into 78d6e5931c 2026-02-04 00:34:43 +03:00
Jake Kenneally
78d6e5931c
fix: Correct debugging_monitor.py script instructions (#676)
Some checks are pending
CI / build (push) Waiting to run
## Summary

**What is the goal of this PR?**
- Minor correction to the `debugging_monitor.py` script instructions

**What changes are included?**
- `pyserial` should be installed, NOT `serial`, which is a [different
lib](https://pypi.org/project/serial/)
- Added macOS serial port

## Additional Context

- Just a minor docs update. I can confirm the debugging script is
working great on macOS

---

### 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? _**< NO >**_
2026-02-04 00:33:20 +03:00
Luke Stein
dac11c3fdd
fix: Correct instruction text to match actual button text (#672)
## Summary

* Instruction text says "Press OK to scan again" but button label is
actually "Connect" (not OK)
* Corrects instruction text

---

### AI Usage

Did you use AI tools to help write this code? **No**
2026-02-04 00:32:52 +03:00
pablohc
fcec6a0b97 fix: dynamic continue reading card sizing based on cover image
- Adapt card width to cover image aspect ratio when available
- Maintain fixed 400px height for consistent layout
- Use actual image dimensions instead of hardcoded 240px width for EPUBs
- Add fallback to half-screen size when no cover image exists
2026-02-03 14:43:02 +01:00
5 changed files with 94 additions and 11 deletions

View File

@ -102,13 +102,18 @@ After flashing the new features, its recommended to capture detailed logs fro
First, make sure all required Python packages are installed: First, make sure all required Python packages are installed:
```python ```python
python3 -m pip install serial colorama matplotlib python3 -m pip install pyserial colorama matplotlib
``` ```
after that run the script: after that run the script:
```sh ```sh
# For Linux
# This was tested on Debian and should work on most Linux systems.
python3 scripts/debugging_monitor.py python3 scripts/debugging_monitor.py
# For macOS
python3 scripts/debugging_monitor.py /dev/cu.usbmodem2101
``` ```
This was tested on Debian and should work on most Linux systems. Minor adjustments may be required for Windows or macOS. Minor adjustments may be required for Windows.
## Internals ## Internals

View File

@ -468,10 +468,47 @@ bool Epub::generateThumbBmp() const {
coverJpg.close(); coverJpg.close();
return false; return false;
} }
// Use smaller target size for Continue Reading card (half of screen: 240x400)
// Generate 1-bit BMP for fast home screen rendering (no gray passes needed) // Generate 1-bit BMP maintaining aspect ratio with fixed height of 400px
constexpr int THUMB_TARGET_WIDTH = 240; // This ensures the card width adapts to the actual cover image aspect ratio
constexpr int THUMB_TARGET_HEIGHT = 400; const int THUMB_TARGET_HEIGHT = 400;
// Read a small portion of the JPG file to determine its dimensions
uint8_t headerBuffer[200];
size_t bytesRead = coverJpg.read(headerBuffer, sizeof(headerBuffer));
coverJpg.seek(0); // Reset file position
int imgWidth = 240, imgHeight = 400; // Default fallback
// Simple header parsing to get image dimensions (works for most JPGs)
if (bytesRead > 0) {
// Look for SOF (Start of Frame) markers
for (size_t i = 0; i < bytesRead - 10; i++) {
if (headerBuffer[i] == 0xFF && headerBuffer[i + 1] == 0xC0) {
// Found SOF0 marker
if (i + 7 < bytesRead) {
imgHeight = (headerBuffer[i + 5] << 8) | headerBuffer[i + 6];
imgWidth = (headerBuffer[i + 7] << 8) | headerBuffer[i + 8];
break;
}
} else if (headerBuffer[i] == 0xFF && headerBuffer[i + 1] == 0xC2) {
// Found SOF2 marker
if (i + 7 < bytesRead) {
imgHeight = (headerBuffer[i + 5] << 8) | headerBuffer[i + 6];
imgWidth = (headerBuffer[i + 7] << 8) | headerBuffer[i + 8];
break;
}
}
}
}
// Calculate target width maintaining aspect ratio
const float aspectRatio = static_cast<float>(imgWidth) / static_cast<float>(imgHeight);
const int THUMB_TARGET_WIDTH = static_cast<int>(THUMB_TARGET_HEIGHT * aspectRatio);
Serial.printf("[%lu] [EBP] Original JPG: %dx%d, Target: %dx%d\n", millis(), imgWidth, imgHeight, THUMB_TARGET_WIDTH,
THUMB_TARGET_HEIGHT);
const bool success = JpegToBmpConverter::jpegFileTo1BitBmpStreamWithSize(coverJpg, thumbBmp, THUMB_TARGET_WIDTH, const bool success = JpegToBmpConverter::jpegFileTo1BitBmpStreamWithSize(coverJpg, thumbBmp, THUMB_TARGET_WIDTH,
THUMB_TARGET_HEIGHT); THUMB_TARGET_HEIGHT);
coverJpg.close(); coverJpg.close();

View File

@ -567,5 +567,5 @@ bool JpegToBmpConverter::jpegFileToBmpStreamWithSize(FsFile& jpegFile, Print& bm
// Convert to 1-bit BMP (black and white only, no grays) for fast home screen rendering // Convert to 1-bit BMP (black and white only, no grays) for fast home screen rendering
bool JpegToBmpConverter::jpegFileTo1BitBmpStreamWithSize(FsFile& jpegFile, Print& bmpOut, int targetMaxWidth, bool JpegToBmpConverter::jpegFileTo1BitBmpStreamWithSize(FsFile& jpegFile, Print& bmpOut, int targetMaxWidth,
int targetMaxHeight) { int targetMaxHeight) {
return jpegFileToBmpStreamInternal(jpegFile, bmpOut, targetMaxWidth, targetMaxHeight, true); return jpegFileToBmpStreamInternal(jpegFile, bmpOut, targetMaxWidth, targetMaxHeight, true, false);
} }

View File

@ -224,9 +224,50 @@ void HomeActivity::render() {
constexpr int bottomMargin = 60; constexpr int bottomMargin = 60;
// --- Top "book" card for the current title (selectorIndex == 0) --- // --- Top "book" card for the current title (selectorIndex == 0) ---
const int bookWidth = pageWidth / 2; // When there's no cover image, use fixed size (half screen)
const int bookHeight = pageHeight / 2; // When there's cover image, adapt width to image aspect ratio, keep height fixed at 400px
const int bookX = (pageWidth - bookWidth) / 2; const int baseHeight = 400; // Fixed height for both scenarios
int bookWidth, bookX;
if (hasCoverImage) {
// When there's cover, calculate width based on image aspect ratio
// Use default width ratio as fallback if we can't get image dimensions
const float defaultWidthRatio = 0.5f; // Same as half screen
bookWidth = static_cast<int>(pageWidth * defaultWidthRatio);
// If we have cover bitmap path, try to get actual image dimensions
if (!coverBmpPath.empty()) {
FsFile file;
if (SdMan.openFileForRead("HOME", coverBmpPath, file)) {
Bitmap bitmap(file);
if (bitmap.parseHeaders() == BmpReaderError::Ok) {
const int imgWidth = bitmap.getWidth();
const int imgHeight = bitmap.getHeight();
// Calculate width based on aspect ratio, maintaining 400px height
if (imgHeight > 0) {
const float aspectRatio = static_cast<float>(imgWidth) / static_cast<float>(imgHeight);
bookWidth = static_cast<int>(baseHeight * aspectRatio);
// Ensure width doesn't exceed reasonable limits (max 90% of screen width)
const int maxWidth = static_cast<int>(pageWidth * 0.9f);
if (bookWidth > maxWidth) {
bookWidth = maxWidth;
}
}
}
file.close();
}
}
bookX = (pageWidth - bookWidth) / 2;
} else {
// No cover: use half screen size
bookWidth = pageWidth / 2;
bookX = (pageWidth - bookWidth) / 2;
}
const int bookHeight = baseHeight;
constexpr int bookY = 30; constexpr int bookY = 30;
const bool bookSelected = hasContinueReading && selectorIndex == 0; const bool bookSelected = hasContinueReading && selectorIndex == 0;

View File

@ -520,7 +520,7 @@ void WifiSelectionActivity::renderNetworkList() const {
const auto height = renderer.getLineHeight(UI_10_FONT_ID); const auto height = renderer.getLineHeight(UI_10_FONT_ID);
const auto top = (pageHeight - height) / 2; const auto top = (pageHeight - height) / 2;
renderer.drawCenteredText(UI_10_FONT_ID, top, "No networks found"); renderer.drawCenteredText(UI_10_FONT_ID, top, "No networks found");
renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press OK to scan again"); renderer.drawCenteredText(SMALL_FONT_ID, top + height + 10, "Press Connect to scan again");
} else { } else {
// Calculate how many networks we can display // Calculate how many networks we can display
constexpr int startY = 60; constexpr int startY = 60;