![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: main.cpp
- Revision:
- 25:b8176ebb96c6
- Parent:
- 24:a7f92dfc5310
- Child:
- 26:2dc31a801cc8
--- a/main.cpp Fri Dec 21 20:04:09 2018 +0000 +++ b/main.cpp Fri Dec 21 20:38:55 2018 +0000 @@ -28,7 +28,7 @@ FATFileSystem ffs("log", &bd); Serial pc(USBTX, USBRX); DigitalOut led1(LED1); -DigitalOut led3(LED3); +DigitalOut led2(LED2); RawSerial s(UART1TX, UART1RX, 38400); /////////////////////////////////////////////////////////////////////////////// @@ -45,6 +45,15 @@ EventQueue logQueue(8 * EVENTS_EVENT_SIZE); Logger logger("/etc/test.log"); + +/////////////////////////////////////////////////////////////////////////////// +// Updater +Updater *u = Updater::instance(); + +void updater_callback() { + led1 = !led1; +} + /////////////////////////////////////////////////////////////////////////////// // GPS Ublox6 ublox; @@ -54,7 +63,7 @@ void gps_callback() { GpsData d; - led3 = !led3; + led2 = !led2; ublox.read(d.latitude, d.longitude, d.course, d.speed, d.hdop, d.svcount); //logQueue.call(&logger, &Logger::log_gps, d); } @@ -136,7 +145,7 @@ { //bridge_uart1(); - Kernel::attach_idle_hook(idler); + //Kernel::attach_idle_hook(idler); printf("Bootup...\n"); fflush(stdout); @@ -169,10 +178,13 @@ } printf("Starting updater...\n"); - Updater *u = Updater::instance(); - u->setInterval(20); + u->attach(updater_callback); Thread updaterThread(osPriorityRealtime, 512, 0, "updater"); - updaterThread.start(callback(u, &Updater::start)); + EventQueue *updaterQueue = mbed_highprio_event_queue(); + Event<void()> event(updaterQueue, callback(u, &Updater::update)); + event.period(20); + event.post(); + updaterThread.start(callback(updaterQueue, &EventQueue::dispatch_forever)); printf("Starting gps...\n"); Thread gpsThread(osPriorityHigh, 256, 0, "gps");