#![allow(unused)]
use embassy_time::Duration;
use log::info;
use static_cell::StaticCell;
use crate::{
dispatch::{GyroPidReceiver, SetpointReceiver},
osd::Osd,
};
pub(crate) static OSD_CTX: StaticCell<OsdContext> = StaticCell::new();
pub struct OsdContext {
pub gyro_pid_receiver: GyroPidReceiver,
pub setpoint_receiver: SetpointReceiver,
pub osd: Osd,
}
#[embassy_executor::task]
pub async fn osd_task(ctx: &'static mut OsdContext) {
let mut ticker = embassy_time::Ticker::every(Duration::from_hz(50));
let mut loop_count: u32 = 0;
info!(" OSD: task started");
loop {
ticker.next().await;
let _gyro_pid_message = ctx.gyro_pid_receiver.get().await;
let _setpoint_message = ctx.setpoint_receiver.get().await;
ctx.osd.update_display();
if loop_count.is_multiple_of(10) {
info!(" OSD: loop {loop_count}");
}
loop_count = loop_count.wrapping_add(1); }
}