epd-waveshare
epd-waveshare copied to clipboard
Proposal(s): support for display timeouts, introducing a local Error type
I have an embedded device that may or may not have an EPD display connected. When the device is initialized without a display attached (but is not configured as such), the initialization routine hangs indefinitely waiting for the device to get 'idle'. Also this can happen when the display module is defective or not properly connected. As a faulty/not connected display is not a total failure in our use case, I would like to gracefully handle such cases.
For this I would like to introduce a timeout to the typical wait_until_idle
functions (e.g. introduce wait_until_idle_with_timeout
or have the timeout by default).
What makes this hard to do this properly, is that across the epd-waveshare library SPI::Error
is used as the general error type, but now we also need to support errors like e.g. Timeout
or DisplayNotFound
. So the proposal here is to move away from using the external generic SPI::Error
in this library and instead use a predefined local epd_waveshare::Error
type or possibly an associated type to the WaveshareDisplay
Trait.
I'm interested in your opinion on this!
Sounds like a great idea!
For the error issue: The new eh-1.0 spi makes this easier since we can use https://docs.rs/embedded-hal/1.0.0-rc.1/embedded_hal/spi/enum.ErrorKind.html now.