Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E-Ink "Dynamic Partial" #3193

Merged
merged 2 commits into from
Feb 11, 2024
Merged

Conversation

todd-herbert
Copy link
Contributor

The other issue to include in discussion is the need for a full update to be includes after so many partial updates - e-ink displays are not meant to be partially updates for ever.

#3075 (comment)

What it is

Selects between full refresh, partial refresh, and skipped updates, balancing urgency and display health. Non-intrusive, disabled by default. Implementable for individual boards.

How to implement it

For individual boards

1. Configure in variant.h

#define USE_EINK
#define USE_EINK_DYNAMIC_PARTIAL
#define EINK_LOWPRIORITY_LIMIT_SECONDS 30
#define EINK_HIGHPRIORITY_LIMIT_SECONDS 1
#define EINK_PARTIAL_REPEAT_LIMIT 5
  • EINK_LOWPRIORITY_LIMIT_SECONDS: interval between "low priority" updates
  • EINK_HIGHPRIORITY_LIMIT_SECONDS: min. interval between "high priority" updates
  • EINK_PARTIAL_REPEAT_LIMIT: max. consecutive partial refreshes, before a full refresh is forced

2. Adjust configForPartialRefresh() and configForFullRefresh(), if necessary

These methods are used internally to execute any code required to switch the display between partial and full refresh configurations. The should work out-of-the-box, but any "display specific" code can go here.

In GFX code

Graphics code should suggest that an update is either "high priority" or "low priority". This is considered by the Dynamic Partial code, when determining whether to use partial or full refresh.

  • EInkDisplay::highPriority() - subsequent updates are important: show ASAP
  • EInkDisplay::lowPriority() - no rush with these ones

For the EInkDisplay class as it currently exists, this pull request has already implemented the required changes.
This is hooked into the existing update display() and forceDisplay() methods:

  • updates called via display() are considered low priority - receives one per loop() (?)
  • updates called via forceDisplay() are considered high priority

What does it change?

The main selection process is handled by this block, in EInkDisplay::forceDisplay()

#if defined(USE_EINK_DYNAMIC_PARTIAL)
    // Decide if update is partial or full
    bool continueUpdate = determineRefreshMode();
    if (!continueUpdate)
        return false; // Abort forceDisplay()
#else

For the most part, the changes are additions, selected by the preprocessor. One exception is the minor refactoring of the "rate-limiting" code in forceDisplay():

if (adafruitDisplay && (sinceLast > msecLimit || lastDrawMsec == 0)) {

Structure has changed from:

if (condition_met)
  doStuff();

to:

if (!condition_met)
  return;

doStuff();

What will I notice?

Probably, nothing. This pull request only enables Dynamic Partial mode for HELTEC_WIRELESS_PAPER_V1_0. Ideally, there should be no impact on other boards.

The hope is that devs will test Dynamic Partial mode on their own hardware, and if the result is good, implement it for the relevant boards; even if only as an interim measure, pending a rewrite of the EInkDisplay class I had seen mentioned in passing.

How is the refresh mode selected?

I will admit, the logic is slightly convoluted. I do believe though that the resulting behavior feels intuitive.

A rough outline:

flowchart of dynamic partial modes' selection logic

Use a mixture of full refresh, partial refresh, and skipped updates, balancing urgency and display health.
@todd-herbert todd-herbert marked this pull request as ready for review February 10, 2024 11:15
thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 10, 2024
@thebentern thebentern requested a review from markbirss February 10, 2024 14:00
@markbirss
Copy link
Contributor

@todd-herbert nice to see the display working without line at the bottom like the RAK14000

@thebentern sent me a v1 board and i already flashed your wip tree, just wish it had a i2c port.

@thebentern
Copy link
Contributor

Great work. This is a good approach that we can slowly test out on other eink boards.

thebentern added a commit to meshtastic/artifacts that referenced this pull request Feb 11, 2024
@thebentern thebentern merged commit 36cf9b9 into meshtastic:master Feb 11, 2024
66 checks passed
GUVWAF pushed a commit to GUVWAF/Meshtastic-device that referenced this pull request Feb 11, 2024
Use a mixture of full refresh, partial refresh, and skipped updates, balancing urgency and display health.

Co-authored-by: Ben Meadors <[email protected]>
@todd-herbert todd-herbert deleted the dynamic-partial branch February 11, 2024 16:58
mverch67 pushed a commit that referenced this pull request Feb 12, 2024
Use a mixture of full refresh, partial refresh, and skipped updates, balancing urgency and display health.

Co-authored-by: Ben Meadors <[email protected]>
thebentern added a commit that referenced this pull request Feb 14, 2024
* StoreForward updates
- Send history in "text" variant
- Don't send history the client already got
- Check if PSRAM is full
- More sensible defaults

* Set `TEXT_BROADCAST` or `TEXT_DIRECT` RequestResponse tag

* feat: E-Ink "Dynamic Partial" (#3193)

Use a mixture of full refresh, partial refresh, and skipped updates, balancing urgency and display health.

Co-authored-by: Ben Meadors <[email protected]>

* [create-pull-request] automated change (#3209)

Co-authored-by: thebentern <[email protected]>

* Reset `last_index` if history was cleared, e.g. by reboot

---------

Co-authored-by: Ben Meadors <[email protected]>
Co-authored-by: todd-herbert <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: thebentern <[email protected]>
Co-authored-by: Garth Vander Houwen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants