Browse Source

turn on lights when taking image

main
Nareshkumar Rao 7 months ago
parent
commit
3d05fffd72
  1. 14
      src/control/imaging.rs

14
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(())
}

Loading…
Cancel
Save