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};
#[allow(unused_imports)] use log::{debug, error, info, trace};
use rppal::gpio::{Gpio, Level, Trigger};
use rppal::gpio::{Gpio, Trigger};
use smallvec::SmallVec;
use tokio::{ sync::mpsc,
time::{delay_for, interval} };
@@ -33,7 +33,7 @@ async fn main() {
let gpio = Gpio::new().expect("gpio init");
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");
let reqwest = &reqwest::Client::new();
@@ -57,8 +57,7 @@ async fn main() {
}
}
fn button_pressed(_level: Level,
clients: &Arc<Mutex<SmallVec<[mpsc::Sender<()>; CHANNEL_VEC_SIZE]>>>) {
fn button_pressed(clients: &Arc<Mutex<SmallVec<[mpsc::Sender<()>; CHANNEL_VEC_SIZE]>>>) {
info!("DOORBELL PRESS");
clients.lock().unwrap().retain(|tx: &mut mpsc::Sender<()>| {
match tx.try_send(()) {