Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions esp8266-weather-station-color.ino
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,21 @@ void drawTime() {

gfx.setFont(ArialRoundedMTBold_36);

if (IS_STYLE_12HR) {
if (IS_STYLE_12HR) { //12:00
int hour = (timeinfo->tm_hour + 11) % 12 + 1; // take care of noon and midnight
sprintf(time_str, "%2d:%02d:%02d\n", hour, timeinfo->tm_min, timeinfo->tm_sec);
} else {
sprintf(time_str, "%02d:%02d:%02d\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
if (IS_STYLE_HHMM) {
sprintf(time_str, "%2d:%02d\n", hour, timeinfo->tm_min); //hh:mm
} else {
sprintf(time_str, "%2d:%02d:%02d\n", hour, timeinfo->tm_min, timeinfo->tm_sec); //hh:mm:ss
}
} else { //24:00
if (IS_STYLE_HHMM) {
sprintf(time_str, "%02d:%02d\n", timeinfo->tm_hour, timeinfo->tm_min); //hh:mm
} else {
sprintf(time_str, "%02d:%02d:%02d\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); //hh:mm:ss
}
}

gfx.drawString(120, 20, time_str);

gfx.setTextAlignment(TEXT_ALIGN_LEFT);
Expand Down
3 changes: 3 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ bool IS_METRIC = true;
// Change for 12 Hour/ 24 hour style clock
bool IS_STYLE_12HR = false;

// Change for HH:MM/ HH:MM:SS format clock
bool IS_STYLE_HHMM = false; // true => HH:MM

// change for different NTP (time servers)
#define NTP_SERVERS "pool.ntp.org"
// #define NTP_SERVERS "us.pool.ntp.org", "time.nist.gov", "pool.ntp.org"
Expand Down