2019-01-20 22:38:53 +01:00
|
|
|
#ifndef _RTCTIME_H
|
|
|
|
#define _RTCTIME_H
|
2019-01-19 17:53:21 +01:00
|
|
|
|
|
|
|
#include "globals.h"
|
2019-01-21 16:16:39 +01:00
|
|
|
#include <Time.h>
|
2019-01-19 17:53:21 +01:00
|
|
|
#include <Wire.h> // must be included here so that Arduino library object file references work
|
|
|
|
#include <RtcDS3231.h>
|
|
|
|
|
2019-01-21 16:16:39 +01:00
|
|
|
#ifdef HAS_GPS
|
|
|
|
#include "gpsread.h"
|
|
|
|
#endif
|
|
|
|
|
2019-01-20 13:17:44 +01:00
|
|
|
typedef enum {
|
|
|
|
useless = 0, // waiting for good enough signal
|
|
|
|
dirty = 1, // time data available but inconfident
|
|
|
|
reserve = 2, // clock was once synced but now may deviate
|
|
|
|
synced_LORA = 3, // clock driven by LORAWAN network
|
|
|
|
synced_GPS = 4 // best possible quality, clock is driven by GPS
|
|
|
|
} clock_state_t;
|
|
|
|
|
2019-01-25 22:49:26 +01:00
|
|
|
extern RtcDS3231<TwoWire> Rtc; // make RTC instance globally available
|
|
|
|
|
2019-01-19 17:53:21 +01:00
|
|
|
int rtc_init(void);
|
2019-01-20 22:38:53 +01:00
|
|
|
void sync_rtctime(void);
|
2019-01-21 16:16:39 +01:00
|
|
|
int set_rtctime(uint32_t UTCTime);
|
|
|
|
int set_rtctime(RtcDateTime now);
|
2019-01-20 22:38:53 +01:00
|
|
|
void sync_rtctime(void);
|
|
|
|
time_t get_rtctime(void);
|
|
|
|
float get_rtctemp(void);
|
2019-01-21 16:16:39 +01:00
|
|
|
time_t gpsTimeSync(void);
|
2019-01-19 17:53:21 +01:00
|
|
|
|
2019-01-20 22:38:53 +01:00
|
|
|
#endif // _RTCTIME_H
|