You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
976 B
40 lines
976 B
#ifndef _ALARMCLOCK_H
|
|
#define _ALARMCLOCK_H
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <time.h>
|
|
#include <sys/time.h>
|
|
#include "apps/sntp/sntp.h"
|
|
|
|
#include "driver/rtc_io.h"
|
|
|
|
enum whichTime { TIME_CURRENT, TIME_ALARM };
|
|
|
|
RTC_DATA_ATTR static struct tm alarmTime;
|
|
RTC_DATA_ATTR static bool alarmArmed;
|
|
|
|
class AlarmClock {
|
|
public:
|
|
AlarmClock();
|
|
bool isPending(double);
|
|
bool isAlarmArmed(void);
|
|
void setAlarmTime(struct tm time);
|
|
void disableAlarm(void);
|
|
struct tm getAlarmTime(void);
|
|
void getTime(char* ptr, size_t maxsize, const char* format = "%H:%M:%S", whichTime type = TIME_CURRENT);
|
|
bool isTimeValid(void);
|
|
bool isNight(void);
|
|
bool getRTCTime(struct tm *timeinfo);
|
|
bool isNTPExpired(void);
|
|
bool updateNTPTime(void);
|
|
double getSecondsToAlarm(void);
|
|
void printTimeUnix(whichTime);
|
|
private:
|
|
bool update(void);
|
|
time_t now;
|
|
struct tm timeinfo;
|
|
uint32_t lastNTPRequest = 0;
|
|
};
|
|
|
|
#endif /* _ALARMCLOCK_H */
|
|
|