buffers: split out concrete surface and pixbuf implementations into a buffers module
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
use smart_leds_trait::SmartLedsWrite;
|
||||
|
||||
use crate::lib8::Rgb8Blend;
|
||||
use crate::render::{Surface, SurfacePool, Display, Surfaces};
|
||||
use crate::render::{Framed, Surface, Display, Surfaces};
|
||||
use crate::buffers::SurfacePool;
|
||||
use crate::power::{brightness_for_mw, AsMilliwatts};
|
||||
use crate::geometry::*;
|
||||
use crate::mappings::*;
|
||||
@ -96,20 +97,8 @@ T: SmartLedsWrite,
|
||||
S: Surface,
|
||||
T::Color: HardwarePixel,
|
||||
[T::Color; PIXEL_NUM]: Pixbuf<T::Color>,
|
||||
Rgb<u8>: From<T::Color> {
|
||||
|
||||
fn start_frame(&mut self) {
|
||||
self.pixbuf.blank();
|
||||
}
|
||||
|
||||
fn end_frame(&mut self) {
|
||||
let b = brightness_for_mw(self.pixbuf.as_milliwatts(), 255, self.max_mw);
|
||||
if let Err(_) = self.target.write(brightness(self.pixbuf.iter().cloned().map(|x| { x.into() }), b)) {
|
||||
//if let Err(_) = self.target.write(self.pixbuf.iter().cloned()) {
|
||||
panic!("Could not write frame");
|
||||
}
|
||||
}
|
||||
|
||||
Rgb<u8>: From<T::Color>
|
||||
{
|
||||
fn render_frame(&mut self) {
|
||||
let surfaces = self.surfaces.take().unwrap();
|
||||
for surface in surfaces.iter() {
|
||||
@ -129,6 +118,25 @@ Rgb<u8>: From<T::Color> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, const PIXEL_NUM: usize> Framed for SmartLedDisplay<T, S, PIXEL_NUM> where
|
||||
T: SmartLedsWrite,
|
||||
S: Surface,
|
||||
T::Color: HardwarePixel,
|
||||
[T::Color; PIXEL_NUM]: Pixbuf<T::Color>,
|
||||
Rgb<u8>: From<T::Color> {
|
||||
|
||||
fn start_frame(&mut self) {
|
||||
self.pixbuf.blank();
|
||||
}
|
||||
|
||||
fn end_frame(&mut self) {
|
||||
let b = brightness_for_mw(self.pixbuf.as_milliwatts(), 255, self.max_mw);
|
||||
if let Err(_) = self.target.write(brightness(self.pixbuf.iter().cloned().map(|x| { x.into() }), b)) {
|
||||
panic!("Could not write frame");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature="rmt")]
|
||||
pub mod rmt {
|
||||
use esp_idf_svc::hal::prelude::Peripherals;
|
||||
|
Reference in New Issue
Block a user