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
Revision 21:db8dadfd7d2a, committed 2014-11-24
- Comitter:
- DaniusKalv
- Date:
- Mon Nov 24 17:52:09 2014 +0000
- Parent:
- 20:8055a5b5dba0
- Child:
- 22:8a5ea75ad53b
- Commit message:
- Updated matrix driver to use bits, also text generator now generates text in hex
Changed in this revision
matrix.cpp | Show annotated file Show diff for this revision Revisions of this file |
text.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/matrix.cpp Mon Nov 24 15:02:37 2014 +0000 +++ b/matrix.cpp Mon Nov 24 17:52:09 2014 +0000 @@ -7,13 +7,15 @@ }; void matrix::show(){ - char temp[8]; + uint8_t temp; fp = fopen("/local/out.txt", "r"); fscanf(fp, "%i", &length); + pc.printf("\r\nLength = %i", length); for (int i = 0; i < 16; i++){ - fscanf(fp, "%s", temp); + fscanf(fp, "%x", &temp); + //pc.printf("\r\n%02x", temp); for (int j = 0; j < 8; j++){ - display[7 - j][i] = temp[j] - 48; + display[7 - j][i] = ((temp & (1 << (7 - j))) >> j); } } for (int i = 15; i < length; i++){ @@ -25,9 +27,10 @@ display[h][g] = display[h][g + 1]; } } - fscanf(fp, "%s", temp); + fscanf(fp, "%x", &temp); + //pc.printf("\r\n%02x", temp); for (int j = 0; j < 8; j++){ - display[j][15] = temp[7 - j] - 48; + display[j][15] = ((temp & (1 << j)) >> j); } } fclose(fp);
--- 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); }