2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 44:0d72a8a1288a
- Parent:
- 43:9a285515f33a
diff -r 9a285515f33a -r 0d72a8a1288a main.cpp --- a/main.cpp Thu Jan 03 19:07:20 2019 +0000 +++ b/main.cpp Mon Jan 07 16:47:33 2019 +0000 @@ -15,7 +15,7 @@ #include "Config.h" #include "Updater.h" //#include "Ublox6.h" -#include "TinyGPS.h" +#include "NMEA.h" #include "Logger.h" #include "SystemState.h" #include "Display.h" @@ -129,16 +129,23 @@ /////////////////////////////////////////////////////////////////////////////// // GPS //Ublox6 ublox; -TinyGPS gps; +NMEA nmea; EventQueue gpsQueue(8 * EVENTS_EVENT_SIZE); // Callback for gps parse data ready void gps_callback() { + GPS::gps_data_t data; GpsData d; led2 = !led2; //ublox.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount); - gps.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount); + data = nmea.read(); + d.latitude = data.lat; + d.longitude = data.lon; + d.course = data.course; + d.speed = data.speed; + d.hdop = data.hdop; + d.svcount = data.svcount; d.timestamp = Kernel::get_ms_count(); logQueue.call(&logger, &Logger::log_gps, d); lcdQueue.call(&display, &Display::gps, d); @@ -149,7 +156,7 @@ while (s.readable()) { char c = s.getc(); //gpsQueue.call(&ublox, &Ublox6::parse, c); - gpsQueue.call(&gps, &TinyGPS::parse, c); + gpsQueue.call(&nmea, &NMEA::parse, c); } } @@ -178,17 +185,12 @@ void read_gps(int argc, char **argv) { - double lat=0; - double lon=0; - float course=0; - float speed=0; - float hdop=0.0; - int svcount=0; + GPS::gps_data_t d; - gps.read(lat, lon, course, speed, hdop, svcount); - printf("%3.7f %3.7f\n", lat, lon); - printf("hdg=%03.1f deg spd=%3.1f m/s\n", course, speed); - printf("%d %f\n", svcount, hdop); + d = nmea.read(); + printf("%3.7f %3.7f\n", d.lat, d.lon); + printf("hdg=%03.1f deg spd=%3.1f m/s\n", d.course, d.speed); + printf("%d %f\n", d.svcount, d.hdop); } void read_imu(int argc, char **argv) @@ -334,7 +336,7 @@ display.status("Starting gps"); Thread gpsThread(osPriorityHigh, 2048, 0, "gps"); gpsThread.start(callback(&gpsQueue, &EventQueue::dispatch_forever)); - gps.subscribe(gps_callback); + nmea.subscribe(gps_callback); s.attach(gps_handler); printf("Starting logging...\n");