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
Diff: nfc/PN532_SPI.h
- Revision:
- 0:88960f3eeb2c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nfc/PN532_SPI.h Fri Dec 27 01:46:32 2013 +0000 @@ -0,0 +1,39 @@ + +#ifndef __PN532_SPI_H__ +#define __PN532_SPI_H__ + +#include "mbed.h" +#include "PN532Interface.h" + +class PN532_SPI : public PN532Interface +{ +public: + PN532_SPI(SPI &spi, PinName ss); + PN532_SPI(SPI *spi, PinName ss); + + virtual void begin(); + virtual void wakeup(); + virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen); + virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout); + +private: + SPI *_spi; + DigitalOut _ss; + uint8_t command; + + bool isReady(); + void writeFrame(const uint8_t *header, uint8_t hlen, const uint8_t *body, uint8_t blen); + int8_t readAckFrame(); + + inline void write(uint8_t data) { + REVERSE_BITS_ORDER(data); + _spi->write(data); + } + inline uint8_t read() { + uint8_t data = _spi->write(0); + REVERSE_BITS_ORDER(data); + return data; + } +}; + +#endif