Implement button status report
This commit is contained in:
parent
b2094de8d0
commit
b27e2cf18f
1 changed files with 10 additions and 0 deletions
|
@ -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 };
|
||||||
|
|
Loading…
Reference in a new issue