Skip to content

Commit dee6931

Browse files
Explorer09BenBE
andcommitted
Restrict time-related meters to textual display (Text+LED mode)
This disables graphing and bar mode display for: * ClockMeter * DateMeter * DateTimeMeter * UptimeMeter Co-authored-by: Benny Baumann <BenBE@geshi.org> Co-authored-by: Kang-Che Sung <explorer09@gmail.com>
1 parent b131dd8 commit dee6931

File tree

4 files changed

+13
-27
lines changed

4 files changed

+13
-27
lines changed

ClockMeter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static void ClockMeter_updateValues(Meter* this) {
2626

2727
struct tm result;
2828
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
29-
this->values[0] = lt->tm_hour * 60 + lt->tm_min;
3029
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt);
3130
}
3231

@@ -37,8 +36,9 @@ const MeterClass ClockMeter_class = {
3736
},
3837
.updateValues = ClockMeter_updateValues,
3938
.defaultMode = TEXT_METERMODE,
40-
.maxItems = 1,
41-
.total = 1440, /* 24*60 */
39+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
40+
.maxItems = 0,
41+
.total = 0.0,
4242
.attributes = ClockMeter_attributes,
4343
.name = "Clock",
4444
.uiName = "Clock",

DateMeter.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ static void DateMeter_updateValues(Meter* this) {
2626

2727
struct tm result;
2828
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
29-
this->values[0] = lt->tm_yday;
30-
int year = lt->tm_year + 1900;
31-
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
32-
this->total = 366;
33-
} else {
34-
this->total = 365;
35-
}
3629
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
3730
}
3831

@@ -43,8 +36,9 @@ const MeterClass DateMeter_class = {
4336
},
4437
.updateValues = DateMeter_updateValues,
4538
.defaultMode = TEXT_METERMODE,
46-
.maxItems = 1,
47-
.total = 365,
39+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
40+
.maxItems = 0,
41+
.total = 0.0,
4842
.attributes = DateMeter_attributes,
4943
.name = "Date",
5044
.uiName = "Date",

DateTimeMeter.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ static void DateTimeMeter_updateValues(Meter* this) {
2626

2727
struct tm result;
2828
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
29-
int year = lt->tm_year + 1900;
30-
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
31-
this->total = 366;
32-
} else {
33-
this->total = 365;
34-
}
35-
this->values[0] = lt->tm_yday;
3629
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
3730
}
3831

@@ -43,8 +36,9 @@ const MeterClass DateTimeMeter_class = {
4336
},
4437
.updateValues = DateTimeMeter_updateValues,
4538
.defaultMode = TEXT_METERMODE,
46-
.maxItems = 1,
47-
.total = 365,
39+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
40+
.maxItems = 0,
41+
.total = 0.0,
4842
.attributes = DateTimeMeter_attributes,
4943
.name = "DateTime",
5044
.uiName = "Date and Time",

UptimeMeter.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ static void UptimeMeter_updateValues(Meter* this) {
2929
int minutes = (totalseconds / 60) % 60;
3030
int hours = (totalseconds / 3600) % 24;
3131
int days = (totalseconds / 86400);
32-
this->values[0] = days;
33-
if (days > this->total) {
34-
this->total = days;
35-
}
32+
3633
char daysbuf[32];
3734
if (days > 100) {
3835
xSnprintf(daysbuf, sizeof(daysbuf), "%d days(!), ", days);
@@ -53,8 +50,9 @@ const MeterClass UptimeMeter_class = {
5350
},
5451
.updateValues = UptimeMeter_updateValues,
5552
.defaultMode = TEXT_METERMODE,
56-
.maxItems = 1,
57-
.total = 100.0,
53+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
54+
.maxItems = 0,
55+
.total = 0.0,
5856
.attributes = UptimeMeter_attributes,
5957
.name = "Uptime",
6058
.uiName = "Uptime",

0 commit comments

Comments
 (0)