2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 43:9a285515f33a
- Parent:
- 42:8d99f64f5898
- Child:
- 44:0d72a8a1288a
--- a/main.cpp Thu Jan 03 17:50:44 2019 +0000 +++ b/main.cpp Thu Jan 03 19:07:20 2019 +0000 @@ -14,7 +14,8 @@ #include "SimpleShell.h" #include "Config.h" #include "Updater.h" -#include "Ublox6.h" +//#include "Ublox6.h" +#include "TinyGPS.h" #include "Logger.h" #include "SystemState.h" #include "Display.h" @@ -34,7 +35,8 @@ SDBlockDevice bd(p5, p6, p7, p8); // MOSI, MISO, CLK, CS FATFileSystem ffs("log", &bd); Serial pc(USBTX, USBRX); -RawSerial s(UART1TX, UART1RX, 38400); +//RawSerial s(UART1TX, UART1RX, 38400); +RawSerial s(UART1TX, UART1RX, 19200); InterruptIn lbutton(LBUTTON, PullUp); // button interrupts InterruptIn cbutton(CBUTTON, PullUp); InterruptIn rbutton(RBUTTON, PullUp); @@ -126,7 +128,8 @@ /////////////////////////////////////////////////////////////////////////////// // GPS -Ublox6 ublox; +//Ublox6 ublox; +TinyGPS gps; EventQueue gpsQueue(8 * EVENTS_EVENT_SIZE); // Callback for gps parse data ready @@ -134,7 +137,8 @@ GpsData d; led2 = !led2; - ublox.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount); + //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); d.timestamp = Kernel::get_ms_count(); logQueue.call(&logger, &Logger::log_gps, d); lcdQueue.call(&display, &Display::gps, d); @@ -143,8 +147,9 @@ // ISR for GPS serial, passes off to thread void gps_handler() { while (s.readable()) { - int c = s.getc(); - gpsQueue.call(&ublox, &Ublox6::parse, c); + char c = s.getc(); + //gpsQueue.call(&ublox, &Ublox6::parse, c); + gpsQueue.call(&gps, &TinyGPS::parse, c); } } @@ -180,7 +185,7 @@ float hdop=0.0; int svcount=0; - ublox.read(lat, lon, course, speed, hdop, svcount); + 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); @@ -265,7 +270,7 @@ int main() { //bridge_uart1(); - bridge_uart2(); + //bridge_uart2(); //Kernel::attach_idle_hook(idler); @@ -329,7 +334,7 @@ display.status("Starting gps"); Thread gpsThread(osPriorityHigh, 2048, 0, "gps"); gpsThread.start(callback(&gpsQueue, &EventQueue::dispatch_forever)); - ublox.subscribe(gps_callback); + gps.subscribe(gps_callback); s.attach(gps_handler); printf("Starting logging...\n");