mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 01:52:48 +00:00
fix fallback behavior for unmodified GxEPD2
Issues exposed by https://github.com/meshtastic/firmware/pull/3356#issuecomment-1986950317
This commit is contained in:
parent
dfbb4cd913
commit
3daae24d29
@ -96,18 +96,45 @@ bool EInkDynamicDisplay::update()
|
|||||||
{
|
{
|
||||||
// Detemine the refresh mode to use, and start the update
|
// Detemine the refresh mode to use, and start the update
|
||||||
bool refreshApproved = determineMode();
|
bool refreshApproved = determineMode();
|
||||||
if (refreshApproved)
|
if (refreshApproved) {
|
||||||
EInkDisplay::forceDisplay(0); // Bypass base class' own rate-limiting system
|
EInkDisplay::forceDisplay(0); // Bypass base class' own rate-limiting system
|
||||||
|
storeAndReset(); // Store the result of this loop for next time. Note: call *before* endOrDetach()
|
||||||
|
endOrDetach(); // endUpdate() right now, or set the async refresh flag (if FULL and HAS_EINK_ASYNC)
|
||||||
|
} else
|
||||||
|
storeAndReset(); // No update, no post-update code, just store the results
|
||||||
|
|
||||||
#if defined(HAS_EINK_ASYNCFULL)
|
|
||||||
if (refreshApproved)
|
|
||||||
endOrDetach(); // Either endUpdate() right now (fast refresh), or set the async flag (full refresh)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
storeAndReset(); // Store the result of this loop for next time
|
|
||||||
return refreshApproved; // (Unutilized) Base class promises to return true if update ran
|
return refreshApproved; // (Unutilized) Base class promises to return true if update ran
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Figure out who runs the post-update code
|
||||||
|
void EInkDynamicDisplay::endOrDetach()
|
||||||
|
{
|
||||||
|
// If the GxEPD2 version reports that it has the async modifications
|
||||||
|
#ifdef HAS_EINK_ASYNCFULL
|
||||||
|
if (previousRefresh == FULL) {
|
||||||
|
asyncRefreshRunning = true; // Set the flag - picked up at start of determineMode(), next loop.
|
||||||
|
|
||||||
|
if (previousFrameFlags & BLOCKING)
|
||||||
|
awaitRefresh();
|
||||||
|
else
|
||||||
|
LOG_DEBUG("Async full-refresh begins\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fast Refresh
|
||||||
|
else if (previousRefresh == FAST)
|
||||||
|
EInkDisplay::endUpdate(); // Still block while updating, but EInkDisplay needs us to call endUpdate() ourselves.
|
||||||
|
|
||||||
|
// Fallback - If using an unmodified version of GxEPD2 for some reason
|
||||||
|
#else
|
||||||
|
if (previousRefresh == FULL || previousRefresh == FAST) { // If refresh wasn't skipped (on unspecified..)
|
||||||
|
LOG_WARN(
|
||||||
|
"GxEPD2 version has not been modified to support async refresh; using fallback behavior. Please update lib_deps in "
|
||||||
|
"variant's platformio.ini file\n");
|
||||||
|
EInkDisplay::endUpdate();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Assess situation, pick a refresh type
|
// Assess situation, pick a refresh type
|
||||||
bool EInkDynamicDisplay::determineMode()
|
bool EInkDynamicDisplay::determineMode()
|
||||||
{
|
{
|
||||||
@ -456,23 +483,6 @@ void EInkDynamicDisplay::checkAsyncFullRefresh()
|
|||||||
// It is only equipped to intercept calls to nextPage()
|
// It is only equipped to intercept calls to nextPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out who runs the post-update code
|
|
||||||
void EInkDynamicDisplay::endOrDetach()
|
|
||||||
{
|
|
||||||
if (refresh == FULL) {
|
|
||||||
asyncRefreshRunning = true; // Set the flag - picked up at start of determineMode(), next loop.
|
|
||||||
|
|
||||||
if (frameFlags & BLOCKING)
|
|
||||||
awaitRefresh();
|
|
||||||
else
|
|
||||||
LOG_DEBUG("Async full-refresh begins\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fast Refresh
|
|
||||||
else
|
|
||||||
EInkDisplay::endUpdate(); // Still block while updating, but EInkDisplay needs us to call endUpdate() ourselves.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hold control while an async refresh runs
|
// Hold control while an async refresh runs
|
||||||
void EInkDynamicDisplay::awaitRefresh()
|
void EInkDynamicDisplay::awaitRefresh()
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,7 @@ class EInkDynamicDisplay : public EInkDisplay
|
|||||||
void applyRefreshMode(); // Run any relevant GxEPD2 code, so next update will use correct refresh type
|
void applyRefreshMode(); // Run any relevant GxEPD2 code, so next update will use correct refresh type
|
||||||
void adjustRefreshCounters(); // Update fastRefreshCount
|
void adjustRefreshCounters(); // Update fastRefreshCount
|
||||||
bool update(); // Trigger the display update - determine mode, then call base class
|
bool update(); // Trigger the display update - determine mode, then call base class
|
||||||
|
void endOrDetach(); // Run the post-update code, or delegate it off to checkAsyncFullRefresh()
|
||||||
|
|
||||||
// Checks as part of determineMode()
|
// Checks as part of determineMode()
|
||||||
void checkInitialized(); // Is this the very first frame?
|
void checkInitialized(); // Is this the very first frame?
|
||||||
@ -112,7 +113,6 @@ class EInkDynamicDisplay : public EInkDisplay
|
|||||||
// Conditional - async full refresh - only with modified meshtastic/GxEPD2
|
// Conditional - async full refresh - only with modified meshtastic/GxEPD2
|
||||||
#if defined(HAS_EINK_ASYNCFULL)
|
#if defined(HAS_EINK_ASYNCFULL)
|
||||||
void checkAsyncFullRefresh(); // Check the status of "async full-refresh"; run the post-update code if the hardware is ready
|
void checkAsyncFullRefresh(); // Check the status of "async full-refresh"; run the post-update code if the hardware is ready
|
||||||
void endOrDetach(); // Run the post-update code, or delegate it off to checkAsyncFullRefresh()
|
|
||||||
void awaitRefresh(); // Hold control while an async refresh runs
|
void awaitRefresh(); // Hold control while an async refresh runs
|
||||||
void endUpdate() override {} // Disable base-class behavior of running post-update immediately after forceDisplay()
|
void endUpdate() override {} // Disable base-class behavior of running post-update immediately after forceDisplay()
|
||||||
bool asyncRefreshRunning = false; // Flag, checked by checkAsyncFullRefresh()
|
bool asyncRefreshRunning = false; // Flag, checked by checkAsyncFullRefresh()
|
||||||
|
Loading…
Reference in New Issue
Block a user