GPS NEMA String parser library. Only supports SkyTraq Venus chip at this time.
Dependents: MTDOT-EVB-LinkCheck-AL MTDOT-BOX-EVB-Factory-Firmware-LIB-108 TelitSensorToCloud mDot_sensor_to_cloud ... more
Diff: GPSPARSER.cpp
- Revision:
- 7:bd1013ba8afd
- Parent:
- 6:2050b4795b66
- Child:
- 8:5fa40fa372e2
--- a/GPSPARSER.cpp Fri Dec 04 16:40:41 2015 -0600
+++ b/GPSPARSER.cpp Mon Dec 07 11:45:56 2015 -0600
@@ -34,7 +34,8 @@
GPSPARSER::GPSPARSER(MTSSerial *uart, NCP5623B* led)
: _getSentenceThread(&GPSPARSER::startSentenceThread,this),
_led(led),
- _led_state(0)
+ _led_state(0),
+ _tick_running(false)
{
_gps_uart = uart;
_gps_uart->baud(9600); //set GPS baud rate here
@@ -59,7 +60,6 @@
if (GPSPARSER::initGps() == 0) {
_gps_detected = true;
_getSentenceThread.signal_set(START_THREAD);
- _led_timer.start();
printf("Started Nema Sentence Thread\r\n");
} else {
printf("No GPS detected\r\n");
@@ -156,6 +156,10 @@
_getSentenceThread.signal_wait(START_THREAD);
printf("Got thread start\r\n");
+ if (_led) {
+ _tick.attach(this, &GPSPARSER::blinker, 0.5);
+ _tick_running = true;
+ }
do {
if (_gps_uart->readable() > 80) {
@@ -208,11 +212,16 @@
if (_led) {
if (_fix_status >= 2) {
+ if (_tick_running) {
+ _tick.detach();
+ _tick_running = false;
+ }
_led->setPWM(NCP5623B::LED_3, 8);
- } else if (_led_timer.read_ms() > 1000) {
- _led_timer.reset();
- _led_state = (_led_state == 0) ? 8 : 0;
- _led->setPWM(NCP5623B::LED_3, _led_state);
+ } else {
+ if (! _tick_running) {
+ _tick.attach(this, &GPSPARSER::blinker, 0.5);
+ _tick_running = true;
+ }
}
}
@@ -428,3 +437,8 @@
return _msl_altitude;
}
+void GPSPARSER::blinker() {
+ _led_state = (_led_state == 0) ? 8 : 0;
+ _led->setPWM(NCP5623B::LED_3, _led_state);
+}
+