added weapon enable flag
This commit is contained in:
parent
70d4e551b4
commit
57522c26cc
2 changed files with 12 additions and 5 deletions
|
@ -360,6 +360,6 @@ fn handle_cam(cam: &mut Pwm, state: &mut CamState, limit: &Input) {
|
||||||
let mut f: pwm::Config = Default::default();
|
let mut f: pwm::Config = Default::default();
|
||||||
f.divider = 40.into();
|
f.divider = 40.into();
|
||||||
f.top = 62500; // 20ms
|
f.top = 62500; // 20ms
|
||||||
f.compare_b = calc_speed(speed); // 1.5ms
|
f.compare_b = calc_speed(-speed); // 1.5ms
|
||||||
cam.set_config(&f);
|
cam.set_config(&f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<()> {
|
fn sax_control(control: &mut ControlPacket, vol: f32, note: &pitch_detection::Pitch<f32>) -> ControlFlow<()> {
|
||||||
if note.frequency < 150. {
|
if note.frequency < 150. {
|
||||||
println!("too low");
|
println!("too low");
|
||||||
|
@ -142,8 +145,10 @@ fn sax_control(control: &mut ControlPacket, vol: f32, note: &pitch_detection::Pi
|
||||||
*control = ControlPacket::Twist(0.0, -1.0);
|
*control = ControlPacket::Twist(0.0, -1.0);
|
||||||
}
|
}
|
||||||
Pitch { letter: NoteLetter::G, accidental: 1} => {
|
Pitch { letter: NoteLetter::G, accidental: 1} => {
|
||||||
println!("fire");
|
if ARMED {
|
||||||
*control = ControlPacket::Fire;
|
println!("fire");
|
||||||
|
*control = ControlPacket::Fire;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Pitch { letter: NoteLetter::F, accidental: 1} => {
|
Pitch { letter: NoteLetter::F, accidental: 1} => {
|
||||||
println!("stop flat");
|
println!("stop flat");
|
||||||
|
@ -193,8 +198,10 @@ fn recorder_control(control: &mut ControlPacket, vol: f32, note: pitch_detection
|
||||||
*control = ControlPacket::Twist(0.0, -1.0);
|
*control = ControlPacket::Twist(0.0, -1.0);
|
||||||
}
|
}
|
||||||
Pitch { letter: NoteLetter::G, accidental: 0|1} => {
|
Pitch { letter: NoteLetter::G, accidental: 0|1} => {
|
||||||
println!("fire");
|
if ARMED {
|
||||||
*control = ControlPacket::Fire;
|
println!("fire");
|
||||||
|
*control = ControlPacket::Fire;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Pitch { letter: NoteLetter::F, accidental: 1} => {
|
Pitch { letter: NoteLetter::F, accidental: 1} => {
|
||||||
println!("stop flat");
|
println!("stop flat");
|
||||||
|
|
Loading…
Reference in a new issue