summaryrefslogtreecommitdiff
path: root/ButtonHandler/ButtonHandler.h
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2015-11-12 12:20:30 -0600
committerMike Fiore <mfiore@multitech.com>2015-11-12 12:20:30 -0600
commitf0f9fc2601dc3421aa3f4d9747748c3bee93f703 (patch)
tree3d884e151729be7fec59af504cb4dfadf31276ac /ButtonHandler/ButtonHandler.h
parent0bc27ddeae03930deb6106144b49e0614fe002da (diff)
downloadmtdot-box-evb-factory-firmware-f0f9fc2601dc3421aa3f4d9747748c3bee93f703.tar.gz
mtdot-box-evb-factory-firmware-f0f9fc2601dc3421aa3f4d9747748c3bee93f703.tar.bz2
mtdot-box-evb-factory-firmware-f0f9fc2601dc3421aa3f4d9747748c3bee93f703.zip
add class for handling button events - signals main thread when event occurs and main thread can check event - supports SW1 press, SW2 press, and SW1 hold
Diffstat (limited to 'ButtonHandler/ButtonHandler.h')
-rw-r--r--ButtonHandler/ButtonHandler.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/ButtonHandler/ButtonHandler.h b/ButtonHandler/ButtonHandler.h
new file mode 100644
index 0000000..3eb8298
--- /dev/null
+++ b/ButtonHandler/ButtonHandler.h
@@ -0,0 +1,36 @@
+#ifndef __BUTTONHANDLER_H__
+#define __BUTTONHANDLER_H__
+
+#include "mbed.h"
+#include "rtos.h"
+
+#define buttonSignal (uint32_t)0x01
+
+typedef enum {
+ none = 0,
+ sw1_press,
+ sw1_hold,
+ sw2_press
+} ButtonEvent;
+
+class ButtonHandler {
+ public:
+ ButtonHandler(osThreadId main);
+ ~ButtonHandler();
+
+ ButtonEvent getButtonEvent();
+
+ private:
+ void sw1_fall();
+ void sw1_rise();
+ void sw2_fall();
+
+ osThreadId _main;
+ InterruptIn _sw1;
+ InterruptIn _sw2;
+ Timer _sw1_timer;
+ time_t _sw1_time;
+ ButtonEvent _event;
+};
+
+#endif