-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttons.cpp
42 lines (36 loc) · 1017 Bytes
/
buttons.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "buttons.h"
bool BUTTON_FLAG = 0;
Button left_button(LEFT_BUTTON, 50, false, false);
Button right_button(RIGHT_BUTTON, 50, false, false);
Button top_button(TOP_BUTTON, 50, false, false);
Button bottom_button(BOTTOM_BUTTON, 50, false, false);
void buttons_init() {
left_button.begin();
right_button.begin();
top_button.begin();
bottom_button.begin();
}
void buttons_check() {
left_button.read();
right_button.read();
top_button.read();
bottom_button.read();
if (right_button.isPressed()) {
current_signal = RIGHT_CRATE_SIGNAL;
BUTTON_FLAG = 1;
} else if (top_button.isPressed()) {
current_signal = TOP_CRATE_SIGNAL;
BUTTON_FLAG = 1;
} else if (bottom_button.isPressed()) {
current_signal = BOTTOM_CRATE_SIGNAL;
BUTTON_FLAG = 1;
} else if (left_button.isPressed()) {
current_signal = LEFT_CRATE_SIGNAL;
BUTTON_FLAG = 1;
} else {
BUTTON_FLAG = 0;
}
if (BUTTON_FLAG) {
motors_movement();
}
}