mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 15:17:42 +03:00
Refresh screen every 15 pages to avoid ghosting
This commit is contained in:
parent
a8b6f7eff2
commit
d3743185e7
@ -128,7 +128,7 @@ void EpdRenderer::drawTextBox(const int x, const int y, const std::string& text,
|
||||
int ypos = 0;
|
||||
while (true) {
|
||||
if (end >= length) {
|
||||
drawText(x, y + ypos, text.substr(start, length - start).c_str(), 1, style);
|
||||
drawText(x, y + ypos, text.substr(start, length - start).c_str(), true, style);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ void EpdRenderer::drawTextBox(const int x, const int y, const std::string& text,
|
||||
}
|
||||
|
||||
if (text[end - 1] == '\n') {
|
||||
drawText(x, y + ypos, text.substr(start, end - start).c_str(), 1, style);
|
||||
drawText(x, y + ypos, text.substr(start, end - start).c_str(), true, style);
|
||||
ypos += getLineHeight();
|
||||
start = end;
|
||||
end = start + 1;
|
||||
@ -145,7 +145,7 @@ void EpdRenderer::drawTextBox(const int x, const int y, const std::string& text,
|
||||
}
|
||||
|
||||
if (getTextWidth(text.substr(start, end - start).c_str(), style) > width) {
|
||||
drawText(x, y + ypos, text.substr(start, end - start - 1).c_str(), 1, style);
|
||||
drawText(x, y + ypos, text.substr(start, end - start - 1).c_str(), true, style);
|
||||
ypos += getLineHeight();
|
||||
start = end - 1;
|
||||
continue;
|
||||
@ -204,8 +204,8 @@ void EpdRenderer::clearScreen(const uint8_t color) const {
|
||||
einkDisplay.clearScreen(color);
|
||||
}
|
||||
|
||||
void EpdRenderer::flushDisplay(const bool partialUpdate) const {
|
||||
einkDisplay.displayBuffer(partialUpdate ? EInkDisplay::FAST_REFRESH : EInkDisplay::FULL_REFRESH);
|
||||
void EpdRenderer::flushDisplay(const EInkDisplay::RefreshMode refreshMode) const {
|
||||
einkDisplay.displayBuffer(refreshMode);
|
||||
}
|
||||
|
||||
// TODO: Support partial window update
|
||||
|
||||
@ -37,7 +37,7 @@ class EpdRenderer {
|
||||
void copyGrayscaleMsbBuffers() const;
|
||||
void displayGrayBuffer() const;
|
||||
void clearScreen(uint8_t color = 0xFF) const;
|
||||
void flushDisplay(bool partialUpdate = true) const;
|
||||
void flushDisplay(EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH) const;
|
||||
void flushArea(int x, int y, int width, int height) const;
|
||||
|
||||
int getPageWidth() const;
|
||||
|
||||
@ -165,7 +165,7 @@ void TextBlock::render(const EpdRenderer& renderer, const int x, const int y) co
|
||||
} else if (wordStyles[i] & ITALIC_SPAN) {
|
||||
fontStyle = ITALIC;
|
||||
}
|
||||
renderer.drawText(x + wordXpos[i], y, words[i].c_str(), 1, fontStyle);
|
||||
renderer.drawText(x + wordXpos[i], y, words[i].c_str(), true, fontStyle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ void onSelectEpubFile(const std::string& path) {
|
||||
enterNewScreen(new EpubReaderScreen(renderer, inputManager, epub, onGoHome));
|
||||
} else {
|
||||
exitScreen();
|
||||
enterNewScreen(new FullScreenMessageScreen(renderer, inputManager, "Failed to load epub", REGULAR, false, false));
|
||||
enterNewScreen(new FullScreenMessageScreen(renderer, inputManager, "Failed to load epub", REGULAR, EInkDisplay::HALF_REFRESH));
|
||||
delay(2000);
|
||||
onGoHome();
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
#include "Battery.h"
|
||||
|
||||
constexpr int PAGES_PER_REFRESH = 20;
|
||||
constexpr int PAGES_PER_REFRESH = 15;
|
||||
constexpr unsigned long SKIP_CHAPTER_MS = 700;
|
||||
|
||||
void EpubReaderScreen::taskTrampoline(void* param) {
|
||||
@ -218,10 +218,16 @@ void EpubReaderScreen::renderScreen() {
|
||||
f.close();
|
||||
}
|
||||
|
||||
void EpubReaderScreen::renderContents(const Page* p) const {
|
||||
void EpubReaderScreen::renderContents(const Page* p) {
|
||||
p->render(renderer);
|
||||
renderStatusBar();
|
||||
renderer.flushDisplay();
|
||||
if (pagesUntilFullRefresh <= 1) {
|
||||
renderer.flushDisplay(EInkDisplay::HALF_REFRESH);
|
||||
pagesUntilFullRefresh = PAGES_PER_REFRESH;
|
||||
} else {
|
||||
renderer.flushDisplay();
|
||||
pagesUntilFullRefresh--;
|
||||
}
|
||||
|
||||
// grayscale rendering
|
||||
{
|
||||
|
||||
@ -21,7 +21,7 @@ class EpubReaderScreen final : public Screen {
|
||||
static void taskTrampoline(void* param);
|
||||
[[noreturn]] void displayTaskLoop();
|
||||
void renderScreen();
|
||||
void renderContents(const Page* p) const;
|
||||
void renderContents(const Page *p);
|
||||
void renderStatusBar() const;
|
||||
|
||||
public:
|
||||
|
||||
@ -120,7 +120,7 @@ void FileSelectionScreen::render() const {
|
||||
|
||||
const auto pageWidth = renderer.getPageWidth();
|
||||
const auto titleWidth = renderer.getTextWidth("CrossPoint Reader", BOLD);
|
||||
renderer.drawText((pageWidth - titleWidth) / 2, 0, "CrossPoint Reader", 1, BOLD);
|
||||
renderer.drawText((pageWidth - titleWidth) / 2, 0, "CrossPoint Reader", true, BOLD);
|
||||
|
||||
if (files.empty()) {
|
||||
renderer.drawUiText(10, 50, "No EPUBs found");
|
||||
@ -130,7 +130,7 @@ void FileSelectionScreen::render() const {
|
||||
|
||||
for (size_t i = 0; i < files.size(); i++) {
|
||||
const auto file = files[i];
|
||||
renderer.drawUiText(10, 50 + i * 30, file.c_str(), i == selectorIndex ? 0 : 1);
|
||||
renderer.drawUiText(10, 50 + i * 30, file.c_str(), i != selectorIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ void FullScreenMessageScreen::onEnter() {
|
||||
const auto left = (renderer.getPageWidth() - width) / 2;
|
||||
const auto top = (renderer.getPageHeight() - height) / 2;
|
||||
|
||||
renderer.clearScreen(invert);
|
||||
renderer.drawUiText(left, top, text.c_str(), invert ? 0 : 1, style);
|
||||
renderer.flushDisplay(partialUpdate);
|
||||
renderer.clearScreen();
|
||||
renderer.drawUiText(left, top, text.c_str(), true, style);
|
||||
renderer.flushDisplay(refreshMode);
|
||||
}
|
||||
|
||||
@ -2,23 +2,22 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "EpdFontFamily.h"
|
||||
#include <EInkDisplay.h>
|
||||
#include <EpdFontFamily.h>
|
||||
#include "Screen.h"
|
||||
|
||||
class FullScreenMessageScreen final : public Screen {
|
||||
std::string text;
|
||||
EpdFontStyle style;
|
||||
bool invert;
|
||||
bool partialUpdate;
|
||||
EInkDisplay::RefreshMode refreshMode;
|
||||
|
||||
public:
|
||||
explicit FullScreenMessageScreen(EpdRenderer& renderer, InputManager& inputManager, std::string text,
|
||||
const EpdFontStyle style = REGULAR, const bool invert = false,
|
||||
const bool partialUpdate = true)
|
||||
const EpdFontStyle style = REGULAR,
|
||||
const EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH)
|
||||
: Screen(renderer, inputManager),
|
||||
text(std::move(text)),
|
||||
style(style),
|
||||
invert(invert),
|
||||
partialUpdate(partialUpdate) {}
|
||||
refreshMode(refreshMode) {}
|
||||
void onEnter() override;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user