Commit Graph

349 Commits (632a4b65b660503482285d071be5448cc54f6741)
 

Author SHA1 Message Date
bezineb5 632a4b65b6 Added i2c address in name 4 years ago
bezineb5 b5aa6ad709
Merge branch 'main' into reset-tlv493d 4 years ago
bezineb5 fe30e70bf2 improved log message 4 years ago
bezineb5 43cd79527c
tlv493d: Auto-reset TLV493D on error (#52) 4 years ago
bezineb5 283ca5488d Added logging 4 years ago
Weston Schmidt a6bfa877b6
tca95xx: Add support for i/o extenders. (#51) 4 years ago
bezineb5 bfe10a0892 Handling error 4 years ago
bezineb5 b7b2464396 Make gosec happy 4 years ago
bezineb5 a71f1305ed Auto-reset TLV493D on error 4 years ago
Matt Hazley 600c8cc85c
Added a new set of Opts for the waveshare 2in13 rev2.1 - needed a different LUT (#49)
Co-authored-by: Matthew Hazley <Matthew.Hazley@dyson.com>
4 years ago
Florian Klink 05bab7ef1f
nrzled.NewSPI: also add padding in the front (#48)
Some SPI devices take a while to set up for transfer, and while doing
so, show the first bit they're about to send.

This causes the first LED to always interpret the first symbol as a
logical 1. Zapping out the whole strip will leave the first LED green,
and the first pixel will always be slightly green-ish.

Prevent this, by applying the same 3 bit padding we have at the end to
the front.

Signed-off-by: Florian Klink <flokli@flokli.de>
4 years ago
Marc-Antoine Ruel 4dd649e46c github actions: remove golint
It's been deprecated since 2020. Good bye
4 years ago
Marc-Antoine Ruel 0fff63390d github actions: fix actions/setup-go@v3
I was misusing semver, using ^ where I wanted ~
4 years ago
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 394037d235 waveshare2in13v2: Simplify memory area configuration
Use Go's built-in "encoding/binary" package to encode the memory area
size and re-use the encoded positions for setting the counters.
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 0e5a5b501f image1bit: Fix typos 4 years ago
Falk Scheerschmidt f6271cf4a4 add sgp30 air quality sensor 4 years ago
Michael Hanselmann 36e39aaecb waveshare2in13v2: Clarify documentation on controller
Additional research provided information confirming that Waveshare
2.13in v2 displays are in fact GDEH0213B72, not GDEH0213B73, or at least
equivalent.
4 years ago
Michael Hanselmann 8f521b945e videosink: Implement rate-limiting, keep-alive
Resolve the remaining two TODOs by adding an upper limit on the frame
rate (defaults to 15 per second) and sending an image every once in
a while even when there were no changes (defaults to once a minute).

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 1b1970bf7c waveshare2in13v2: Use drawing functionality for clearing
With the introduction of the shadow buffer in commit 4f99575 there's
always a sufficiently large memory buffer to keep the bytes to send for
clearing and the dedicated code using a smaller buffer is no longer
needed. This also has the advantage of automatically updating both
on-device buffers.
4 years ago
Michael Hanselmann 8a5bc2a87c waveshare2in13v2: Test updates to both buffers
Move the logic applying display content changes to both buffers to the
"drawImage" function.
4 years ago
Michael Hanselmann df5238c598 waveshare2in13v2: Enable hardware early
Enable the clock and analog parts when configuring the mode. In probably
all use cases a drawing operation is following soon after anyway.
Putting the device to sleep disables these hardware parts again.
4 years ago
Michael Hanselmann 40f2bd16d7 waveshare2in13v2: Add function to put controller to sleep 4 years ago
Michael Hanselmann 52b148df45 waveshare2in13v2: Document command 0x37 and always apply it
The datasheets of the comparable SSD1680, SSD1675B and GDEH0213B73
controllers describe this command as "Write register for display
option".

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 3650bc73a2 waveshare213v2: Add named constants for display update flags 4 years ago
Michael Hanselmann 0c6b49f898 waveshare213v2: Implement flicker-free partial updates
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>
4 years ago
Michael Hanselmann be539b05ff waveshare213v2: Move display update to testable function
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 648f44a621 waveshare213v2: Allow changing update mode without re-initialization
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>
4 years ago
Michael Hanselmann 85bed23e58 waveshare213v2: Unify initialization, separate mode config
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>
4 years ago
Michael Hanselmann 4f995754b0 waveshare213v2: Keep display contents in shadow buffer
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>
4 years ago
Michael Hanselmann 6052af94b0 waveshare213v2: Move initialization to testable functions 4 years ago
Michael Hanselmann 347b4e237c waveshare213v2: Make busy a PinIn, use WaitForEdge
The busy pin from the e-paper display is only used to read, not to
write, and thus there's no need for the PinIO interface. PinIn is
enough.

In addition the WaitForEdge function can be used to shorten the delays
when waiting for the display to become idle. Spurious or missed edges
are acceptable: the delay isn't very long.
4 years ago
Michael Hanselmann 5179e40adf waveshare213v2: Use color for clearing
This is an API-breaking change, albeit a simple one: Previously the
Dev.Clear function received a byte named "color". It was sent directly
to the display, thus acting more like a pattern to fill the display
with. In practice only 0 and 255 are likely to be used.

With this change the function is changed to receive a value of type
color.Color which is then converted to image1bit.Bit before filling the
display. The latter is also given a unittest.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann ee4a6e4f2e waveshare213v2: Use correct row size for clearing
Commit ecc1eed contained a typo: the rows of data sent for clearing the
display were sized for the height instead of the width.
4 years ago
Michael Hanselmann e7981104ad waveshare2in13v2: Amend documentation with note on GDEH0213B73 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
Michael Hanselmann abc5f2f9c2 waveshare213v2: Move code waiting for idle state to error handler
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann b25f6410ea 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 969dc07218 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 670331bb80 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 749694fcdb waveshare213v2: Separate functions for full and partial mode init
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
4 years ago
Michael Hanselmann 49c84dc6bb waveshare213v2: Avoid allocating for every row when drawing
Reuse the slice instead.
4 years ago
Marc-Antoine Ruel 9b7814b7f9 Update dependencies 4 years ago
Marc-Antoine Ruel 1a02735f94 go generate: replacement go get with go generate 4 years ago
Marc-Antoine Ruel 4d03e3f68b github actions: update go get to go install for go1.17 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