to colorize a colorful pixel with a simple touch using nfc technology
Dependencies: Chainable_RGB_LED mbed
use Arch, NFC Shield and Grove - Chainable RGB LED to DIY a touch pixel. Then use an Android with NFC support to colorize it.
The project is on https://github.com/Seeed-Studio/TouchPixel
nfc/NfcAdapter.h@0:88960f3eeb2c, 2013-12-27 (annotated)
- Committer:
- yihui
- Date:
- Fri Dec 27 01:46:32 2013 +0000
- Revision:
- 0:88960f3eeb2c
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 0:88960f3eeb2c | 1 | #ifndef NfcAdapter_h |
yihui | 0:88960f3eeb2c | 2 | #define NfcAdapter_h |
yihui | 0:88960f3eeb2c | 3 | |
yihui | 0:88960f3eeb2c | 4 | #include <PN532Interface.h> |
yihui | 0:88960f3eeb2c | 5 | #include <PN532.h> |
yihui | 0:88960f3eeb2c | 6 | #include <NfcTag.h> |
yihui | 0:88960f3eeb2c | 7 | #include <Ndef.h> |
yihui | 0:88960f3eeb2c | 8 | |
yihui | 0:88960f3eeb2c | 9 | // Drivers |
yihui | 0:88960f3eeb2c | 10 | #include <MifareClassic.h> |
yihui | 0:88960f3eeb2c | 11 | #include <MifareUltralight.h> |
yihui | 0:88960f3eeb2c | 12 | |
yihui | 0:88960f3eeb2c | 13 | #define TAG_TYPE_MIFARE_CLASSIC (0) |
yihui | 0:88960f3eeb2c | 14 | #define TAG_TYPE_1 (1) |
yihui | 0:88960f3eeb2c | 15 | #define TAG_TYPE_2 (2) |
yihui | 0:88960f3eeb2c | 16 | #define TAG_TYPE_3 (3) |
yihui | 0:88960f3eeb2c | 17 | #define TAG_TYPE_4 (4) |
yihui | 0:88960f3eeb2c | 18 | #define TAG_TYPE_UNKNOWN (99) |
yihui | 0:88960f3eeb2c | 19 | |
yihui | 0:88960f3eeb2c | 20 | #define IRQ (2) |
yihui | 0:88960f3eeb2c | 21 | #define RESET (3) // Not connected by default on the NFC Shield |
yihui | 0:88960f3eeb2c | 22 | |
yihui | 0:88960f3eeb2c | 23 | class NfcAdapter { |
yihui | 0:88960f3eeb2c | 24 | public: |
yihui | 0:88960f3eeb2c | 25 | NfcAdapter(PN532Interface &interface); |
yihui | 0:88960f3eeb2c | 26 | |
yihui | 0:88960f3eeb2c | 27 | ~NfcAdapter(void); |
yihui | 0:88960f3eeb2c | 28 | void begin(void); |
yihui | 0:88960f3eeb2c | 29 | bool tagPresent(); // tagAvailable |
yihui | 0:88960f3eeb2c | 30 | NfcTag read(); |
yihui | 0:88960f3eeb2c | 31 | bool write(NdefMessage& ndefMessage); |
yihui | 0:88960f3eeb2c | 32 | // FUTURE bool share(NdefMessage& ndefMessage); |
yihui | 0:88960f3eeb2c | 33 | // FUTURE bool unshare(); |
yihui | 0:88960f3eeb2c | 34 | // FUTURE bool erase(); |
yihui | 0:88960f3eeb2c | 35 | // FUTURE bool format(); |
yihui | 0:88960f3eeb2c | 36 | private: |
yihui | 0:88960f3eeb2c | 37 | PN532* shield; |
yihui | 0:88960f3eeb2c | 38 | uint8_t uid[7]; // Buffer to store the returned UID |
yihui | 0:88960f3eeb2c | 39 | unsigned int uidLength; // Length of the UID (4 or 7 uint8_ts depending on ISO14443A card type) |
yihui | 0:88960f3eeb2c | 40 | unsigned int guessTagType(); |
yihui | 0:88960f3eeb2c | 41 | }; |
yihui | 0:88960f3eeb2c | 42 | |
yihui | 0:88960f3eeb2c | 43 | #endif |