From 3d05fffd72f5864f00b70271496d31cfb16f0cbe Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao Date: Tue, 7 May 2024 23:38:38 +0200 Subject: [PATCH] turn on lights when taking image --- src/control/imaging.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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(()) }