Closed nilscript closed 4 years ago
Interesting, this means that the rppal::spi is fallible on PIN operations.
There's a constraint on the SPI connector that says PinError: core::convert::From<SPI::Error>
A solution would be to implement this conversion problem is that's not possible outside rppal or the max driver itself due to orphan rules. I'll have to think more about how this can get resolved.
Normaly a generic solution would be to do something like
impl<E> From<E> for PinError {
fn from(_: E) -> PinError {
PinError
}
}
However this is already present in core
and it conflicts. Which means that for some readon From<rppi::SPI::Error>
does not get implemented for PinError
using that core conversion
I also tried the exact same solution but its as you say. Core conflicts.
Could you try latest master now please? I'm a bit busy today to do proper re-testing of everything but I think it should work. Note: the version is bumped to 0.3.0
so you'll need to workspace this.
I've used .map_err(|_| DataError)
and expanded the PinError into a DataError
enum so while the main error is lost you still know if it was a PIN error or an SPI one now.
If this works for you I'll try and test tomorrow and do a release.
We were really on the same wave length today. I also though about just mapping the error. It is compiling now. Lets see if the clock can write something.
Also thanks for the quick help :)
This works for me. Display is working fine. Hope it works for other systems as well.
Released v0.3.0
Im trying to write a digital clock using a raspberry pi and found this library. I can't get it to work though as the error types from this library and rppal does not implement the same trait. I am unsure if the scope of this library is to support raspberry pi or rppal directly but it's worth asking.
The compile error:
main.rs:
Cargo.toml:
I am unsure of where a potential solution can be implemented as this lib is a no-std lib. Could be that a solution should exist in the rppal library instead.