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
includes/BtnHandler.hpp@1:e1c5259b7d9a, 2017-04-10 (annotated)
- Committer:
- Ismael Balafrej
- Date:
- Mon Apr 10 15:02:24 2017 -0400
- Revision:
- 1:e1c5259b7d9a
V1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ismael Balafrej |
1:e1c5259b7d9a | 1 | #pragma once |
Ismael Balafrej |
1:e1c5259b7d9a | 2 | #include "ports.hpp" |
Ismael Balafrej |
1:e1c5259b7d9a | 3 | #include "PinDetect.h" |
Ismael Balafrej |
1:e1c5259b7d9a | 4 | #include "ServerData.hpp" |
Ismael Balafrej |
1:e1c5259b7d9a | 5 | #include "serverEvents.hpp" |
Ismael Balafrej |
1:e1c5259b7d9a | 6 | |
Ismael Balafrej |
1:e1c5259b7d9a | 7 | class BtnHandler { |
Ismael Balafrej |
1:e1c5259b7d9a | 8 | PinDetect _interrupt; |
Ismael Balafrej |
1:e1c5259b7d9a | 9 | ServerEvent event; |
Ismael Balafrej |
1:e1c5259b7d9a | 10 | public: |
Ismael Balafrej |
1:e1c5259b7d9a | 11 | BtnHandler(PinName pin, const char *eventName) : _interrupt(pin) { |
Ismael Balafrej |
1:e1c5259b7d9a | 12 | strcpy(event.event, eventName); |
Ismael Balafrej |
1:e1c5259b7d9a | 13 | _interrupt.mode( PullDown ); |
Ismael Balafrej |
1:e1c5259b7d9a | 14 | _interrupt.setSampleFrequency(); |
Ismael Balafrej |
1:e1c5259b7d9a | 15 | _interrupt.attach_asserted(this, &BtnHandler::sendEvent); |
Ismael Balafrej |
1:e1c5259b7d9a | 16 | } |
Ismael Balafrej |
1:e1c5259b7d9a | 17 | BtnHandler(PinName pin, const char *eventName, const char *direction) : BtnHandler(pin, eventName) { |
Ismael Balafrej |
1:e1c5259b7d9a | 18 | strcpy(event.data.direction, direction); |
Ismael Balafrej |
1:e1c5259b7d9a | 19 | } |
Ismael Balafrej |
1:e1c5259b7d9a | 20 | void sendEvent() |
Ismael Balafrej |
1:e1c5259b7d9a | 21 | { |
Ismael Balafrej |
1:e1c5259b7d9a | 22 | websocket_message_send(event); |
Ismael Balafrej |
1:e1c5259b7d9a | 23 | } |
Ismael Balafrej |
1:e1c5259b7d9a | 24 | }; |