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

Committer:
yihui
Date:
Fri Dec 27 01:46:32 2013 +0000
Revision:
0:88960f3eeb2c
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:88960f3eeb2c 1 #include "Ndef.h"
yihui 0:88960f3eeb2c 2 #include "PN532_debug.h"
yihui 0:88960f3eeb2c 3
yihui 0:88960f3eeb2c 4 // Borrowed from Adafruit_NFCShield_I2C
yihui 0:88960f3eeb2c 5 void PrintHex(const uint8_t * data, const long numuint8_ts)
yihui 0:88960f3eeb2c 6 {
yihui 0:88960f3eeb2c 7 uint32_t szPos;
yihui 0:88960f3eeb2c 8 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 0:88960f3eeb2c 9 {
yihui 0:88960f3eeb2c 10 DMSG("0x");
yihui 0:88960f3eeb2c 11 // Append leading 0 for small values
yihui 0:88960f3eeb2c 12 if (data[szPos] <= 0xF)
yihui 0:88960f3eeb2c 13 DMSG("0");
yihui 0:88960f3eeb2c 14 DMSG_HEX(data[szPos]&0xff);
yihui 0:88960f3eeb2c 15 if ((numuint8_ts > 1) && (szPos != numuint8_ts - 1))
yihui 0:88960f3eeb2c 16 {
yihui 0:88960f3eeb2c 17 DMSG(" ");
yihui 0:88960f3eeb2c 18 }
yihui 0:88960f3eeb2c 19 }
yihui 0:88960f3eeb2c 20 DMSG("");
yihui 0:88960f3eeb2c 21 }
yihui 0:88960f3eeb2c 22
yihui 0:88960f3eeb2c 23 // Borrowed from Adafruit_NFCShield_I2C
yihui 0:88960f3eeb2c 24 void PrintHexChar(const uint8_t * data, const long numuint8_ts)
yihui 0:88960f3eeb2c 25 {
yihui 0:88960f3eeb2c 26 uint32_t szPos;
yihui 0:88960f3eeb2c 27 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 0:88960f3eeb2c 28 {
yihui 0:88960f3eeb2c 29 // Append leading 0 for small values
yihui 0:88960f3eeb2c 30 DMSG_HEX(data[szPos]);
yihui 0:88960f3eeb2c 31 }
yihui 0:88960f3eeb2c 32 DMSG(" ");
yihui 0:88960f3eeb2c 33 for (szPos=0; szPos < numuint8_ts; szPos++)
yihui 0:88960f3eeb2c 34 {
yihui 0:88960f3eeb2c 35 if (data[szPos] <= 0x1F)
yihui 0:88960f3eeb2c 36 DMSG(".");
yihui 0:88960f3eeb2c 37 else
yihui 0:88960f3eeb2c 38 DMSG("%c", (char)data[szPos]);
yihui 0:88960f3eeb2c 39 }
yihui 0:88960f3eeb2c 40 DMSG("\n");
yihui 0:88960f3eeb2c 41 }
yihui 0:88960f3eeb2c 42
yihui 0:88960f3eeb2c 43 // Note if buffer % blockSize != 0, last block will not be written
yihui 0:88960f3eeb2c 44 void DumpHex(const uint8_t * data, const long numuint8_ts, const unsigned int blockSize)
yihui 0:88960f3eeb2c 45 {
yihui 0:88960f3eeb2c 46 int i;
yihui 0:88960f3eeb2c 47 for (i = 0; i < (numuint8_ts / blockSize); i++)
yihui 0:88960f3eeb2c 48 {
yihui 0:88960f3eeb2c 49 PrintHexChar(data, blockSize);
yihui 0:88960f3eeb2c 50 data += blockSize;
yihui 0:88960f3eeb2c 51 }
yihui 0:88960f3eeb2c 52 }