CPUMeter: show if a CPU is offline in text mode

Related to #729 as the text mode displays all zero values for offline
CPUs.
This commit is contained in:
Christian Göttsche 2021-08-10 17:08:48 +02:00
parent 671282d309
commit ba5ef1ac8b
1 changed files with 7 additions and 1 deletions

View File

@ -116,9 +116,15 @@ static void CPUMeter_display(const Object* cast, RichString* out) {
const Meter* this = (const Meter*)cast;
if (this->param > this->pl->existingCPUs) {
RichString_appendAscii(out, CRT_colors[METER_TEXT], "absent");
RichString_appendAscii(out, CRT_colors[METER_SHADOW], " absent");
return;
}
if (this->curItems == 0) {
RichString_appendAscii(out, CRT_colors[METER_SHADOW], " offline");
return;
}
len = xSnprintf(buffer, sizeof(buffer), "%5.1f%% ", this->values[CPU_METER_NORMAL]);
RichString_appendAscii(out, CRT_colors[METER_TEXT], ":");
RichString_appendnAscii(out, CRT_colors[CPU_NORMAL], buffer, len);