don't pass along already-ignored pin level to button handler

This commit is contained in:
2020-11-03 09:07:11 -08:00
parent fbb7dea664
commit 4a66223542

View File

@@ -6,7 +6,7 @@ use std::time::Duration;
use futures_util::{FutureExt, select, stream, StreamExt}; use futures_util::{FutureExt, select, stream, StreamExt};
#[allow(unused_imports)] use log::{debug, error, info, trace}; #[allow(unused_imports)] use log::{debug, error, info, trace};
use rppal::gpio::{Gpio, Level, Trigger}; use rppal::gpio::{Gpio, Trigger};
use smallvec::SmallVec; use smallvec::SmallVec;
use tokio::{ sync::mpsc, use tokio::{ sync::mpsc,
time::{delay_for, interval} }; time::{delay_for, interval} };
@@ -33,7 +33,7 @@ async fn main() {
let gpio = Gpio::new().expect("gpio init"); let gpio = Gpio::new().expect("gpio init");
let mut pin = gpio.get(BUTTON_PIN).expect("pin init").into_input_pullup(); let mut pin = gpio.get(BUTTON_PIN).expect("pin init").into_input_pullup();
pin.set_async_interrupt(Trigger::FallingEdge, move |level| button_pressed(level, &clients)) pin.set_async_interrupt(Trigger::FallingEdge, move |_| button_pressed(&clients))
.expect("set interrupt"); .expect("set interrupt");
let reqwest = &reqwest::Client::new(); let reqwest = &reqwest::Client::new();
@@ -57,8 +57,7 @@ async fn main() {
} }
} }
fn button_pressed(_level: Level, fn button_pressed(clients: &Arc<Mutex<SmallVec<[mpsc::Sender<()>; CHANNEL_VEC_SIZE]>>>) {
clients: &Arc<Mutex<SmallVec<[mpsc::Sender<()>; CHANNEL_VEC_SIZE]>>>) {
info!("DOORBELL PRESS"); info!("DOORBELL PRESS");
clients.lock().unwrap().retain(|tx: &mut mpsc::Sender<()>| { clients.lock().unwrap().retain(|tx: &mut mpsc::Sender<()>| {
match tx.try_send(()) { match tx.try_send(()) {