companion: keep mesh/BLE running during e-ink panel refresh

Use GxEPD2's busy callback to run the mesh, interface and sensor loops
(loopCore(), shared with loop()) while the panel refreshes, instead of
blocking the main loop. Covers the partial refresh in endFrame(), the
full wipe in startFrame(), and the sleep icon / blank refresh on turnOff().
This commit is contained in:
akalinin-softvelum committed 2026-10-29 12:38:30 +00:00
1 parent bd4be350c5
commit d8b5724c38
4 files changed
+41 -1

No files matched your search

+9
View File
@@ -88,7 +88,9 @@ void GxEPDDisplay::drawSleepIcon() {
display.fillRect((x - 5) * scale_x - 1, y * scale_y, (W+5) * scale_x + 2, (H-2) * scale_y + 1, GxEPD_WHITE);
_curr_color = GxEPD_BLACK;
drawXbm(x, y, sleep_icon_24x24, W, H);
if (_busy_hook) display.epd2.setBusyCallback(busyCallback, this);
display.display(true);
display.epd2.setBusyCallback(NULL);
}
void GxEPDDisplay::turnOff(bool blank) {
@@ -104,8 +106,10 @@ void GxEPDDisplay::turnOff(bool blank) {
void GxEPDDisplay::blankScreen() {
// do full refresh before powering off to clear screen
// no full refresh needed at wakeup
if (_busy_hook) display.epd2.setBusyCallback(busyCallback, this);
display.clearScreen(0xFF); // Clears microcontroller side RAM
display.writeScreenBuffer(0xFF); // Forces 0xFF (White) into the display controller's history registers
display.epd2.setBusyCallback(NULL);
_partial_refresh_count = 0;
last_display_crc_value = 0;
// we can hibernate as screen has been cleaned
@@ -126,8 +130,10 @@ void GxEPDDisplay::startFrame(ColorVal bkg) {
|| (_max_partial_refresh > 0
&& _partial_refresh_count >= _max_partial_refresh)) {
// forces a full wipe of the screen ...
if (_busy_hook) display.epd2.setBusyCallback(busyCallback, this);
display.clearScreen(0xFF); // Clears microcontroller side RAM
display.writeScreenBuffer(0xFF); // Forces 0xFF (White) into the display controller's history registers
display.epd2.setBusyCallback(NULL);
// we'll need a partial refresh after that (whatever crc value is)
last_display_crc_value = 0;
_partial_refresh_count = 0;
@@ -239,7 +245,10 @@ void GxEPDDisplay::endFrame() {
if (_isOn == false) return;
uint32_t crc = display_crc.finalize();
if (crc != last_display_crc_value) {
// keep the rest of the firmware running while the panel refreshes (~0.5s partial)
if (_busy_hook) display.epd2.setBusyCallback(busyCallback, this);
display.display(true);
display.epd2.setBusyCallback(NULL);
_partial_refresh_count++;
}
last_display_crc_value = crc;