From 8c77d9d084d1558715e32986d04ddce49295288e Mon Sep 17 00:00:00 2001 From: gferraro Date: Wed, 16 Oct 2024 14:58:47 +0200 Subject: [PATCH] remove unneeded method --- src/attiny_rtc_i2c.rs | 11 +++++------ src/core0_audio.rs | 27 +++++++++++---------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/attiny_rtc_i2c.rs b/src/attiny_rtc_i2c.rs index 9b0e378..2e4f75f 100644 --- a/src/attiny_rtc_i2c.rs +++ b/src/attiny_rtc_i2c.rs @@ -74,10 +74,13 @@ impl From for CameraState { } #[repr(u8)] +#[derive(Format)] + pub enum RecordingType { TestRecording = 0, LongRecording = 1, ScheduledRecording = 2, + ThermalRequestedScheduledRecording = 3, } #[repr(u8)] @@ -500,6 +503,8 @@ impl SharedI2C { == tc2_agent_state::LONG_AUDIO_RECORDING { return Ok(Some(RecordingType::LongRecording)); + } else if state & tc2_agent_state::TAKE_AUDIO == tc2_agent_state::TAKE_AUDIO { + return Ok(Some(RecordingType::ThermalRequestedScheduledRecording)); } } Ok(None) @@ -568,12 +573,6 @@ impl SharedI2C { self.tc2_agent_write_flag(delay, tc2_agent_state::THERMAL_MODE, false) } - pub fn tc2_agent_requested_audio_rec(&mut self, delay: &mut Delay) -> Result { - match self.try_attiny_read_command(REG_TC2_AGENT_STATE, delay, None) { - Ok(state) => Ok((state & tc2_agent_state::TAKE_AUDIO) == tc2_agent_state::TAKE_AUDIO), - Err(e) => Err(e), - } - } pub fn tc2_agent_take_audio_rec(&mut self, delay: &mut Delay) -> Result<(), Error> { self.tc2_agent_write_flag(delay, tc2_agent_state::TAKE_AUDIO, true) } diff --git a/src/core0_audio.rs b/src/core0_audio.rs index 785d160..64969dd 100644 --- a/src/core0_audio.rs +++ b/src/core0_audio.rs @@ -171,7 +171,8 @@ pub fn audio_task( let mut duration = 60; let mut recording_type = None; - let mut recording_requested = false; + let mut user_recording_requested = false; + let mut thermal_requested_audio = false; if alarm_triggered { recording_type = Some(RecordingType::ScheduledRecording); } else { @@ -182,11 +183,15 @@ pub fn audio_task( match rec_type { RecordingType::LongRecording => { duration = 60 * 5; - recording_requested = true; + user_recording_requested = true; } RecordingType::TestRecording => { duration = 10; - recording_requested = true; + user_recording_requested = true; + } + RecordingType::ThermalRequestedScheduledRecording => { + duration = 60; + thermal_requested_audio = true; } _ => {} } @@ -194,7 +199,6 @@ pub fn audio_task( } } - let mut thermal_requested_audio = false; let mut reschedule = false; let mut alarm_date_time: Option = None; @@ -224,9 +228,10 @@ pub fn audio_task( ); } - if !recording_requested { + if !user_recording_requested { if device_config_was_updated { let reboot; + if device_config.config().is_audio_device() && !thermal_requested_audio { if let AudioMode::AudioOnly = device_config.config().audio_mode { reboot = false; @@ -369,18 +374,9 @@ pub fn audio_task( } } - if let Ok(take_rec) = shared_i2c.tc2_agent_requested_audio_rec(&mut delay) { - thermal_requested_audio = take_rec; - if thermal_requested_audio { - recording_type = Some(RecordingType::ScheduledRecording); - } - } else { - thermal_requested_audio = false; - } - info!( "Alarm triggered {} scheduled {} thermal requested {}", - alarm_triggered, scheduled, thermal_requested_audio + alarm_triggered, scheduled, recording_type ); if recording_type.is_none() && scheduled { @@ -516,7 +512,6 @@ pub fn audio_task( shared_i2c.clear_alarm(&mut delay); reschedule = true; clear_audio_alarm(&mut flash_storage); - if thermal_requested_audio { //if audio requested from thermal, the alarm will be re scheduled there let _ = shared_i2c.tc2_agent_clear_and_set_flag(