CPU: add new option --cpu-freq-ndigits

Fix #578
This commit is contained in:
李通洲
2023-10-08 10:09:56 +08:00
parent 4c9d9f6223
commit 78249bf4f7
5 changed files with 28 additions and 5 deletions
+1
View File
@@ -3,6 +3,7 @@
Features:
* Support opkg (Packages, Linux)
* Support GNOME Console terminal version and font detection (Terminal, Linux)
* Add `--cpu-freq-ndigits` to set number of digits for CPU frequency (CPU)
Bugfixes:
* Fix possible crashes on Windows 7 (Disk, Windows)
+7
View File
@@ -737,6 +737,13 @@
"type": "boolean",
"default": false
},
"freqNdigits": {
"title": "Set the number of digits to keep after the decimal point when printing CPU frequency",
"type": "integer",
"minimum": 0,
"maximum": 9,
"default": 2
},
"key": {
"$ref": "#/$defs/key"
},
+5 -4
View File
@@ -138,11 +138,12 @@ Module specific options:
--display-precise-refresh-rate: <?value>:Set if decimal refresh rates should not be rounded into integers when printing. Default is true
--sound-type: <value>: Set what type of sound devices should be printed. Should be either main, active or all. Default is main
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
--cpu-freq-ndigits <num>: Set the number of digits to keep after the decimal point when printing CPU frequency. Default is 2
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
--gpu-hide-type <?value>: Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--localip-show-ipv4 <?value>: Show IPv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show IPv6 addresses in local ip module. Default is false
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
+14 -1
View File
@@ -48,7 +48,7 @@ void ffPrintCPU(FFCPUOptions* options)
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
if(cpu.frequencyMax > 0.0)
ffStrbufAppendF(&str, " @ %.9g GHz", cpu.frequencyMax);
ffStrbufAppendF(&str, " @ %.*f GHz", options->freqNdigits, cpu.frequencyMax);
if(cpu.temperature == cpu.temperature) //FF_CPU_TEMP_UNSET
{
@@ -82,6 +82,7 @@ void ffInitCPUOptions(FFCPUOptions* options)
ffOptionInitModuleBaseInfo(&options->moduleInfo, FF_CPU_MODULE_NAME, ffParseCPUCommandOptions, ffParseCPUJsonObject, ffPrintCPU, ffGenerateCPUJson, ffPrintCPUHelpFormat);
ffOptionInitModuleArg(&options->moduleArgs);
options->temp = false;
options->freqNdigits = 2;
}
bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value)
@@ -97,6 +98,12 @@ bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char
return true;
}
if (ffStrEqualsIgnCase(subKey, "freq-ndigits"))
{
options->freqNdigits = (uint8_t) ffOptionParseUInt32(key, value);
return true;
}
return false;
}
@@ -124,6 +131,12 @@ void ffParseCPUJsonObject(FFCPUOptions* options, yyjson_val* module)
continue;
}
if (ffStrEqualsIgnCase(key, "freqNdigits"))
{
options->freqNdigits = (uint8_t) yyjson_get_uint(val);
continue;
}
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
+1
View File
@@ -10,4 +10,5 @@ typedef struct FFCPUOptions
FFModuleArgs moduleArgs;
bool temp;
uint8_t freqNdigits;
} FFCPUOptions;