ISO datetime for Clock, FileManager, Frequency manager

Added option to show/hide clock (with/without date)
This commit is contained in:
Arjan Onwezen 2021-05-16 11:41:09 +02:00
parent c307e9d5ae
commit 6bc2cbeda9
10 changed files with 114 additions and 41 deletions

View file

@ -410,23 +410,29 @@ void Labels::paint(Painter& painter) {
void LiveDateTime::on_tick_second() {
rtcGetTime(&RTCD1, &datetime);
text = "";
if(date_enabled){
text = to_string_dec_uint(datetime.month(), 2, '0') + "/" + to_string_dec_uint(datetime.day(), 2, '0') + " ";
}
text = text + to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0');
if(!hide_clock) {
if(date_enabled){
text = to_string_dec_uint(datetime.year(), 4, '0') + "-" +
to_string_dec_uint(datetime.month(), 2, '0') + "-" +
to_string_dec_uint(datetime.day(), 2, '0') + " ";
}
else{
text = " ";
}
text = text + to_string_dec_uint(datetime.hour(), 2, '0') + ":" + to_string_dec_uint(datetime.minute(), 2, '0');
if(seconds_enabled){
text += ":";
if(seconds_enabled){
text += ":";
if(init_delay==0)
text += to_string_dec_uint(datetime.second(), 2, '0');
else
{
// Placeholder while the seconds are not updated
text += "XX";
init_delay--;
if(init_delay==0)
text += to_string_dec_uint(datetime.second(), 2, '0');
else
{
// Placeholder while the seconds are not updated
text += "XX";
init_delay--;
}
}
}
set_dirty();
@ -459,6 +465,9 @@ void LiveDateTime::paint(Painter& painter) {
text
);
}
void LiveDateTime::set_hide_clock(bool new_value){
this->hide_clock = new_value;
}
void LiveDateTime::set_date_enabled(bool new_value){
this->date_enabled = new_value;