2019-06-12 19:18:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <SoftwareSerial.h>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
2019-06-26 14:46:07 +00:00
|
|
|
// A lightweight struct to hold location information.
|
|
|
|
// TinyGPS++ actually uses a *ton* of RAM so we can't keep the instance around as a global variable
|
2019-06-28 13:11:25 +00:00
|
|
|
// FUTURE: Rewrite this to use TinyGPS's integer system instead?
|
2019-06-26 14:46:07 +00:00
|
|
|
struct GPSLocation {
|
|
|
|
float lat;
|
|
|
|
float lng;
|
|
|
|
#ifdef SD_DEBUG_ENABLED
|
|
|
|
char time[20];
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2019-06-12 19:18:37 +00:00
|
|
|
/**
|
|
|
|
* Initialises the connection to the GPS device.
|
|
|
|
*/
|
2019-06-26 14:59:49 +00:00
|
|
|
SoftwareSerial gps_begin();
|
2019-06-12 19:18:37 +00:00
|
|
|
|
|
|
|
/**
|
2019-06-20 12:56:08 +00:00
|
|
|
* Fetches new data from the GPS module.
|
2019-06-12 19:18:37 +00:00
|
|
|
* May take a moment, as the GPS device needs time to acquire a satellite fix.
|
2019-06-20 12:56:08 +00:00
|
|
|
*/
|
2019-06-26 14:46:07 +00:00
|
|
|
GPSLocation gps_fetch();
|
2019-06-13 13:13:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ends the connection to the GPS device and puts it to sleep in order to save
|
|
|
|
* power.
|
|
|
|
* Note that the GPS device is connected directly to the power management
|
|
|
|
* system and so doesn't get turned off after each measurement, as it takes
|
|
|
|
* ~30s to reacquire a lock when it first starts up - hence why we put it to
|
|
|
|
* sleep instead.
|
2019-06-26 14:59:49 +00:00
|
|
|
* TODO: Connect the gps module to the timed power rail instead, as its; got an onboard battery.
|
2019-06-13 13:13:03 +00:00
|
|
|
*/
|
2019-06-26 14:59:49 +00:00
|
|
|
void gps_end(SoftwareSerial gps);
|