ui: split out safety ui into its own dedicated set of layers
This commit is contained in:
@@ -11,6 +11,7 @@ use core::ptr::addr_of_mut;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Instant, Timer};
|
||||
|
||||
use esp_hal::{gpio::{Output, OutputConfig}, peripherals, time::Rate};
|
||||
#[allow(unused_imports)]
|
||||
use esp_hal::{
|
||||
clock::CpuClock, interrupt::software::SoftwareInterruptControl, system::{AppCoreGuard, CpuControl, Stack}, timer::{systimer::SystemTimer, timg::{TimerGroup, Wdt}},
|
||||
@@ -19,7 +20,7 @@ use esp_hal::{
|
||||
|
||||
use esp_hal_embassy::{Executor, InterruptExecutor};
|
||||
use log::*;
|
||||
use renderbug_embassy::{logging::RenderbugLogger, tasks::ui::UiSurfacePool};
|
||||
use renderbug_embassy::{logging::RenderbugLogger, tasks::{safetyui::{safety_ui_main, SafetyUi}, ui::UiSurfacePool}};
|
||||
use renderbug_embassy::events::BusGarage;
|
||||
use static_cell::StaticCell;
|
||||
use esp_backtrace as _;
|
||||
@@ -45,7 +46,6 @@ static CORE_HANDLE: StaticCell<AppCoreGuard> = StaticCell::new();
|
||||
async fn main(spawner: Spawner) {
|
||||
critical_section::with(|_| {
|
||||
RenderbugLogger::init_logger();
|
||||
//esp_println::logger::init_logger_from_env();
|
||||
});
|
||||
|
||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||
@@ -62,13 +62,15 @@ async fn main(spawner: Spawner) {
|
||||
let timer1 = TimerGroup::new(peripherals.TIMG1);
|
||||
let mut ui_wdt = timer1.wdt;
|
||||
ui_wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(10));
|
||||
//ui_wdt.enable(); //FIXME: Re-enable UI watchdog once we have a brain task running
|
||||
ui_wdt.enable(); //FIXME: Re-enable UI watchdog once we have a brain task running
|
||||
|
||||
let garage = BUS_GARAGE.init(Default::default());
|
||||
|
||||
info!("Setting up rendering pipeline");
|
||||
let mut surfaces = UiSurfacePool::default();
|
||||
let ui = Ui::new(&mut surfaces, garage.display.clone());
|
||||
let ui = Ui::new(&mut surfaces);
|
||||
let mut safety_surfaces = UiSurfacePool::default();
|
||||
let safety_ui = SafetyUi::new(&mut safety_surfaces, garage.display.clone());
|
||||
|
||||
let mut wdt = timer0.wdt;
|
||||
wdt.set_timeout(esp_hal::timer::timg::MwdtStage::Stage0, esp_hal::time::Duration::from_secs(3));
|
||||
@@ -80,7 +82,7 @@ async fn main(spawner: Spawner) {
|
||||
#[cfg(not(feature="headless"))]
|
||||
{
|
||||
wdt.enable();
|
||||
hi_spawn.must_spawn(renderbug_embassy::tasks::render::render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, garage.display.clone(), wdt));
|
||||
hi_spawn.must_spawn(renderbug_embassy::tasks::render::render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, safety_surfaces, garage.display.clone(), wdt));
|
||||
}
|
||||
#[cfg(feature="headless")]
|
||||
garage.display.notify_render_is_running(true);
|
||||
@@ -104,6 +106,26 @@ async fn main(spawner: Spawner) {
|
||||
spawner.must_spawn(renderbug_embassy::tasks::gps::gps_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
}
|
||||
|
||||
#[cfg(feature="oled")]
|
||||
{
|
||||
use esp_hal::i2c::master::{Config, I2c};
|
||||
|
||||
let mut rst = Output::new(peripherals.GPIO21, esp_hal::gpio::Level::Low, OutputConfig::default());
|
||||
Timer::after_millis(10).await;
|
||||
rst.set_high();
|
||||
Timer::after_millis(10).await;
|
||||
rst.set_low();
|
||||
Timer::after_millis(10).await;
|
||||
rst.set_high();
|
||||
|
||||
let i2c = I2c::new(
|
||||
peripherals.I2C0,
|
||||
Config::default().with_frequency(Rate::from_khz(400))
|
||||
).unwrap().with_scl(peripherals.GPIO18).with_sda(peripherals.GPIO17).into_async();
|
||||
|
||||
spawner.must_spawn(renderbug_embassy::tasks::oled::oled_task(i2c, garage.telemetry.dyn_subscriber().unwrap()));
|
||||
}
|
||||
|
||||
#[cfg(feature="simulation")]
|
||||
{
|
||||
spawner.must_spawn(renderbug_embassy::tasks::simulation::motion_simulation_task(garage.motion.dyn_sender()));
|
||||
@@ -111,7 +133,7 @@ async fn main(spawner: Spawner) {
|
||||
}
|
||||
|
||||
info!("Launching motion engine");
|
||||
spawner.must_spawn(motion_task(garage.motion.dyn_receiver(), garage.notify.dyn_sender(), garage.predict.dyn_sender()));
|
||||
spawner.must_spawn(motion_task(garage.motion.dyn_receiver(), garage.notify.dyn_publisher().unwrap(), garage.predict.dyn_sender()));
|
||||
|
||||
info!("Starting core 2");
|
||||
let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL);
|
||||
@@ -122,19 +144,21 @@ async fn main(spawner: Spawner) {
|
||||
#[cfg(feature="radio")]
|
||||
{
|
||||
info!("Launching wifi");
|
||||
spawner.must_spawn(renderbug_embassy::tasks::wifi::wireless_task(garage.notify.dyn_receiver(), timer0.timer0.into(), peripherals.RNG, peripherals.WIFI, peripherals.BT));
|
||||
//spawner.must_spawn(renderbug_embassy::tasks::wifi::wireless_task(garage.notify.dyn_receiver().unwrap(), timer0.timer0.into(), peripherals.RNG, peripherals.WIFI, peripherals.BT));
|
||||
}
|
||||
info!("Launching Safety UI");
|
||||
spawner.must_spawn(safety_ui_main(garage.notify.dyn_subscriber().unwrap(), safety_ui));
|
||||
info!("Launching UI");
|
||||
spawner.must_spawn(ui_main(garage.notify.dyn_receiver(), ui));
|
||||
spawner.must_spawn(ui_main(garage.notify.dyn_subscriber().unwrap(), garage.telemetry.dyn_publisher().unwrap(), ui));
|
||||
#[cfg(feature="demo")]
|
||||
{
|
||||
warn!("Launching with demo sequencer");
|
||||
spawner.must_spawn(renderbug_embassy::tasks::demo::demo_task(garage.notify.dyn_sender()));
|
||||
spawner.must_spawn(renderbug_embassy::tasks::demo::demo_task(garage.notify.dyn_publisher().unwrap()));
|
||||
}
|
||||
#[cfg(not(feature="demo"))]
|
||||
{
|
||||
info!("Launching prediction engine");
|
||||
spawner.must_spawn(renderbug_embassy::tasks::predict::prediction_task(garage.predict.dyn_receiver(), garage.notify.dyn_sender()));
|
||||
spawner.must_spawn(renderbug_embassy::tasks::predict::prediction_task(garage.predict.dyn_receiver(), garage.notify.dyn_publisher().unwrap(), garage.telemetry.dyn_publisher().unwrap()));
|
||||
}
|
||||
info!("Launching core 2 watchdog");
|
||||
spawner.must_spawn(wdt_task(ui_wdt));
|
||||
|
||||
Reference in New Issue
Block a user