@@ -948,24 +948,25 @@ pub trait PwmPin {
948
948
/// };
949
949
///
950
950
///
951
- /// let before = qei.count ();
951
+ /// let before = qei.try_count().unwrap ();
952
952
/// timer.start(1.s());
953
953
/// block!(timer.wait());
954
- /// let after = qei.count ();
954
+ /// let after = qei.try_count().unwrap ();
955
955
///
956
956
/// let speed = after.wrapping_sub(before);
957
957
/// println!("Speed: {} pulses per second", speed);
958
958
/// }
959
959
///
960
- /// # use std ::convert::Infallible;
960
+ /// # use core ::convert::Infallible;
961
961
/// # struct Seconds(u32);
962
962
/// # trait U32Ext { fn s(self) -> Seconds; }
963
963
/// # impl U32Ext for u32 { fn s(self) -> Seconds { Seconds(self) } }
964
964
/// # struct Qei1;
965
965
/// # impl hal::Qei for Qei1 {
966
+ /// # type Error = Infallible;
966
967
/// # type Count = u16;
967
- /// # fn count (&self) -> u16 { 0 }
968
- /// # fn direction (&self) -> ::hal::Direction { unimplemented!() }
968
+ /// # fn try_count (&self) -> Result< u16, Self::Error> { 0 }
969
+ /// # fn try_direction (&self) -> Result< ::hal::Direction, Self::Error> { unimplemented!() }
969
970
/// # }
970
971
/// # struct Timer6;
971
972
/// # impl hal::timer::CountDown for Timer6 {
@@ -978,14 +979,17 @@ pub trait PwmPin {
978
979
// reason: needs to be re-evaluated in the new singletons world. At the very least this needs a
979
980
// reference implementation
980
981
pub trait Qei {
982
+ /// Enumeration of `Qei` errors
983
+ type Error ;
984
+
981
985
/// The type of the value returned by `count`
982
986
type Count ;
983
987
984
988
/// Returns the current pulse count of the encoder
985
- fn count ( & self ) -> Self :: Count ;
989
+ fn try_count ( & self ) -> Result < Self :: Count , Self :: Error > ;
986
990
987
991
/// Returns the count direction
988
- fn direction ( & self ) -> Direction ;
992
+ fn try_direction ( & self ) -> Result < Direction , Self :: Error > ;
989
993
}
990
994
991
995
/// Count direction
0 commit comments