mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
Compare commits
4 Commits
e290accd3e
...
89b5e1b24b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89b5e1b24b | ||
|
|
78d6e5931c | ||
|
|
dac11c3fdd | ||
|
|
fcec6a0b97 |
@ -102,13 +102,18 @@ After flashing the new features, it’s 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
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user