netcode
This commit is contained in:
parent
763db5f983
commit
1e8208b1e8
1 changed files with 56 additions and 48 deletions
|
|
@ -58,6 +58,19 @@ fn panic( info: &PanicInfo) -> ! {
|
|||
loop { }
|
||||
}
|
||||
|
||||
fn run_motor(pwm_c: &mut pwm::Config, pwm: &mut Pwm, pulse: u16) {
|
||||
pwm_c.compare_b = pulse;
|
||||
pwm.set_config(&pwm_c);
|
||||
}
|
||||
|
||||
async fn open_door(mut pwm_c: &mut pwm::Config, mut pwm: &mut Pwm<'_>) {
|
||||
run_motor(&mut pwm_c, &mut pwm, 0x13DF); // up
|
||||
Timer::after_millis(3000).await;
|
||||
run_motor(&mut pwm_c, &mut pwm, 0x123C); // down
|
||||
Timer::after_millis(750).await;
|
||||
run_motor(&mut pwm_c, &mut pwm, 4687); // stop
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
|
||||
|
|
@ -172,6 +185,14 @@ async fn main(spawner: Spawner) {
|
|||
info!("power {pwr:?}");
|
||||
pwm.set_config(&c);
|
||||
},
|
||||
'B' => {
|
||||
let mut buf: [u8;8] = [0;8];
|
||||
buf.copy_from_slice(segs.next().unwrap());
|
||||
let card = u64::from_ne_bytes(buf);
|
||||
info!("card {card:#16x}");
|
||||
|
||||
open_door(&mut c, &mut pwm).await;
|
||||
},
|
||||
_ => {}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue