Temp: Display: support better temperature value formatting

Fix #737
This commit is contained in:
李通洲
2024-02-26 10:46:13 +08:00
parent 1c87693867
commit a0c47204bb
10 changed files with 227 additions and 51 deletions
+4 -2
View File
@@ -58,13 +58,15 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
{
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false);
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffParseTemperature(result->temperature, &tempStr);
ffPrintFormat(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_BATTERY_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology},
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status},
{FF_FORMAT_ARG_TYPE_DOUBLE, &result->temperature},
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial},
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate},
@@ -226,7 +228,7 @@ void ffPrintBatteryHelpFormat(void)
"Battery technology",
"Battery capacity (percentage)",
"Battery status",
"Battery temperature",
"Battery temperature (formatted)",
"Battery cycle count",
"Battery serial number",
"Battery manufactor date",
+4 -2
View File
@@ -60,6 +60,8 @@ void ffPrintCPU(FFCPUOptions* options)
}
else
{
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffParseTemperature(cpu.temperature, &tempStr);
ffPrintFormat(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.name},
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu.vendor},
@@ -68,7 +70,7 @@ void ffPrintCPU(FFCPUOptions* options)
{FF_FORMAT_ARG_TYPE_UINT16, &cpu.coresOnline},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMin},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.frequencyMax},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu.temperature}
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr}
});
}
}
@@ -193,7 +195,7 @@ void ffPrintCPUHelpFormat(void)
"Online core count",
"Min frequency",
"Max frequency",
"Temperature"
"Temperature (formatted)"
});
}
+3 -1
View File
@@ -72,11 +72,13 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
}
else
{
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffParseTemperature(gpu->temperature, &tempStr);
ffPrintFormat(FF_GPU_MODULE_NAME, index, &options->moduleArgs, FF_GPU_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &gpu->driver},
{FF_FORMAT_ARG_TYPE_DOUBLE, &gpu->temperature},
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr},
{FF_FORMAT_ARG_TYPE_INT, &gpu->coreCount},
{FF_FORMAT_ARG_TYPE_STRING, type},
{FF_FORMAT_ARG_TYPE_UINT64, &gpu->dedicated.total},
+4 -2
View File
@@ -102,6 +102,8 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
}
else
{
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
ffParseTemperature(dev->temperature, &tempStr);
if (dev->type & FF_PHYSICALDISK_TYPE_READWRITE)
readOnlyType = "Read-write";
ffParseSize(dev->size, &buffer);
@@ -115,7 +117,7 @@ void ffPrintPhysicalDisk(FFPhysicalDiskOptions* options)
{FF_FORMAT_ARG_TYPE_STRING, removableType},
{FF_FORMAT_ARG_TYPE_STRING, readOnlyType},
{FF_FORMAT_ARG_TYPE_STRBUF, &dev->revision},
{FF_FORMAT_ARG_TYPE_DOUBLE, &dev->temperature},
{FF_FORMAT_ARG_TYPE_DOUBLE, &tempStr},
});
}
++index;
@@ -263,7 +265,7 @@ void ffPrintPhysicalDiskHelpFormat(void)
"Device kind (Removable or Fixed)",
"Device kind (Read-only or Read-write)",
"Product revision",
"Device temperature",
"Device temperature (formatted)",
});
}