feat(eink): full refresh interval setting in Settings › Display

Add "Full rfsh" setting (e-ink only) with options off/5/10/20/30
partial refreshes between full refreshes. Prevents ghosting on panels
that accumulate artifacts after many partial updates.

GxEPDDisplay counts partial refreshes and calls display.display(false)
every N frames when the interval is set. Persisted in DataStore and
applied at startup via applyFullRefreshInterval().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-24 10:22:03 +02:00
parent 8012278483
commit a6bf3ee08f
8 changed files with 54 additions and 1 deletions

View File

@@ -295,6 +295,7 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
rd(&_prefs.display_rotation, sizeof(_prefs.display_rotation));
rd(_prefs.page_order, sizeof(_prefs.page_order));
rd(&_prefs.joystick_rotation, sizeof(_prefs.joystick_rotation));
rd(&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every));
file.close();
}
@@ -374,6 +375,7 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
file.write((uint8_t *)&_prefs.display_rotation, sizeof(_prefs.display_rotation));
file.write((uint8_t *)_prefs.page_order, sizeof(_prefs.page_order));
file.write((uint8_t *)&_prefs.joystick_rotation, sizeof(_prefs.joystick_rotation));
file.write((uint8_t *)&_prefs.eink_full_refresh_every, sizeof(_prefs.eink_full_refresh_every));
file.close();
}

View File

