render: remove getters from Surface, reimplement buffer sharing with Send+Sync
This commit is contained in:
@ -18,30 +18,25 @@ use rgb::Rgb;
|
||||
|
||||
use super::Board;
|
||||
|
||||
use crate::buffers::BufferedSurfacePool;
|
||||
use crate::task::FixedSizeScheduler;
|
||||
use crate::task::Task;
|
||||
use crate::buffers::{Pixbuf, SurfacePool};
|
||||
use crate::buffers::Pixbuf;
|
||||
use crate::mappings::StrideMapping;
|
||||
use crate::platform::smart_leds_lib::StrideOutput;
|
||||
use crate::platform::smart_leds_lib::rmt::FastWs2812Esp32Rmt;
|
||||
use crate::time::Periodically;
|
||||
|
||||
#[cfg(feature="threads")]
|
||||
use crate::buffers::SharedSurface as SurfaceType;
|
||||
|
||||
#[cfg(not(feature="threads"))]
|
||||
use crate::buffers::SimpleSurface as SurfaceType;
|
||||
|
||||
pub struct Esp32Board<'a> {
|
||||
pub struct Esp32Board {
|
||||
output: Option<<Self as Board>::Output>,
|
||||
surfaces: Option<SurfacePool<SurfaceType>>,
|
||||
sys_loop: EspSystemEventLoop,
|
||||
modem: Option<Modem>,
|
||||
surfaces: BufferedSurfacePool
|
||||
}
|
||||
|
||||
impl<'a> Board for Esp32Board<'a> {
|
||||
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'a>>;
|
||||
type Surfaces = SurfacePool<SurfaceType>;
|
||||
impl Board for Esp32Board {
|
||||
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'static>>;
|
||||
type Surfaces = BufferedSurfacePool;
|
||||
type Scheduler = FixedSizeScheduler<2>;
|
||||
|
||||
fn take() -> Self {
|
||||
@ -88,10 +83,10 @@ impl<'a> Board for Esp32Board<'a> {
|
||||
);
|
||||
|
||||
Esp32Board {
|
||||
surfaces: Some(SurfacePool::new()),
|
||||
output: Some(output),
|
||||
modem: Some(peripherals.modem),
|
||||
sys_loop: sys_loop.clone(),
|
||||
surfaces: BufferedSurfacePool::new()
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,13 +95,14 @@ impl<'a> Board for Esp32Board<'a> {
|
||||
}
|
||||
|
||||
fn surfaces(&mut self) -> Self::Surfaces {
|
||||
self.surfaces.take().unwrap()
|
||||
self.surfaces.clone()
|
||||
}
|
||||
|
||||
fn system_tasks(&mut self) -> Self::Scheduler {
|
||||
let nvs = EspDefaultNvsPartition::take().unwrap();
|
||||
FixedSizeScheduler::new([
|
||||
Box::new(WifiTask::new(self.modem.take().unwrap(), self.sys_loop.clone(), &nvs)),
|
||||
Box::new(self.surfaces.clone())
|
||||
])
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user