mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Included running flag in struct.
This commit is contained in:
@@ -159,14 +159,14 @@ pub async fn set_green_led_handler(_context: &mut Context, _header: VarHeader, r
|
||||
LED_FREQUENCY_SIGNAL.signal(rqst);
|
||||
}
|
||||
|
||||
static RUNNING: Mutex<ThreadModeRawMutex, bool> = Mutex::new(false);
|
||||
static STOP: Mutex<ThreadModeRawMutex, bool> = Mutex::new(false);
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn start_single_impedance_handler(context: SpawnCtx, header: VarHeader, rqst: StartImpedance, sender: Sender<AppTx>) {
|
||||
info!("Start impedance measurement at {:?} Hz.", rqst.sinus_frequency);
|
||||
|
||||
*RUNNING.lock().await = true;
|
||||
// Mark the impedance setup as running
|
||||
context.impedance_setup.lock().await.running = true;
|
||||
|
||||
// Init the sequencer
|
||||
context.impedance_setup.lock().await.init_single_frequency_measurement(rqst.sinus_frequency).await;
|
||||
@@ -198,14 +198,14 @@ pub async fn start_single_impedance_handler(context: SpawnCtx, header: VarHeader
|
||||
seq = seq.wrapping_add(1);
|
||||
}
|
||||
|
||||
*RUNNING.lock().await = false;
|
||||
context.impedance_setup.lock().await.running = false;
|
||||
info!("Impedance measurement stopped.");
|
||||
*STOP.lock().await = false;
|
||||
}
|
||||
|
||||
pub async fn stop_single_impedance_handler(_context: &mut Context, _header: VarHeader, _rqst: ()) -> bool {
|
||||
pub async fn stop_single_impedance_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> bool {
|
||||
info!("Stop impedance measurement");
|
||||
let was_busy = *RUNNING.lock().await;
|
||||
let was_busy = context.impedance_setup.lock().await.running;
|
||||
if was_busy {
|
||||
*STOP.lock().await = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user