diff --git a/itsybitsy_m0_lights/src/lib.rs b/itsybitsy_m0_lights/src/lib.rs index 8f9bccc..ccf9365 100644 --- a/itsybitsy_m0_lights/src/lib.rs +++ b/itsybitsy_m0_lights/src/lib.rs @@ -12,6 +12,7 @@ use atsamd21g18a::{ Peripherals }; use core::u8; +use core::fmt::Debug; pub use embedded_hal::digital::v2::OutputPin; use hal::{ clock::GenericClockController, @@ -53,14 +54,19 @@ pub struct NeopixelLights<T: OutputPin, U: OutputPin, V: OutputPin> { pub red_led: V } -impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> { +impl<T: OutputPin, U: OutputPin, V: OutputPin> NeopixelLights<T, U, V> +where + T::Error: Debug, + U::Error: Debug, + V::Error: Debug, +{ #[inline] - fn write(&mut self, bit: bool) { - self.out.set_high().ok(); - self.high_out.set_high().ok(); + pub fn write(&mut self, bit: bool) { + self.out.set_high().unwrap(); + self.high_out.set_high().unwrap(); delay(if bit { ONE_HIGH_CYCLES } else { ZERO_HIGH_CYCLES }); - self.out.set_low().ok(); - self.high_out.set_low().ok(); + self.out.set_low().unwrap(); + self.high_out.set_low().unwrap(); delay(if bit { ONE_LOW_CYCLES } else { ZERO_LOW_CYCLES }); } @@ -77,7 +83,12 @@ impl<T: OutputPin, U: OutputPin> NeopixelLights<T, U> { } } -impl<T: OutputPin, U: OutputPin> Lights for NeopixelLights<T, U> { +impl<T: OutputPin, U: OutputPin, V: OutputPin> Lights for NeopixelLights<T, U, V> +where + T::Error: Debug, + U::Error: Debug, + V::Error: Debug, +{ type Pixel = HardwareRgb; #[inline] @@ -87,6 +98,7 @@ impl<T: OutputPin, U: OutputPin> Lights for NeopixelLights<T, U> { self.byte(rgb.0); self.byte(rgb.2); } + #[inline] fn latch(&mut self) { delay(LATCH_CYCLES); }