use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
use static_cell::StaticCell;
use motor_mixers::{MotorMixerMessage, MotorMixerOutput, MotorMixerQuadXPwm};
pub(crate) static MOTOR_MIXER_CTX: StaticCell<MotorMixerContext> = StaticCell::new();
pub static MOTOR_MIXER_SIGNAL: Signal<CriticalSectionRawMutex, MotorMixerMessage> = Signal::new();
pub struct MotorMixerContext {
pub motor_mixer: MotorMixerQuadXPwm,
}
#[embassy_executor::task]
pub async fn motor_mixer_task(ctx: &'static mut MotorMixerContext) {
loop {
let motor_mixer_message = MOTOR_MIXER_SIGNAL.wait().await;
ctx.motor_mixer.output_to_motors(motor_mixer_message);
}
}