wave cancel
Dependencies: 4DGL-uLCD-SE EthernetInterface HTTPClient NTPClient PinDetect SDFileSystem mbed-rtos mbed wave_player
Fork of 4180_Final_Project by
Diff: main.cpp
- Revision:
- 12:27470e8c0556
- Parent:
- 11:89e778e985d5
- Child:
- 13:34dc6730e791
--- a/main.cpp Thu Apr 28 16:52:38 2016 +0000 +++ b/main.cpp Thu Apr 28 17:00:55 2016 +0000 @@ -151,6 +151,75 @@ } } +void getSDInfo() +{ + char c; + FILE *fp = fopen("/sd/mydir/sdtest.txt", "r"); + if(fp == NULL) { + error("Could not open file for read\n"); + } + int count = 0; + int i; + char arr_time[8] = ""; + char hour[3], min[3]; + int arrival_hour; + int arrival_min; + char r_time[8] = ""; + int ready_time = 0; + char start_add[32] = ""; // start location address + char dest_add[32] = ""; // destination address + + while (!feof(fp)){ // while not end of file + c=fgetc(fp); // get a character/byte from the file + uLCD.printf("%c",c); + if (c == '@') { + count++; // specifies what data (eg. arrival time, ready time, etc) + i = 0; + } + else { + //uLCD.printf("%d",count); + switch (count) { + case 0: // arrival time + arr_time[i] = c; + i++; + break; + case 1: // ready time (min) + r_time[i] = c; + i++; + break; + case 2: // start address + start_add[i] = c; + i++; + break; + case 3: // destination address + dest_add[i] = c; + i++; + break; + default: + error("too many & detected\n"); + break; + } + + //uLCD.printf("Read from file %02x\n\r",c); // and show it in hex format + } + } + memcpy( hour, &arr_time[0], 2 ); + memcpy( min, &arr_time[3], 2 ); + + arrival_hour = atoi(hour); + arrival_min = atoi(min); + uLCD.printf("\narrival hour is %d\n",arrival_hour); + uLCD.printf("arrival min is %d\n",arrival_min); + + ready_time = atoi(r_time); + //uLCD.printf("\nString ready time is %s",r_time); + uLCD.printf("Ready Time is %d\n",ready_time); + uLCD.printf("start address is %s\n", start_add); + uLCD.printf("dest address is %s\n", dest_add); + + fclose(fp); +} + int main() { snooze.mode(PullUp);