Commit Graph

15 Commits (fae68919b97bca287d32a46b7eaeed589a3344ee)

Author SHA1 Message Date
Michael Hanselmann fae68919b9 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
Michael Hanselmann 1ade23a46c waveshare213v2: Move code waiting for idle state to error handler
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann f34f11aa5b waveshare213v2: Move command and data sending code into error handler
This code isn't used directly and there's no need to keep the additional
complexity.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann fdb05081b1 waveshare213v2: Move error handler to separate file
The structure definition and the functions were already split up. Moving
to a separate file simplifies the code structure.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann c1f05896d4 waveshare213v2: Use error handler while clearing
Use the shared code for collecting errors.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 54fdcd8593 waveshare213v2: Separate functions for full and partial mode init
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 980b365d2d waveshare213v2: Avoid allocating for every row when drawing
Reuse the slice instead.
4 years ago
Michael Hanselmann 455934ac1d waveshare213v2: Always configure all aspects of RAM area
Set the start/end positions as well as the number of bytes to write by
computing them from an `image.Rectangle`. This is a preparatory step for
implementing partial image updates.

Also change the data entry mode setting to 0x03, the value applied at
power-on reset. It's not actually used given the way memory updates are
written (one large block instead of chunks).

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 414c28d5c6 waveshare213v2: Avoid using a slice for commands
All commands consist of a single byte and there's no need to use
a slice.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann c38b40a52a waveshare213v2: Document more values
Introduce named constants where possible (based on the data sheet) and
compute values instead of using hardcoded ones.

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
hansmi d09d487465
Remove dependencies on fogleman/gg and golang/freetype (#28)
The waveshare2in13v2 example was evidently copied from the epd example,
but didn't comment out the code pulling in additional dependencies.
5 years ago
hansmi d92a4ed45d
waveshare2in13v2: Add constants, add missing init to example (#25)
Avoid using strconv.Itoa
fmt.Sprintf() can format numbers directly using the "%d" format
specifier.

Call Dev.Init in example code
Without initializing the hardware nothing is shown on the display.

Add constants for commands
Translate the command names from the datasheet into constant names,
similar to `epd/epd.go`. These names make it easier to understand what
the driver does.

One command, 0x37, is not documented in any of the datasheets available
(Waveshare 2.13inch e-Paper, Good Display GDEH0213B72).

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
5 years ago
Dan Kortschak 960e8d343b
waveshare2in13v2: add example (#8) 5 years ago
Sönke Brightside 296894bc24
Separate waveshare2in13v2 driver (#2)
Adds support for EPD2in13v2
5 years ago