2018-06-08 22:41:37 +02:00
|
|
|
#ifdef HAS_GPS
|
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
// Local logging tag
|
|
|
|
static const char TAG[] = "main";
|
2018-06-09 17:59:59 +02:00
|
|
|
|
2018-06-09 13:18:59 +02:00
|
|
|
// GPS read data to global struct
|
|
|
|
void gps_read(){
|
|
|
|
gps_status.latitude = gps.location.lat();
|
|
|
|
gps_status.longitude = gps.location.lng();
|
|
|
|
gps_status.satellites = (uint8_t) gps.satellites.value();
|
|
|
|
gps_status.hdop = (uint8_t) (gps.hdop.value() / 100);
|
|
|
|
gps_status.altitude = (uint16_t) gps.altitude.meters();
|
|
|
|
}
|
|
|
|
|
2018-06-09 16:52:51 +02:00
|
|
|
/// GPS serial feed FreeRTos Task
|
2018-06-08 22:41:37 +02:00
|
|
|
void gps_loop(void * pvParameters) {
|
|
|
|
|
|
|
|
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
|
|
|
|
|
|
|
HardwareSerial GPS_Serial(1);
|
2018-06-09 10:42:12 +02:00
|
|
|
//GPS_Serial.begin(HAS_GPS);
|
|
|
|
GPS_Serial.begin(9600, SERIAL_8N1, 12, 15 );
|
2018-06-08 22:41:37 +02:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
|
|
|
while (GPS_Serial.available()) {
|
2018-06-09 13:18:59 +02:00
|
|
|
gps.encode(GPS_Serial.read());
|
2018-06-08 22:41:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vTaskDelay(1/portTICK_PERIOD_MS); // reset watchdog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAS_GPS
|