aboutsummaryrefslogtreecommitdiff
path: root/src/buttons.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/buttons.cpp')
-rw-r--r--src/buttons.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/buttons.cpp b/src/buttons.cpp
new file mode 100644
index 0000000..27ce40b
--- /dev/null
+++ b/src/buttons.cpp
@@ -0,0 +1,20 @@
+#include "buttons.h"
+#include <Arduino.h>
+#include "config.h"
+
+void buttonsInit()
+{
+ pinMode(BTN_UP, INPUT_PULLUP);
+ pinMode(BTN_DOWN, INPUT_PULLUP);
+ pinMode(BTN_SELECT, INPUT_PULLUP);
+ pinMode(BTN_BACK, INPUT_PULLUP);
+ pinMode(BTN_RIGHT, INPUT_PULLUP);
+ pinMode(BTN_LEFT, INPUT_PULLUP);
+}
+
+bool btnUp() { return !digitalRead(BTN_UP); }
+bool btnDown() { return !digitalRead(BTN_DOWN); }
+bool btnSelect() { return !digitalRead(BTN_SELECT); }
+bool btnBack() { return !digitalRead(BTN_BACK); }
+bool btnRight() { return !digitalRead(BTN_RIGHT); }
+bool btnLeft() { return !digitalRead(BTN_LEFT); }