Dependencies: XBeeLib mbed HvZAlphaNumLib HvZServerLib
lib/Tag.hpp@0:9cdba0589ba2, 2010-12-12 (annotated)
- Committer:
- etherealflaim
- Date:
- Sun Dec 12 19:35:00 2010 +0000
- Revision:
- 0:9cdba0589ba2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
etherealflaim | 0:9cdba0589ba2 | 1 | #ifndef _TAGCONNECTION |
etherealflaim | 0:9cdba0589ba2 | 2 | #define _TAGCONNECTION |
etherealflaim | 0:9cdba0589ba2 | 3 | |
etherealflaim | 0:9cdba0589ba2 | 4 | #include "mbed.h" |
etherealflaim | 0:9cdba0589ba2 | 5 | #include "iHvZ.hpp" |
etherealflaim | 0:9cdba0589ba2 | 6 | #include "XBee.hpp" |
etherealflaim | 0:9cdba0589ba2 | 7 | |
etherealflaim | 0:9cdba0589ba2 | 8 | /** Connection between devices for the purpose of tagging and stunning |
etherealflaim | 0:9cdba0589ba2 | 9 | */ |
etherealflaim | 0:9cdba0589ba2 | 10 | class Tag { |
etherealflaim | 0:9cdba0589ba2 | 11 | private: |
etherealflaim | 0:9cdba0589ba2 | 12 | iHvZ *m_game; //< Maintain a connection to the active game |
etherealflaim | 0:9cdba0589ba2 | 13 | |
etherealflaim | 0:9cdba0589ba2 | 14 | DigitalIn m_tag; //< Check the status of the tagging/stunning button |
etherealflaim | 0:9cdba0589ba2 | 15 | InterruptIn m_tag_int; //< Get an interrupt whenever the tag/stun button is hit |
etherealflaim | 0:9cdba0589ba2 | 16 | Timeout m_timeout; //< Get an interrupt when a timeout occurs |
etherealflaim | 0:9cdba0589ba2 | 17 | |
etherealflaim | 0:9cdba0589ba2 | 18 | typedef enum { |
etherealflaim | 0:9cdba0589ba2 | 19 | TAG_EVENT_UNKNOWN = 0, |
etherealflaim | 0:9cdba0589ba2 | 20 | TAG_EVENT_BUTTON, |
etherealflaim | 0:9cdba0589ba2 | 21 | TAG_EVENT_RX, |
etherealflaim | 0:9cdba0589ba2 | 22 | TAG_EVENT_TIMEOUT, |
etherealflaim | 0:9cdba0589ba2 | 23 | } TagEvent; |
etherealflaim | 0:9cdba0589ba2 | 24 | |
etherealflaim | 0:9cdba0589ba2 | 25 | typedef enum { |
etherealflaim | 0:9cdba0589ba2 | 26 | TAG_STATE_WAITING = 0, |
etherealflaim | 0:9cdba0589ba2 | 27 | // Sending states |
etherealflaim | 0:9cdba0589ba2 | 28 | TAG_STATE_TX_SEND, |
etherealflaim | 0:9cdba0589ba2 | 29 | TAG_STATE_TX_WAITACK, |
etherealflaim | 0:9cdba0589ba2 | 30 | TAG_STATE_TX_WAITBTN, |
etherealflaim | 0:9cdba0589ba2 | 31 | TAG_STATE_TX_SENDCOMP, |
etherealflaim | 0:9cdba0589ba2 | 32 | // Receiving states |
etherealflaim | 0:9cdba0589ba2 | 33 | TAG_STATE_RX_RECV, |
etherealflaim | 0:9cdba0589ba2 | 34 | TAG_STATE_RX_WAITBTN, |
etherealflaim | 0:9cdba0589ba2 | 35 | TAG_STATE_RX_SENDACK, |
etherealflaim | 0:9cdba0589ba2 | 36 | TAG_STATE_RX_WAITCOMP |
etherealflaim | 0:9cdba0589ba2 | 37 | } TagState; |
etherealflaim | 0:9cdba0589ba2 | 38 | |
etherealflaim | 0:9cdba0589ba2 | 39 | public: |
etherealflaim | 0:9cdba0589ba2 | 40 | /** |
etherealflaim | 0:9cdba0589ba2 | 41 | * Create a new Tag |
etherealflaim | 0:9cdba0589ba2 | 42 | */ |
etherealflaim | 0:9cdba0589ba2 | 43 | Tag(iHvZ *game, PinName tagbtn); |
etherealflaim | 0:9cdba0589ba2 | 44 | |
etherealflaim | 0:9cdba0589ba2 | 45 | private: |
etherealflaim | 0:9cdba0589ba2 | 46 | inline void rise(); |
etherealflaim | 0:9cdba0589ba2 | 47 | inline void rx(); |
etherealflaim | 0:9cdba0589ba2 | 48 | inline void timeout(); |
etherealflaim | 0:9cdba0589ba2 | 49 | |
etherealflaim | 0:9cdba0589ba2 | 50 | // Defined in Tag.cpp |
etherealflaim | 0:9cdba0589ba2 | 51 | void event(TagEvent ev = TAG_EVENT_UNKNOWN); |
etherealflaim | 0:9cdba0589ba2 | 52 | |
etherealflaim | 0:9cdba0589ba2 | 53 | }; |
etherealflaim | 0:9cdba0589ba2 | 54 | |
etherealflaim | 0:9cdba0589ba2 | 55 | #endif |