use embassy_stm32::gpio::{AnyPin, Level, Output, Speed};
use embassy_stm32::Peri;
pub const COUNT: usize = 11;
pub struct Leds {
out: [Output<'static>; COUNT],
}
impl Leds {
pub fn new(pins: [Peri<'static, AnyPin>; COUNT]) -> Self {
Self {
out: pins.map(|p| Output::new(p, Level::Low, Speed::Low)),
}
}
pub fn set(&mut self, i: usize, on: bool) {
if on {
self.out[i].set_high();
} else {
self.out[i].set_low();
}
}
pub fn only(&mut self, i: usize) {
for (n, led) in self.out.iter_mut().enumerate() {
if n == i {
led.set_high();
} else {
led.set_low();
}
}
}
pub const fn count(&self) -> usize {
COUNT
}
}