Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NerfUSXbee PinDetect EthernetInterface JSON MFRC522 WebSocketClient mbed-rtos mbed
Diff: includes/BtnHandler.hpp
- Revision:
- 1:e1c5259b7d9a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/includes/BtnHandler.hpp Mon Apr 10 15:02:24 2017 -0400
@@ -0,0 +1,24 @@
+#pragma once
+#include "ports.hpp"
+#include "PinDetect.h"
+#include "ServerData.hpp"
+#include "serverEvents.hpp"
+
+class BtnHandler {
+ PinDetect _interrupt;
+ ServerEvent event;
+ public:
+ BtnHandler(PinName pin, const char *eventName) : _interrupt(pin) {
+ strcpy(event.event, eventName);
+ _interrupt.mode( PullDown );
+ _interrupt.setSampleFrequency();
+ _interrupt.attach_asserted(this, &BtnHandler::sendEvent);
+ }
+ BtnHandler(PinName pin, const char *eventName, const char *direction) : BtnHandler(pin, eventName) {
+ strcpy(event.data.direction, direction);
+ }
+ void sendEvent()
+ {
+ websocket_message_send(event);
+ }
+};
\ No newline at end of file