Closed ColinTimBarndt closed 2 weeks ago
Solves #50
Another important (possibly breaking) change that I added is that get_position
no longer panics. It was already returning a Result
, though it was only using the Ok
variant and panics otherwise. There's an Error::Position
now for this purpose.
Is there a reason to not implement the trait core::error::Error
?
Is there a reason to not implement the trait
core::error::Error
?
Thanks for pointing that out, that was an oversight.
I've added error handling to all IO operations (especially I2C). My motivation is that this would have saved my hours of debugging because I though that communication with my display was successful. I was unaware that the driver ignored any errors. My implementation propagates those errors to the user, which can then decide what to do with them (or keep ignoring).
I have only tested this on blocking I2C so far. I am very confident that this would work everywhere else, though I'd prefer to first test it on my display. Sadly, mine can only do I2C, though the other implementations didn't change much.
I'd be happy about any feedback on this. Especially because this PR has some breaking changes due to generics that have been added to the Error struct and many functions. Also, all pins must have the same error type with this implementation. It is technically possible to drop this requirement, but it would make the generics on Error explode.
Example
Here's an example stack trace when unwrapping an Err result caused by me unplugging the CLK jumper. Previously, the program wouldn't have been able to notice this error as it would have been ignored and dropped by the driver.