1
Fork 0

added weapon enable flag

This commit is contained in:
Andy Killorin 2025-01-19 17:17:29 -05:00
parent 70d4e551b4
commit 57522c26cc
Signed by: ank
GPG key ID: 23F9463ECB67FE8C
2 changed files with 12 additions and 5 deletions

View file

@ -360,6 +360,6 @@ fn handle_cam(cam: &mut Pwm, state: &mut CamState, limit: &Input) {
let mut f: pwm::Config = Default::default();
f.divider = 40.into();
f.top = 62500; // 20ms
f.compare_b = calc_speed(speed); // 1.5ms
f.compare_b = calc_speed(-speed); // 1.5ms
cam.set_config(&f);
}

View file

@ -112,6 +112,9 @@ async fn controller(mut notes: mpsc::Receiver<(Option<pitch_detection::Pitch<f32
}
}
/// Weapon enabled
const ARMED: bool = true;
fn sax_control(control: &mut ControlPacket, vol: f32, note: &pitch_detection::Pitch<f32>) -> ControlFlow<()> {
if note.frequency < 150. {
println!("too low");
@ -142,9 +145,11 @@ fn sax_control(control: &mut ControlPacket, vol: f32, note: &pitch_detection::Pi
*control = ControlPacket::Twist(0.0, -1.0);
}
Pitch { letter: NoteLetter::G, accidental: 1} => {
if ARMED {
println!("fire");
*control = ControlPacket::Fire;
}
}
Pitch { letter: NoteLetter::F, accidental: 1} => {
println!("stop flat");
*control = ControlPacket::Stop;
@ -193,9 +198,11 @@ fn recorder_control(control: &mut ControlPacket, vol: f32, note: pitch_detection
*control = ControlPacket::Twist(0.0, -1.0);
}
Pitch { letter: NoteLetter::G, accidental: 0|1} => {
if ARMED {
println!("fire");
*control = ControlPacket::Fire;
}
}
Pitch { letter: NoteLetter::F, accidental: 1} => {
println!("stop flat");
*control = ControlPacket::Stop;