added internet time which is shown in the main first screen
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef INTERNET_TIME_H
|
||||
#define INTERNET_TIME_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
struct InternetTimeInfo
|
||||
{
|
||||
bool valid;
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
};
|
||||
|
||||
class InternetTime
|
||||
{
|
||||
public:
|
||||
InternetTime();
|
||||
void update(unsigned long now, bool wifiConnected);
|
||||
InternetTimeInfo info() const;
|
||||
bool consumeDirty();
|
||||
|
||||
private:
|
||||
void fetch(unsigned long now);
|
||||
void updateCurrentTime(unsigned long now);
|
||||
InternetTimeInfo infoFromEpoch(unsigned long epoch) const;
|
||||
|
||||
unsigned long lastEpoch_;
|
||||
unsigned long lastSyncMillis_;
|
||||
unsigned long nextAttempt_;
|
||||
InternetTimeInfo current_;
|
||||
bool dirty_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user