Skip to content

Commit

Permalink
Moved date format to user settings files
Browse files Browse the repository at this point in the history
  • Loading branch information
NC22 committed Aug 15, 2024
1 parent 2d43573 commit ab972ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Volna42/src/Env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void Env::initDefaultTime() {
t = mktime(&tm);
defaultTime = t;
Serial.println(F("Default time reassigned by user config"));
Serial.println(defaultTime);
// Serial.println(defaultTime);
}

} else {
Expand Down Expand Up @@ -1492,10 +1492,12 @@ void Env::updateTime(time_t dt) {
String tmp = "";
int tmpN;

strftime(buffer, sizeof(buffer), "%d.%m.%y", &stnow);
tmp = FPSTR(longDateFormat);
strftime(buffer, sizeof(buffer), tmp.c_str(), &stnow);
fTime.date = buffer;

strftime(buffer, sizeof(buffer), "%d.%m.%Y", &stnow);
tmp = FPSTR(shortDateFormat);
strftime(buffer, sizeof(buffer), tmp.c_str(), &stnow);
fTime.dateShort = buffer;

strftime(buffer, sizeof(buffer), "%H:%M:%S", &stnow);
Expand Down Expand Up @@ -1594,7 +1596,11 @@ void Env::updateTime(time_t dt) {

strftime(buffer, sizeof(buffer), "%d", &stnow);
tmp = buffer;
fTime.monthText = tmp + " " + fTime.monthText;
if (pgm_read_byte(&textDateFormat) == 0) {
fTime.monthText = tmp + " " + fTime.monthText;
} else if (pgm_read_byte(&textDateFormat) == 1) {
fTime.monthText = fTime.monthText + " " + tmp;
}

strftime(buffer, sizeof(buffer), "%H", &stnow);
tmp = buffer;
Expand Down
4 changes: 4 additions & 0 deletions Volna42/src/Env.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ extern const size_t widgetsDefaultsSize PROGMEM;
extern const uint8_t cfgCelsius PROGMEM;
extern const uint8_t cfg12HourFormat PROGMEM;

extern const uint8_t textDateFormat PROGMEM;
extern const char longDateFormat[] PROGMEM;
extern const char shortDateFormat[] PROGMEM;

typedef struct {

unsigned int size;
Expand Down
5 changes: 5 additions & 0 deletions Volna42/src/UserSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const char productVersion[] PROGMEM = "0.88";
const char defaultWifiAP[] PROGMEM = "VOLNA42-EINK"; // SSIDs can reach up to 32 characters in length
const char defaultWifiAPP[] PROGMEM = "volnaaccess"; // A Valid Password is 8 - 63 Characters long


const char shortDateFormat[] PROGMEM = "%d.%m.%y"; // date & time string date part format for 1.54'
const char longDateFormat[] PROGMEM = "%d.%m.%y"; // Date string format (2-string of [Clock & Date widget] used in 4.2')

const uint8_t textDateFormat PROGMEM = 0; // Short text date format : 0 - [15 August, Thu], 1 - [August 15, Thu] (3-string of [Clock & Date widget] used in 4.2')
const uint8_t cfgCelsius PROGMEM = 1; // 0-1 | Use Celsius instead of Fahrenheit by default
const uint8_t cfg12HourFormat PROGMEM = 0; // 0-1 | Use 12 hour PM / AM clock format by default

Expand Down

0 comments on commit ab972ec

Please sign in to comment.