diff --git a/src/control/imaging.rs b/src/control/imaging.rs index 6e796be..ece94a6 100644 --- a/src/control/imaging.rs +++ b/src/control/imaging.rs @@ -1,8 +1,9 @@ use std::{path::Path, time::Duration}; use crate::{ + actuators, error::GenericResult, - io, + io::{self, RelaySwitchState}, state::{lock_state, ProgramStateShared}, }; @@ -18,7 +19,18 @@ pub async fn save_latest_image(program_state: ProgramStateShared) -> GenericResu .clone() }) .unwrap_or(io::ImageResolution::R360p); + + let light_state: RelaySwitchState; + { + let mut program_state = lock_state(&program_state)?; + light_state = actuators::get_light_state(&mut program_state)?; + actuators::switch_lights(RelaySwitchState::On, &mut program_state)?; + } io::capture_image(&resolution, get_image_path()).await?; + { + let mut program_state = lock_state(&program_state)?; + actuators::switch_lights(light_state, &mut program_state)?; + } Ok(()) }