summaryrefslogtreecommitdiffstats
path: root/CPUMeter.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-09-22 14:50:50 +0200
committercgzones <cgzones@googlemail.com>2020-09-24 20:11:28 +0200
commitedf1b10d2c3fa94c23a23cfc947490cf1ebf66d1 (patch)
tree09571af36c5d969795a188604db164bfce1fd3cd /CPUMeter.c
parentf4e1f4619f3761382d5e97ddf92237085a7bd443 (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.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/CPUMeter.c b/CPUMeter.c
index badca940..482565ee 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy