41 lines
970 B
Rust
41 lines
970 B
Rust
#![no_std]
|
|
|
|
use lights::HardwareRgb;
|
|
use lights::gamma::correct;
|
|
use lights::Lights;
|
|
use lights::PixelIterator;
|
|
use lights::rgb::Rgb;
|
|
|
|
const PORCH_BACK_LEN: usize = 150;
|
|
const PORCH_FRONT_LEN: usize = 150;
|
|
|
|
|
|
pub struct Harrogate<PB, PF> {
|
|
pub porch_back: PB,
|
|
pub porch_front: PF,
|
|
}
|
|
|
|
impl<PB, PF> Harrogate<PB, PF>
|
|
where
|
|
PB: IntoIterator<Item = Rgb>,
|
|
PF: IntoIterator<Item = Rgb>,
|
|
{
|
|
pub fn render_to<L: Lights<Pixel = HardwareRgb>>(self, lights: &mut L) {
|
|
let mut buffer = [HardwareRgb(255,0,255); PORCH_BACK_LEN + PORCH_FRONT_LEN];
|
|
|
|
for (i, pixel) in self.porch_back.into_iter().take(PORCH_BACK_LEN).enumerate() {
|
|
buffer[PORCH_BACK_LEN - i] = correct(&pixel);
|
|
}
|
|
for (i, pixel) in self.porch_front.into_iter().take(PORCH_FRONT_LEN).enumerate() {
|
|
buffer[PORCH_BACK_LEN + i] = correct(&pixel);
|
|
}
|
|
|
|
buffer.iter().render_to(lights);
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
// #[test]
|
|
}
|