Files
firmware/src/GPS.h

40 lines
923 B
C
Raw Normal View History

2020-02-06 07:39:21 -08:00
#pragma once
#include <TinyGPS++.h>
#include "PeriodicTask.h"
#include "Observer.h"
2020-02-19 10:53:09 -08:00
#include "sys/time.h"
2020-02-06 07:39:21 -08:00
/**
* A gps class that only reads from the GPS periodically (and FIXME - eventually keeps the gps powered down except when reading)
*
* When new data is available it will notify observers.
*/
class GPS : public PeriodicTask, public Observable, public TinyGPSPlus
{
public:
GPS();
2020-02-19 10:53:09 -08:00
/// Return time since 1970 in secs. Until we have a GPS lock we will be returning time based at zero
uint32_t getTime();
/// Return time since 1970 in secs. If we don't have a GPS lock return zero
uint32_t getValidTime();
2020-02-06 08:18:20 -08:00
String getTimeStr();
2020-02-06 07:39:21 -08:00
void setup();
virtual void loop();
2020-02-21 10:20:47 -08:00
virtual void doTask();
2020-02-19 08:17:28 -08:00
2020-02-19 10:53:09 -08:00
/// If we haven't yet set our RTC this boot, set it from a GPS derived time
void perhapsSetRTC(const struct timeval *tv);
2020-02-19 08:17:28 -08:00
private:
void readFromRTC();
2020-02-06 07:39:21 -08:00
};
extern GPS gps;