feat: Allow for sunlight fading fix (#15)

See crosspoint-reader/crosspoint-reader#561 for details.

This PR contains necessary changes to be able to implement a fix for the
sunlight fading issue present on the XTEINK X4.

Basically, I'm making sure for all necessary functions to have a
parameter turnOffScreen and to pass it through to displayBuffer() .

displayBuffer() then won't do a HALF_REFRESH if if turnOffScreen is true
and also pass it down to refreshDisplay().
This commit is contained in:
Maik Allgöwer
2026-02-02 00:36:37 +11:00
committed by GitHub
parent c39f253a7d
commit c8ce3949b3
2 changed files with 8 additions and 7 deletions
@@ -42,9 +42,9 @@ class EInkDisplay {
void cleanupGrayscaleBuffers(const uint8_t* bwBuffer);
#endif
void displayBuffer(RefreshMode mode = FAST_REFRESH);
void displayBuffer(RefreshMode mode = FAST_REFRESH, bool turnOffScreen = false);
// EXPERIMENTAL: Windowed update - display only a rectangular region
void displayWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
void displayWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool turnOffScreen = false);
void displayGrayBuffer(bool turnOffScreen = false);
void refreshDisplay(RefreshMode mode = FAST_REFRESH, bool turnOffScreen = false);
+6 -5
View File
@@ -408,8 +408,9 @@ void EInkDisplay::cleanupGrayscaleBuffers(const uint8_t* bwBuffer) {
}
#endif
void EInkDisplay::displayBuffer(RefreshMode mode) {
if (!isScreenOn) {
void EInkDisplay::displayBuffer(RefreshMode mode, const bool turnOffScreen) {
if (!isScreenOn && !turnOffScreen)
{
// Force half refresh if screen is off
mode = HALF_REFRESH;
}
@@ -442,7 +443,7 @@ void EInkDisplay::displayBuffer(RefreshMode mode) {
#endif
// Refresh the display
refreshDisplay(mode);
refreshDisplay(mode, turnOffScreen);
#ifdef EINK_DISPLAY_SINGLE_BUFFER_MODE
// In single buffer mode always sync RED RAM after refresh to prepare for next fast refresh
@@ -455,7 +456,7 @@ void EInkDisplay::displayBuffer(RefreshMode mode) {
// EXPERIMENTAL: Windowed update support
// Displays only a rectangular region of the frame buffer, preserving the rest of the screen.
// Requirements: x and w must be byte-aligned (multiples of 8 pixels)
void EInkDisplay::displayWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
void EInkDisplay::displayWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const bool turnOffScreen) {
if (Serial) Serial.printf("[%lu] Displaying window at (%d,%d) size (%dx%d)\n", millis(), x, y, w, h);
// Validate bounds
@@ -517,7 +518,7 @@ void EInkDisplay::displayWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
#endif
// Perform fast refresh
refreshDisplay(FAST_REFRESH);
refreshDisplay(FAST_REFRESH, turnOffScreen);
#ifdef EINK_DISPLAY_SINGLE_BUFFER_MODE
// Post-refresh: Sync RED RAM with current window (for next fast refresh)