added spectrometer timeout
Dependencies: SDFileSystem mbed
Fork of All_Combined_Real2 by
Diff: main.cpp
- Revision:
- 0:26713d1db198
- Child:
- 1:5fa445bd14a6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Mar 10 17:27:10 2016 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" +#include "nmea.h" +#include "SDFileSystem.h" + +#define BUF_SIZE 1024 + +DigitalOut gpo(D0); +DigitalOut led(LED_RED); + +Serial duino(PTC4, PTC3); +Serial pc(USBTX, USBRX); + +/************************************************** + ** SD FILE SYSTEM ** + **************************************************/ +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); +FILE *fpData; + +int main() +{ + pc.baud(115200); // make sure to set computer TERA Term or whatever to 115200 baud!!! + duino.baud(9600); + pc.printf("Initializing ...\r\n"); + char buffer[BUF_SIZE]; + + while (true) { + + led = !led; + + get_nmea(&duino, buffer, BUF_SIZE); + + struct NMEA_data nmea = parse_line(buffer); + + // determine whether there's a lock + char lock_str[BUF_SIZE]; + if ( nmea.lock_flag == 'A' ) + sprintf(lock_str, "Has lock"); + else + sprintf(lock_str, "No lock"); + + // assemble data into summary string + char status_str[BUF_SIZE]; + sprintf(status_str, "%02d:%02d:%02d, %d/%d/%d, %dd %lf' %c %dd %lf' %c, %s\r\n", + nmea.hours, nmea.minutes, nmea.seconds, + nmea.month, nmea.day, nmea.year, + nmea.latitude, nmea.latitude_minutes, nmea.latitude_direction, + nmea.longitude, nmea.longitude_minutes, nmea.longitude_direction, lock_str); + + // print to pc, sd card + pc.printf("%s", status_str); + + fpData = fopen("/sd/data.txt", "a"); + fprintf(fpData, "%s", status_str); + fclose(fpData); + wait(0.5f); + } +} \ No newline at end of file