Skip to content

Commit

Permalink
More Rusty way of audio switching knob read
Browse files Browse the repository at this point in the history
  • Loading branch information
juliansebline committed Feb 2, 2025
1 parent eef0e85 commit 80d7afb
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ pub enum AudioSwitchingKnobPosition {
Norm,
Fo,
}
read_write_enum!(AudioSwitchingKnobPosition);
impl From<f64> for AudioSwitchingKnobPosition {
fn from(value: f64) -> Self {
match value as u8 {
0 => Self::Captain,
2 => Self::Fo,
_ => Self::Norm,
}
}
}

pub struct AudioManagementUnit {
adaptation_board: AdaptationBoard,
Expand Down Expand Up @@ -504,13 +514,8 @@ impl SimulationElement for AdaptationBoard {
let ls_fcu1_pressed = reader.read(&self.ls_fcu1_pressed_id);
let ls_fcu2_pressed = reader.read(&self.ls_fcu2_pressed_id);

let audio_switching_knob = match reader.read(&self.audio_switching_knob_id) {
0 => AudioSwitchingKnobPosition::Captain,
2 => AudioSwitchingKnobPosition::Fo,
_ => AudioSwitchingKnobPosition::Norm,
};
self.audio_switching_knob = reader.read(&self.audio_switching_knob_id);

self.audio_switching_knob = audio_switching_knob;
self.ls_fcu1_pressed = ls_fcu1_pressed;
self.ls_fcu2_pressed = ls_fcu2_pressed;
}
Expand Down

0 comments on commit 80d7afb

Please sign in to comment.