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
Revision 7:bd1013ba8afd, committed 2015-12-07
- Comitter:
- Mike Fiore
- Date:
- Mon Dec 07 11:45:56 2015 -0600
- Parent:
- 6:2050b4795b66
- Child:
- 8:5fa40fa372e2
- Commit message:
- use ticker to blink LED
Changed in this revision
| GPSPARSER.cpp | Show annotated file Show diff for this revision Revisions of this file |
| GPSPARSER.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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);
+}
+
--- a/GPSPARSER.h Fri Dec 04 16:40:41 2015 -0600
+++ b/GPSPARSER.h Mon Dec 07 11:45:56 2015 -0600
@@ -153,7 +153,8 @@
Thread _getSentenceThread;
NCP5623B* _led;
int8_t _led_state;
- Timer _led_timer;
+ Ticker _tick;
+ bool _tick_running;
/** Detect and initialize GPS device
* @return status of initialization
@@ -205,5 +206,7 @@
*/
uint8_t parseZDA(char *nema_buff);
+ void blinker();
+
};
#endif