Skip to content

Commit 64c4446

Browse files
committed
Adjust LoadAverageMeter "total" assignment
The meter now has a dynamic scale, and so the "total" value can be updated automatically by the bar meter drawing code. The initial "total" value for LoadAverageMeter is now always the number of active CPUs (processor threads). Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent 6a2df7b commit 64c4446

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

LoadAverageMeter.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ static void LoadAverageMeter_updateValues(Meter* this) {
4646
this->curItems = 1;
4747

4848
// change bar color and total based on value
49+
if (this->total < this->host->activeCPUs) {
50+
this->total = this->host->activeCPUs;
51+
}
4952
if (this->values[0] < 1.0) {
5053
this->curAttributes = OK_attributes;
51-
this->total = 1.0;
5254
} else if (this->values[0] < this->host->activeCPUs) {
5355
this->curAttributes = Medium_attributes;
54-
this->total = this->host->activeCPUs;
5556
} else {
5657
this->curAttributes = High_attributes;
57-
this->total = 2 * this->host->activeCPUs;
5858
}
5959

6060
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.2f/%.2f/%.2f", this->values[0], this->values[1], this->values[2]);
@@ -78,15 +78,15 @@ static void LoadMeter_updateValues(Meter* this) {
7878
Platform_getLoadAverage(&this->values[0], &five, &fifteen);
7979

8080
// change bar color and total based on value
81+
if (this->total < this->host->activeCPUs) {
82+
this->total = this->host->activeCPUs;
83+
}
8184
if (this->values[0] < 1.0) {
8285
this->curAttributes = OK_attributes;
83-
this->total = 1.0;
8486
} else if (this->values[0] < this->host->activeCPUs) {
8587
this->curAttributes = Medium_attributes;
86-
this->total = this->host->activeCPUs;
8788
} else {
8889
this->curAttributes = High_attributes;
89-
this->total = 2 * this->host->activeCPUs;
9090
}
9191

9292
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.2f", this->values[0]);
@@ -112,7 +112,7 @@ const MeterClass LoadAverageMeter_class = {
112112
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
113113
.maxItems = 3,
114114
.isPercentChart = false,
115-
.total = 100.0,
115+
.total = 1.0,
116116
.attributes = LoadAverageMeter_attributes,
117117
.name = "LoadAverage",
118118
.uiName = "Load average",
@@ -131,7 +131,7 @@ const MeterClass LoadMeter_class = {
131131
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
132132
.maxItems = 1,
133133
.isPercentChart = false,
134-
.total = 100.0,
134+
.total = 1.0,
135135
.attributes = LoadMeter_attributes,
136136
.name = "Load",
137137
.uiName = "Load",

0 commit comments

Comments
 (0)