always display frequency in MHz

This commit is contained in:
Redha Gouicem 2020-08-28 12:15:32 +02:00
parent 2d14269bcd
commit 3ef5df25bc
1 changed files with 1 additions and 6 deletions

View File

@ -65,18 +65,13 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT); memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT);
double percent = Platform_setCPUValues(this, cpu); double percent = Platform_setCPUValues(this, cpu);
if (this->pl->settings->showCPUFrequency) { if (this->pl->settings->showCPUFrequency) {
/* Initial frequency is in MHz. Emit it as GHz if it's larger than 1000MHz */
double cpuFrequency = this->values[CPU_METER_FREQUENCY]; double cpuFrequency = this->values[CPU_METER_FREQUENCY];
char unit = 'M'; char unit = 'M';
char cpuFrequencyBuffer[16]; char cpuFrequencyBuffer[16];
if (cpuFrequency < 0) { if (cpuFrequency < 0) {
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A"); xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
} else { } else {
if (cpuFrequency > 1000) { xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0f%cHz", cpuFrequency, unit);
cpuFrequency /= 1000;
unit = 'G';
}
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.3f%cHz", cpuFrequency, unit);
} }
if (this->pl->settings->showCPUUsage) { if (this->pl->settings->showCPUUsage) {
xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer); xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer);