From edf1b10d2c3fa94c23a23cfc947490cf1ebf66d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 22 Sep 2020 14:50:50 +0200 Subject: 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. --- CPUMeter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'CPUMeter.c') 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); -- cgit v1.2.3