2025-12-03 22:00:29 +11:00
|
|
|
#pragma once
|
|
|
|
|
#include <Epub.h>
|
|
|
|
|
#include <Epub/Section.h>
|
|
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
|
#include <freertos/semphr.h>
|
|
|
|
|
#include <freertos/task.h>
|
|
|
|
|
|
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
|
|
class EpubReaderScreen final : public Screen {
|
|
|
|
|
Epub* epub;
|
|
|
|
|
Section* section = nullptr;
|
|
|
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
|
|
|
SemaphoreHandle_t sectionMutex = nullptr;
|
|
|
|
|
int currentSpineIndex = 0;
|
|
|
|
|
int nextPageNumber = 0;
|
2025-12-05 22:19:44 +11:00
|
|
|
int pagesUntilFullRefresh = 0;
|
2025-12-03 22:00:29 +11:00
|
|
|
bool updateRequired = false;
|
2025-12-04 00:07:25 +11:00
|
|
|
const std::function<void()> onGoHome;
|
2025-12-03 22:00:29 +11:00
|
|
|
|
|
|
|
|
static void taskTrampoline(void* param);
|
|
|
|
|
[[noreturn]] void displayTaskLoop();
|
|
|
|
|
void renderPage();
|
|
|
|
|
void renderStatusBar() const;
|
|
|
|
|
|
|
|
|
|
public:
|
2025-12-04 00:07:25 +11:00
|
|
|
explicit EpubReaderScreen(EpdRenderer* renderer, Epub* epub, const std::function<void()>& onGoHome)
|
|
|
|
|
: Screen(renderer), epub(epub), onGoHome(onGoHome) {}
|
2025-12-03 22:00:29 +11:00
|
|
|
void onEnter() override;
|
|
|
|
|
void onExit() override;
|
|
|
|
|
void handleInput(Input input) override;
|
|
|
|
|
};
|