renderbug/src/main.rs

58 lines
1.6 KiB
Rust

mod power;
mod lib8;
mod render;
mod task;
mod time;
mod geometry;
mod platform;
mod animations;
mod mappings;
mod buffers;
use esp_idf_svc::hal::prelude::Peripherals;
use crate::platform::Board;
use crate::task::{Task, Scheduler};
use crate::render::{Surfaces, Renderer};
use crate::geometry::Rectangle;
use crate::platform::esp32::Esp32Board as BoardType;
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();
let peripherals = Peripherals::take().unwrap();
let mut board: BoardType = Board::new(peripherals);
log::info!("Board: {}", core::any::type_name_of_val(&board));
let output = board.output();
log::info!("Output: {}", core::any::type_name_of_val(&output));
let mut surfaces = board.surfaces();
log::info!("Surface implementation: {}", core::any::type_name_of_val(&output));
log::info!("Creating animations");
let mut tasks: Vec<Box<dyn Task + 'static>> = vec![
Box::new(animations::IdleTask::new(&mut surfaces)),
Box::new(animations::TestPattern::new(surfaces.new_surface(&Rectangle::everything()).unwrap())),
];
tasks.append(&mut board.system_tasks());
tasks.push(Box::new(Renderer::new(output, surfaces)));
let mut runner = Scheduler::new(tasks);
log::info!("Runner ready: {:?}", runner);
log::info!("Ready to rock and roll");
loop {
runner.tick();
}
}