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

waveshare213v2: Implement partial updates #41

Merged
merged 7 commits into from
Dec 24, 2021
Merged

waveshare213v2: Implement partial updates #41

merged 7 commits into from
Dec 24, 2021

Conversation

hansmi
Copy link
Contributor

@hansmi hansmi commented Dec 23, 2021

This series of changes implements partial, flicker-free update for Waveshare 2.13in v2 displays. Sleep modes and better power management will follow later.

This is necessary for partial updates of the display--not just
incremental updates of the full display, but updating part of the
display in general.

On the horizontal axis only whole bytes can be written, so updates need
to be aligned to 8 pixels. One option would be to require the caller of
Dev.Draw to only operate at multiples of 8. Another would be to read
back the contents of bytes to be updated partially and combine the data.
According to the datasheet the controller supports that (command 0x27).

The simplest option, however, is to maintain a shadow buffer in the
driver. Updates are applied to the buffer from which only the changed
destination rectangle is sent to the display. The permanent cost is
a bit more than 4kB of memory for a 122x250 display while saving on
memory allocations for a temporary image buffer on updates.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Merge the common logic in the "initDisplayFull" and "initDisplayPartial"
functions and separate out the parts related to the display update mode.
In a forthcoming change the update mode will no longer be set when
initializing, but rather via a separate setter function, requiring the
ability to reconfigure the display controller without a full
re-initialization.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
It's perfectly acceptable to update a display in full mode before
switching to partial mode and vice-versa. There's no need for a full
soft-reset in-between.

This change breaks the API: the "Init" function no longer receives
a parameter. The default is to always start in the full update mode.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
Update both image buffers (B/W and red) and configure the controller to
only refresh the changed areas. With this change the "DrawPartial"
function becomes equivalent to "Draw" and is thus marked as deprecated.
It didn't really provide additional functionality before as partial
updates weren't truly implemented.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2021

Codecov Report

Merging #41 (ec4ee88) into main (347b4e2) will increase coverage by 1.1%.
The diff coverage is 68.5%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main     #41     +/-   ##
=======================================
+ Coverage   62.5%   63.6%   +1.1%     
=======================================
  Files         55      56      +1     
  Lines       6723    6727      +4     
=======================================
+ Hits        4200    4279     +79     
+ Misses      2382    2307     -75     
  Partials     141     141             
Impacted Files Coverage Δ
waveshare2in13v2/waveshare213v2.go 0.0% <0.0%> (ø)
waveshare2in13v2/controller.go 100.0% <100.0%> (ø)
waveshare2in13v2/drawing.go 100.0% <100.0%> (ø)
lepton/lepton.go 87.2% <0.0%> (+1.0%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 347b4e2...ec4ee88. Read the comment docs.

@maruel maruel merged commit 3650bc7 into periph:main Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants