Implement button status report

This commit is contained in:
Gregor Riepl 2021-05-04 23:50:53 +02:00
parent b2094de8d0
commit b27e2cf18f

View file

@ -9,6 +9,7 @@
#include "button.h" #include "button.h"
static bool report_change = false; static bool report_change = false;
static uint8_t last_buttons = 0;
static void init(); static void init();
static void send_status(); static void send_status();
@ -95,6 +96,7 @@ static void loop();
static void init() { static void init() {
// initialize buttons // initialize buttons
button_init(); button_init();
last_buttons = button_get();
// initialize VFD // initialize VFD
display_init(); display_init();
@ -150,6 +152,14 @@ static void send_status() {
} }
static void loop() { static void loop() {
// Report button state changes first
if (report_change) {
uint8_t current = button_get();
if (current != last_buttons) {
send_status();
last_buttons = current;
}
}
// Check for new messages // Check for new messages
if (can_check_message()) { if (can_check_message()) {
can_t msg = { 0 }; can_t msg = { 0 };