asdfasdf
Dependencies: 4DGL-uLCD-SE mbed SDFileSystem
Fork of final_serial by
main.cpp@1:592209317c79, 2016-04-27 (annotated)
- Committer:
- ashea6
- Date:
- Wed Apr 27 21:21:32 2016 +0000
- Revision:
- 1:592209317c79
- Parent:
- 0:78a5165b5f5e
final serial to sd updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
agamemaker | 0:78a5165b5f5e | 1 | #include "mbed.h" |
agamemaker | 0:78a5165b5f5e | 2 | #include "uLCD_4DGL.h" |
ashea6 | 1:592209317c79 | 3 | #include "SDFileSystem.h" |
agamemaker | 0:78a5165b5f5e | 4 | |
agamemaker | 0:78a5165b5f5e | 5 | Serial pc(USBTX, USBRX); |
agamemaker | 0:78a5165b5f5e | 6 | DigitalOut myled(LED1); |
ashea6 | 1:592209317c79 | 7 | SDFileSystem sd(p11, p12, p13, p14, "sd"); //SD card |
agamemaker | 0:78a5165b5f5e | 8 | uLCD_4DGL uLCD(p28,p27,p29); |
agamemaker | 0:78a5165b5f5e | 9 | |
agamemaker | 0:78a5165b5f5e | 10 | |
ashea6 | 1:592209317c79 | 11 | int main() |
ashea6 | 1:592209317c79 | 12 | { |
ashea6 | 1:592209317c79 | 13 | while(1) { |
ashea6 | 1:592209317c79 | 14 | char buff[100]; |
ashea6 | 1:592209317c79 | 15 | int i = 0; |
ashea6 | 1:592209317c79 | 16 | bool flag = false; |
ashea6 | 1:592209317c79 | 17 | while(!flag) { |
ashea6 | 1:592209317c79 | 18 | buff[i] = pc.getc(); |
ashea6 | 1:592209317c79 | 19 | pc.putc(buff[i]); |
ashea6 | 1:592209317c79 | 20 | flag = buff[i] == '^'; |
ashea6 | 1:592209317c79 | 21 | i++; |
ashea6 | 1:592209317c79 | 22 | } |
ashea6 | 1:592209317c79 | 23 | uLCD.printf("%s", buff); |
ashea6 | 1:592209317c79 | 24 | |
ashea6 | 1:592209317c79 | 25 | mkdir("/sd/mydir", 0777); |
ashea6 | 1:592209317c79 | 26 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
ashea6 | 1:592209317c79 | 27 | if(fp == NULL) { |
ashea6 | 1:592209317c79 | 28 | error("Could not open file for write\n"); |
ashea6 | 1:592209317c79 | 29 | } |
ashea6 | 1:592209317c79 | 30 | fprintf(fp, buff); |
ashea6 | 1:592209317c79 | 31 | fclose(fp); |
agamemaker | 0:78a5165b5f5e | 32 | } |
agamemaker | 0:78a5165b5f5e | 33 | } |