diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-09-22 14:50:50 +0200 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-09-24 20:11:28 +0200 |
commit | edf1b10d2c3fa94c23a23cfc947490cf1ebf66d1 (patch) | |
tree | 09571af36c5d969795a188604db164bfce1fd3cd /CPUMeter.c | |
parent | f4e1f4619f3761382d5e97ddf92237085a7bd443 (diff) |
Read CPU frequency from sysfs by default
Use the more portable sysfs node /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq
to get the CPU frequency.
In case of an error fall back to /proc/cpuinfo .
Also use a fixed width of 4 for the frequency to avoid position jumps
in case the frequency moves in the range 900-1100 MHz.
Diffstat (limited to 'CPUMeter.c')
-rw-r--r-- | CPUMeter.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -45,7 +45,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) { if (isnan(cpuFrequency)) { xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A"); } else { - xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency); + xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%4uMHz", (unsigned)cpuFrequency); } if (this->pl->settings->showCPUUsage) { xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer); |