renderbug/src/main.rs

68 lines
1.8 KiB
Rust

mod power;
mod lib8;
mod render;
mod task;
mod time;
mod geometry;
mod platform;
mod animations;
mod mappings;
mod buffers;
use buffers::SurfacePool;
use crate::platform::DisplayInit;
use crate::render::Surfaces;
use crate::geometry::Rectangle;
#[cfg(feature="embedded-graphics")]
#[cfg(feature="rmt")]
use crate::platform::embedded_graphics_lib::PonderjarTarget as DisplayType;
#[cfg(feature="smart-leds")]
#[cfg(feature="rmt")]
use crate::platform::smart_leds_lib::rmt::FastWs2812Esp32Rmt as DisplayType;
#[cfg(feature="smart-leds")]
#[cfg(feature="spi")]
use crate::platform::smart_leds_lib::spi::SPIDisplay as DisplayType;
#[cfg(feature="threads")]
use crate::buffers::SharedSurface as SurfaceType;
#[cfg(not(feature="threads"))]
use crate::buffers::SimpleSurface as SurfaceType;
use crate::render::Renderer;
fn main() {
// It is necessary to call this function once. Otherwise some patches to the runtime
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
esp_idf_svc::sys::link_patches();
// Bind the log crate to the ESP Logging facilities
esp_idf_svc::log::EspLogger::initialize_default();
log::info!("Setting up display");
let display = DisplayType::new_display::<SurfaceType>();
let mut surfaces: SurfacePool<SurfaceType> = SurfacePool::new();
log::info!("Created new display type {}", core::any::type_name_of_val(&display));
log::info!("Creating runner");
let mut runner = task::Scheduler::new(vec![
Box::new(animations::IdleTask::new(&mut surfaces)),
Box::new(animations::TestPattern::new(surfaces.new_surface(&Rectangle::everything()).unwrap())),
Box::new(Renderer::new(display, surfaces)),
]);
log::info!("Runner ready: {:?}", runner);
log::info!("Ready to rock and roll");
loop {
runner.tick();
}
}