platform: remove Peripherals param from board trait
This commit is contained in:
parent
59c3307c27
commit
0884c704b0
16
src/main.rs
16
src/main.rs
@ -9,26 +9,14 @@ mod animations;
|
|||||||
mod mappings;
|
mod mappings;
|
||||||
mod buffers;
|
mod buffers;
|
||||||
|
|
||||||
use esp_idf_svc::hal::prelude::Peripherals;
|
use crate::platform::{DefaultBoard, Board};
|
||||||
|
|
||||||
use crate::platform::Board;
|
|
||||||
use crate::task::{Task, Scheduler};
|
use crate::task::{Task, Scheduler};
|
||||||
use crate::render::{Surfaces, Renderer};
|
use crate::render::{Surfaces, Renderer};
|
||||||
use crate::geometry::Rectangle;
|
use crate::geometry::Rectangle;
|
||||||
|
|
||||||
use crate::platform::esp32::Esp32Board as BoardType;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
let mut board: DefaultBoard = Board::take();
|
||||||
// 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));
|
log::info!("Board: {}", core::any::type_name_of_val(&board));
|
||||||
|
|
||||||
let output = board.output();
|
let output = board.output();
|
||||||
|
@ -41,8 +41,15 @@ impl<'a> Board for Esp32Board<'a> {
|
|||||||
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'a>>;
|
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'a>>;
|
||||||
type Surfaces = SurfacePool<SurfaceType>;
|
type Surfaces = SurfacePool<SurfaceType>;
|
||||||
|
|
||||||
fn new(peripherals: Peripherals) -> Self {
|
fn take() -> Self {
|
||||||
|
// 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 sys_loop = EspSystemEventLoop::take().unwrap();
|
let sys_loop = EspSystemEventLoop::take().unwrap();
|
||||||
let nvs = EspDefaultNvsPartition::take().unwrap();
|
let nvs = EspDefaultNvsPartition::take().unwrap();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ pub mod smart_leds_lib;
|
|||||||
|
|
||||||
pub mod esp32;
|
pub mod esp32;
|
||||||
|
|
||||||
use esp_idf_svc::hal::prelude::Peripherals;
|
pub type DefaultBoard = esp32::Esp32Board;
|
||||||
|
|
||||||
use crate::render::{Output, Surfaces};
|
use crate::render::{Output, Surfaces};
|
||||||
use crate::task::Task;
|
use crate::task::Task;
|
||||||
@ -15,7 +15,7 @@ pub trait Board {
|
|||||||
type Output: Output;
|
type Output: Output;
|
||||||
type Surfaces: Surfaces;
|
type Surfaces: Surfaces;
|
||||||
|
|
||||||
fn new(peripherals: Peripherals) -> Self;
|
fn take() -> Self;
|
||||||
fn output(&mut self) -> Self::Output;
|
fn output(&mut self) -> Self::Output;
|
||||||
fn surfaces(&mut self) -> Self::Surfaces;
|
fn surfaces(&mut self) -> Self::Surfaces;
|
||||||
fn system_tasks(&mut self) -> Vec<Box<dyn Task>>;
|
fn system_tasks(&mut self) -> Vec<Box<dyn Task>>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user