fix(color): Don't trigger RTC write every second, update all fields (#2867)
Also all fields should be updated, not just the seconds
This commit is contained in:
@@ -48,14 +48,32 @@ class DateTimeWindow : public FormGroup {
|
|||||||
{
|
{
|
||||||
FormGroup::checkEvents();
|
FormGroup::checkEvents();
|
||||||
|
|
||||||
if (get_tmr10ms() - lastRefresh > 100) {
|
if (get_tmr10ms() - lastRefresh >= 10) {
|
||||||
seconds->setValue(seconds->getValue());
|
struct gtm newTS;
|
||||||
lastRefresh = get_tmr10ms();
|
lastRefresh = get_tmr10ms();
|
||||||
|
|
||||||
|
gettime(&newTS);
|
||||||
|
if(newTS.tm_sec == lastSecond)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lastSecond = newTS.tm_sec;
|
||||||
|
year->update();
|
||||||
|
month->update();
|
||||||
|
day->update();
|
||||||
|
hour->update();
|
||||||
|
minutes->update();
|
||||||
|
seconds->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
tmr10ms_t lastRefresh = 0;
|
tmr10ms_t lastRefresh = 0;
|
||||||
|
int8_t lastSecond;
|
||||||
|
NumberEdit* year = nullptr;
|
||||||
|
NumberEdit* month = nullptr;
|
||||||
|
NumberEdit* day = nullptr;
|
||||||
|
NumberEdit* hour = nullptr;
|
||||||
|
NumberEdit* minutes = nullptr;
|
||||||
NumberEdit* seconds = nullptr;
|
NumberEdit* seconds = nullptr;
|
||||||
|
|
||||||
void build()
|
void build()
|
||||||
@@ -66,7 +84,7 @@ class DateTimeWindow : public FormGroup {
|
|||||||
auto line = newLine(&grid);
|
auto line = newLine(&grid);
|
||||||
// Date
|
// Date
|
||||||
new StaticText(line, rect_t{}, STR_DATE, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(line, rect_t{}, STR_DATE, 0, COLOR_THEME_PRIMARY1);
|
||||||
auto year = new NumberEdit(line, rect_t{}, 2018, 2100,
|
year = new NumberEdit(line, rect_t{}, 2018, 2100,
|
||||||
[=]() -> int32_t {
|
[=]() -> int32_t {
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
@@ -79,7 +97,7 @@ class DateTimeWindow : public FormGroup {
|
|||||||
SET_LOAD_DATETIME(&t);
|
SET_LOAD_DATETIME(&t);
|
||||||
});
|
});
|
||||||
lv_obj_set_style_grid_cell_x_align(year->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
lv_obj_set_style_grid_cell_x_align(year->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
||||||
auto month = new NumberEdit(line, rect_t{}, 1, 12,
|
month = new NumberEdit(line, rect_t{}, 1, 12,
|
||||||
[=]() -> int32_t {
|
[=]() -> int32_t {
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
@@ -102,7 +120,7 @@ class DateTimeWindow : public FormGroup {
|
|||||||
static const pm_uint8_t dmon[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
static const pm_uint8_t dmon[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
dlim += *(&dmon[t.tm_mon]);*/
|
dlim += *(&dmon[t.tm_mon]);*/
|
||||||
int8_t dlim = 31;
|
int8_t dlim = 31;
|
||||||
auto day = new NumberEdit(line, rect_t{}, 1, dlim,
|
day = new NumberEdit(line, rect_t{}, 1, dlim,
|
||||||
[=]() -> int32_t {
|
[=]() -> int32_t {
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
@@ -122,7 +140,7 @@ class DateTimeWindow : public FormGroup {
|
|||||||
|
|
||||||
// Time
|
// Time
|
||||||
new StaticText(line, rect_t{}, STR_TIME, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(line, rect_t{}, STR_TIME, 0, COLOR_THEME_PRIMARY1);
|
||||||
auto hour = new NumberEdit(line, rect_t{}, 0, 24,
|
hour = new NumberEdit(line, rect_t{}, 0, 24,
|
||||||
[=]() -> int32_t {
|
[=]() -> int32_t {
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
@@ -142,7 +160,7 @@ class DateTimeWindow : public FormGroup {
|
|||||||
});
|
});
|
||||||
lv_obj_set_style_grid_cell_x_align(hour->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
lv_obj_set_style_grid_cell_x_align(hour->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
|
||||||
|
|
||||||
auto minutes = new NumberEdit(line, rect_t{}, 0, 59,
|
minutes = new NumberEdit(line, rect_t{}, 0, 59,
|
||||||
[=]() -> int32_t {
|
[=]() -> int32_t {
|
||||||
struct gtm t;
|
struct gtm t;
|
||||||
gettime(&t);
|
gettime(&t);
|
||||||
|
|||||||
Reference in New Issue
Block a user