-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
112 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
#include "CWDateTime.h" | ||
|
||
void CWDateTime::begin() | ||
{ | ||
myTZ.setCache(0); | ||
waitForSync(); | ||
} | ||
|
||
void CWDateTime::setTimezone(const char *timeZone) | ||
{ | ||
myTZ.setCache(0); | ||
myTZ.setLocation(timeZone); | ||
waitForSync(); | ||
} | ||
|
||
String CWDateTime::getTimezone() | ||
{ | ||
return myTZ.getTimezoneName(0); | ||
} | ||
|
||
|
||
void CWDateTime::update() | ||
{ | ||
} | ||
|
||
String CWDateTime::getFormattedTime() | ||
{ | ||
return myTZ.dateTime(); | ||
} | ||
|
||
char *CWDateTime::getHour(const char *format) | ||
{ | ||
static char buffer[3] = {'\0'}; | ||
snprintf(buffer, sizeof(buffer), format, myTZ.dateTime("H")); | ||
return buffer; | ||
} | ||
|
||
char *CWDateTime::getMinute(const char *format) | ||
{ | ||
static char buffer[3] = {'\0'}; | ||
strncpy(buffer, myTZ.dateTime("i").c_str(), sizeof(buffer)); | ||
return buffer; | ||
} | ||
|
||
int CWDateTime::getHour() | ||
{ | ||
return myTZ.dateTime("H").toInt(); | ||
} | ||
|
||
int CWDateTime::getMinute() | ||
{ | ||
return myTZ.dateTime("i").toInt(); | ||
} | ||
|
||
int CWDateTime::getSecond() | ||
{ | ||
return myTZ.dateTime("s").toInt(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef CWDateTimeCf_h | ||
#define CWDateTimeCf_h | ||
|
||
#include <Arduino.h> | ||
|
||
#include <ezTime.h> | ||
#include <WiFi.h> | ||
|
||
class CWDateTime | ||
{ | ||
private: | ||
Timezone myTZ; | ||
|
||
public: | ||
void begin(); | ||
void setTimezone(const char *timeZone); | ||
String getTimezone(); | ||
void update(); | ||
String getFormattedTime(); | ||
|
||
char *getHour(const char *format); | ||
char *getMinute(const char *format); | ||
int getHour(); | ||
int getMinute(); | ||
int getSecond(); | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
#ifndef IClockface_h | ||
#define IClockface_h | ||
|
||
#include "DateTime.h" | ||
#include "CWDateTime.h" | ||
|
||
class IClockface { | ||
|
||
//virtual void setup(DateTime *dateTime) = 0; | ||
virtual void setup(DateTime *dateTime) = 0; | ||
virtual void setup(CWDateTime *dateTime) = 0; | ||
virtual void update() = 0; | ||
|
||
}; | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters