From fb6b5bced604ffe2943affcf4e1af4b7bcaad510 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 22 Aug 2022 13:56:43 +0200 Subject: [PATCH] Test for button press every 50ms. That's more than enough. --- include/controller.h | 1 + src/controller.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/controller.h b/include/controller.h index bdf8394..9a054a1 100644 --- a/include/controller.h +++ b/include/controller.h @@ -14,6 +14,7 @@ class Controller { Playlist current_playlist; bool is_rfid_present = false; unsigned long last_rfid_check = 0; + unsigned long last_button_check = 0; uint8_t button_pressed = 0; unsigned long button_pressed_since = 0; bool button_already_processed = false; diff --git a/src/controller.cpp b/src/controller.cpp index 1eab3d7..e491e7f 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -6,7 +6,10 @@ void Controller::handle() { handle_rfid(); last_rfid_check = millis(); } - handle_buttons(); + if (last_button_check + 10 < millis() || last_button_check > millis()) { + handle_buttons(); + last_button_check = millis(); + } } void Controller::handle_buttons() {