use unwraps() to match idiomatic code (probably optimizes out?)
This commit is contained in:
parent
88236f5966
commit
59ff9aa7fd
1 changed files with 19 additions and 7 deletions
|
@ -12,6 +12,7 @@ use atsamd21g18a::{
|
||||||
Peripherals
|
Peripherals
|
||||||
};
|
};
|
||||||
use core::u8;
|
use core::u8;
|
||||||
|
use core::fmt::Debug;
|
||||||
pub use embedded_hal::digital::v2::OutputPin;
|
pub use embedded_hal::digital::v2::OutputPin;
|
||||||
use hal::{
|
use hal::{
|
||||||
clock::GenericClockController,
|
clock::GenericClockController,
|
||||||
|
@ -53,14 +54,19 @@ pub struct NeopixelLights<T: OutputPin, U: OutputPin, V: OutputPin> {
|
||||||
pub red_led: V
|
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]
|
#[inline]
|
||||||
fn write(&mut self, bit: bool) {
|
pub fn write(&mut self, bit: bool) {
|
||||||
self.out.set_high().ok();
|
self.out.set_high().unwrap();
|
||||||
self.high_out.set_high().ok();
|
self.high_out.set_high().unwrap();
|
||||||
delay(if bit { ONE_HIGH_CYCLES } else { ZERO_HIGH_CYCLES });
|
delay(if bit { ONE_HIGH_CYCLES } else { ZERO_HIGH_CYCLES });
|
||||||
self.out.set_low().ok();
|
self.out.set_low().unwrap();
|
||||||
self.high_out.set_low().ok();
|
self.high_out.set_low().unwrap();
|
||||||
delay(if bit { ONE_LOW_CYCLES } else { ZERO_LOW_CYCLES });
|
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;
|
type Pixel = HardwareRgb;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -87,6 +98,7 @@ impl<T: OutputPin, U: OutputPin> Lights for NeopixelLights<T, U> {
|
||||||
self.byte(rgb.0);
|
self.byte(rgb.0);
|
||||||
self.byte(rgb.2);
|
self.byte(rgb.2);
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
fn latch(&mut self) {
|
fn latch(&mut self) {
|
||||||
delay(LATCH_CYCLES);
|
delay(LATCH_CYCLES);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue