## Summary * **What is the goal of this PR?** (e.g., Fixes a bug in the user authentication module, Display the book cover image in the **"Continue Reading"** card on the home screen, with fast navigation using framebuffer caching. * **What changes are included?** - Display book cover image in the "Continue Reading" card on home screen - Load cover from cached BMP (same as sleep screen cover) - Add framebuffer store/restore functions (`copyStoredBwBuffer`, `freeStoredBwBuffer`) for fast navigation after initial render - Fix `drawBitmap` scaling bug: apply scale to offset only, not to base coordinates - Add white text boxes behind title/author/continue reading label for readability on cover - Support both EPUB and XTC file cover images - Increase HomeActivity task stack size from 2048 to 4096 for cover image rendering ## Additional Context * Add any other information that might be helpful for the reviewer (e.g., performance implications, potential risks, specific areas to focus on). - Performance: First render loads cover from SD card (~800ms), subsequent navigation uses cached framebuffer (~instant) - Memory: Framebuffer cache uses ~48KB (6 chunks × 8KB) while on home screen, freed on exit - Fallback: If cover image is not available, falls back to standard text-only display - The `drawBitmap` fix corrects a bug where screenY = (y + offset) scale was incorrectly scaling the base coordinates. Now correctly uses screenY = y + (offset scale)
53 lines
2.0 KiB
C++
53 lines
2.0 KiB
C++
#pragma once
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <functional>
|
|
|
|
#include "../Activity.h"
|
|
|
|
class HomeActivity final : public Activity {
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
|
int selectorIndex = 0;
|
|
bool updateRequired = false;
|
|
bool hasContinueReading = false;
|
|
bool hasOpdsUrl = false;
|
|
bool hasCoverImage = false;
|
|
bool coverRendered = false; // Track if cover has been rendered once
|
|
bool coverBufferStored = false; // Track if cover buffer is stored
|
|
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
|
|
std::string lastBookTitle;
|
|
std::string lastBookAuthor;
|
|
std::string coverBmpPath;
|
|
const std::function<void()> onContinueReading;
|
|
const std::function<void()> onReaderOpen;
|
|
const std::function<void()> onSettingsOpen;
|
|
const std::function<void()> onFileTransferOpen;
|
|
const std::function<void()> onOpdsBrowserOpen;
|
|
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void render();
|
|
int getMenuItemCount() const;
|
|
bool storeCoverBuffer(); // Store frame buffer for cover image
|
|
bool restoreCoverBuffer(); // Restore frame buffer from stored cover
|
|
void freeCoverBuffer(); // Free the stored cover buffer
|
|
|
|
public:
|
|
explicit HomeActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
|
const std::function<void()>& onContinueReading, const std::function<void()>& onReaderOpen,
|
|
const std::function<void()>& onSettingsOpen, const std::function<void()>& onFileTransferOpen,
|
|
const std::function<void()>& onOpdsBrowserOpen)
|
|
: Activity("Home", renderer, mappedInput),
|
|
onContinueReading(onContinueReading),
|
|
onReaderOpen(onReaderOpen),
|
|
onSettingsOpen(onSettingsOpen),
|
|
onFileTransferOpen(onFileTransferOpen),
|
|
onOpdsBrowserOpen(onOpdsBrowserOpen) {}
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
};
|