Skip to content

Commit

Permalink
remove unneeded method
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Oct 16, 2024
1 parent 0f21e7c commit 8c77d9d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
11 changes: 5 additions & 6 deletions src/attiny_rtc_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ impl From<u8> for CameraState {
}

#[repr(u8)]
#[derive(Format)]

pub enum RecordingType {
TestRecording = 0,
LongRecording = 1,
ScheduledRecording = 2,
ThermalRequestedScheduledRecording = 3,
}

#[repr(u8)]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<bool, Error> {
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)
}
Expand Down
27 changes: 11 additions & 16 deletions src/core0_audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -182,19 +183,22 @@ 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;
}
_ => {}
}
}
}
}

let mut thermal_requested_audio = false;
let mut reschedule = false;
let mut alarm_date_time: Option<NaiveDateTime> = None;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8c77d9d

Please sign in to comment.