@@ -85,6 +85,7 @@ struct NodePrefs { // persisted to file
// 0 = end of list (also uninitialized legacy). hasCustomOrder iff page_order[0] in 1..11.
uint8_t page_order[11];
uint8_t joystick_rotation; // 0-3 steps CW; independent of display_rotation
uint8_t eink_full_refresh_every; // index into {0,5,10,20,30}: full refresh every N partials (0=off)
// Bitmasks for home_pages_mask (bit=1 → page visible; 0 field = all visible).
static const uint16_t HP_CLOCK = 1 << 0;

View File

@@ -26,6 +26,9 @@ class SettingsScreen : public UIScreen {
#endif
#if defined(EINK_DISPLAY_MODEL)
JOY_ROTATION,
#endif
#if defined(EINK_DISPLAY_MODEL)
EINK_FULL_REFRESH,
#endif
// Sound section
SECTION_SOUND,
@@ -85,6 +88,10 @@ class SettingsScreen : public UIScreen {
static const int LOW_BAT_COUNT = 7;
static const char* BATT_DISPLAY_LABELS[3];
static const int BATT_DISPLAY_COUNT = 3;
#if defined(EINK_DISPLAY_MODEL)
static const char* EINK_FULL_REFRESH_LABELS[5];
static const int EINK_FULL_REFRESH_COUNT = 5;
#endif
int lowBatIndex() {
NodePrefs* p = _task->getNodePrefs();
@@ -438,6 +445,14 @@ class SettingsScreen : public UIScreen {
{ static const char* ROT_LABELS[] = { "0 deg", "90 deg", "180 deg", "270 deg" };
uint8_t r = p ? (p->joystick_rotation & 3) : 0;
display.print(ROT_LABELS[r]); }
#endif
#if defined(EINK_DISPLAY_MODEL)
} else if (item == EINK_FULL_REFRESH) {
display.print("Full rfsh");
display.setCursor(display.valCol(), y);
{ uint8_t idx = p ? p->eink_full_refresh_every : 0;
if (idx >= EINK_FULL_REFRESH_COUNT) idx = 0;
display.print(EINK_FULL_REFRESH_LABELS[idx]); }
#endif
} else if (item == DM_FILTER) {
display.print("DM");
@@ -669,6 +684,17 @@ public:
_dirty = true;
return true;
}
#endif
#if defined(EINK_DISPLAY_MODEL)
if (_selected == EINK_FULL_REFRESH && p && (left || right || enter)) {
int idx = p->eink_full_refresh_every;
if (idx >= EINK_FULL_REFRESH_COUNT) idx = 0;
idx = (idx + (left ? EINK_FULL_REFRESH_COUNT - 1 : 1)) % EINK_FULL_REFRESH_COUNT;
p->eink_full_refresh_every = idx;
_task->applyFullRefreshInterval();
_dirty = true;
return true;
}
#endif
if (_selected == DM_FILTER && p && (left || right || enter)) {
p->dm_show_all = p->dm_show_all ? 0 : 1;
@@ -702,3 +728,6 @@ const char* SettingsScreen::GPS_INTERVAL_LABELS[6] = { "off", "30s", "1min",
const uint16_t SettingsScreen::LOW_BAT_OPTS[7] = { 0, 3000, 3100, 3200, 3300, 3400, 3500 };
const char* SettingsScreen::LOW_BAT_LABELS[7] = { "off", "3.0V", "3.1V", "3.2V", "3.3V", "3.4V", "3.5V" };
const char* SettingsScreen::BATT_DISPLAY_LABELS[3] = { "icon", "%", "V" };
#if defined(EINK_DISPLAY_MODEL)
const char* SettingsScreen::EINK_FULL_REFRESH_LABELS[5] = { "off", "5", "10", "20", "30" };
#endif

View File

@@ -903,6 +903,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
applyBrightness();
applyFont();
applyRotation();
applyFullRefreshInterval();
setCurrScreen(splash);
}
@@ -1662,6 +1663,16 @@ void UITask::applyRotation() {
}
}
void UITask::applyFullRefreshInterval() {
if (_display != NULL && _node_prefs != NULL) {
static const uint8_t OPTS[] = { 0, 5, 10, 20, 30 };
static const int OPTS_COUNT = 5;
uint8_t idx = _node_prefs->eink_full_refresh_every;
if (idx >= OPTS_COUNT) idx = 0;
_display->setFullRefreshInterval(OPTS[idx]);
}
}
void UITask::setBrightnessLevel(uint8_t level) {
if (_node_prefs == NULL) return;
if (level > 4) level = 4;

View File

@@ -161,6 +161,7 @@ public:
void applyGPSInterval();
void applyFont();
void applyRotation();
void applyFullRefreshInterval();
uint32_t autoOffMillis() const {
if (!_node_prefs || _node_prefs->auto_off_secs == 0) return 0;
return (uint32_t)_node_prefs->auto_off_secs * 1000UL;

View File

@@ -228,5 +228,6 @@ public:
virtual void setBrightness(uint8_t level) { } // level 0-4 (min to max), no-op default
virtual void setDisplayRotation(uint8_t rot) { } // 0-3, no-op for fixed-orientation displays
virtual void setFullRefreshInterval(uint8_t n) { } // e-ink: do full refresh every n partial refreshes (0=never)
virtual void endFrame() = 0;
};

View File

@@ -195,7 +195,12 @@ void GxEPDDisplay::setDisplayRotation(uint8_t rot) {
void GxEPDDisplay::endFrame() {
uint32_t crc = display_crc.finalize();
if (crc != last_display_crc_value) {
display.display(true);
bool partial = true;
if (_full_refresh_interval > 0 && ++_partial_count >= _full_refresh_interval) {
partial = false;
_partial_count = 0;
}
display.display(partial);
last_display_crc_value = crc;
}
}

View File

@@ -54,6 +54,8 @@ class GxEPDDisplay : public DisplayDriver {
CRC32 display_crc;
int last_display_crc_value = 0;
int _text_sz = 1;
uint8_t _full_refresh_interval = 0; // 0=never, N=full refresh every N partial refreshes
uint8_t _partial_count = 0;
public:
#if defined(EINK_DISPLAY_MODEL)
@@ -100,5 +102,6 @@ public:
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
uint16_t getTextWidth(const char* str) override;
void setDisplayRotation(uint8_t rot) override;
void setFullRefreshInterval(uint8_t n) override { _full_refresh_interval = n; _partial_count = 0; }
void endFrame() override;
};