Blue LED matrix (8x16) program. Gets text string through bluetooth and displays it on led matrix. Also has a clock function- get system time from a phone through bluetooth and enters clock mode. In clock mode it acts as a clock showing hours and minutes and blinking led every second. Clock mode can be broken if a text string is received through bluetooth.
Dependencies: mbed
Diff: text.cpp
- Revision:
- 21:db8dadfd7d2a
- Parent:
- 9:ed7e8a6fc537
diff -r 8055a5b5dba0 -r db8dadfd7d2a text.cpp --- a/text.cpp Mon Nov 24 15:02:37 2014 +0000 +++ b/text.cpp Mon Nov 24 17:52:09 2014 +0000 @@ -14,7 +14,7 @@ calcLength(input); fprintf(fp, "%i\r\n", length); for (int i = 0; i < 16; i++){ - fprintf(fp, "00000000\r\n"); + fprintf(fp, "%02x\r\n", 0x00); } for (int i = 0; i < stringLength; i++){ pc.printf("\r\nTaking letter "); @@ -24,16 +24,20 @@ pc.putc(input.at(i)); tempCheck(); for (int j = 7; j >= (8 - letSize); j--){ + uint8_t hex = 0; for (int g = 7; g >= 0; g--){ - fprintf(fp, "%i", ((temp[g] & (1 << j)) >> j)); + //fprintf(fp, "%i", ((temp[g] & (1 << j)) >> j)); + hex |= (((temp[g] & (1 << j)) >> j) << g); } - fprintf(fp,"\r\n"); + fprintf(fp,"%02x\r\n", hex); } - fprintf(fp, "00000000\r\n"); + fprintf(fp, "%02x\r\n", 0x00); } for (int i = 0; i < 15; i++){ - fprintf(fp, "00000000\r\n"); + fprintf(fp, "%02x\r\n", 0x00); } + pc.printf("\r\n%02x", 0x3e); + fprintf(fp, "%02x\r\n", 0x3e); fclose(fp); }