Commit Graph

5 Commits (v3.7.4)

Author SHA1 Message Date
hansmi 0012149b5d
waveshare2in13v2: Support rotation of image (#46)
* waveshare2in13v2: Populate bounds only once

The forthcoming introduction of image orientation will make the
computation slightly more complicated. The bounds are fixed during the
lifetime of a "Dev" instance, so it's better to retain them.

* waveshare2in13v2: Make sending image part of drawOpts

* waveshare2in13v2: Unexport drawSpec members

The members of the "drawSpec" structure are only for internal use, so
rename them to start with a lower-case letter.

* waveshare2in13v2: Implement support for rotating image

A new option named "Origin" controls which of the four corners of the
display should be used as the (0,0) position for the image. The
in-memory buffer is kept in logical orientation. The actual rotation
happens only when sending updates.

By aligning the buffer accordingly the code is already prepared for
a more efficient sending of image data for the "TopRight" and
"BottomLeft" origins. See the TODO comment on "drawSpec.BufferDstOffset"
for details.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 0349dabcd3 waveshare2in13v2: List width first in String() result
The convention is to write dimensions with the width first.
4 years ago
Michael Hanselmann 59e1d3f851 waveshare2in13v2: Add test for New()
Ensure the internal buffer has the correct size and a few other
properties are correct.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann ecc1eed386 waveshare213v2: Add support for partial drawing
When the destination rectangle didn't start at (0,0) or cover the whole
display the Dev.Draw function would continue to update the display in
full. Obviously that didn't result in a good output.

This change updates the drawing logic to only update the affected area
(aligned to whole bytes on the horizontal axis) and limits the amount of
transferred data to the minimum needed to cover the destination
rectangle.

The calculation of the various offsets as well as the function sending
the image data are written to support unittesting.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
hansmi 5b35a3fb05
waveshare2in13v2: Deduplicate and simplify logic for sending data (#33)
Dev.Clear: Avoid writing one beyond the end of the line. Also build the
row data only once before sending it for each line.

Dev.Draw, Dev.DrawPartial: Deduplicate logic for iterating over pixels
and simplify it such that a whole row of bits is built before sending
them in one go.

Tested using a Waveshare e-Paper 2.13in V2 display.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago