Temps: rename display.temperature to display.temp

This commit is contained in:
李通洲
2024-02-27 13:11:39 +08:00
parent ba60d9059f
commit 5147651bcb
6 changed files with 45 additions and 45 deletions
+3 -3
View File
@@ -1,15 +1,15 @@
# 2.8.6
Changes:
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temperature": { "unit": "C" } }`
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temp": { "unit": "C" } }`
Bugfixes:
* Fix incorrect GPU name detection for Intel iGPU on Linux (#736, GPU, Linux)
Features:
* Support additional temperature formatting options (#737)
* `{ "temperature": { "ndigits": 1 } }`
* `{ "temperature": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
* `{ "temp": { "ndigits": 1 } }`
* `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
# 2.8.5
+4 -4
View File
@@ -59,13 +59,13 @@
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Value less then green will be shown in green"
"description": "Value (in celsius) less then green will be shown in green"
},
"yellow": {
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Value greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
"description": "Value (in celsius) greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
}
}
}
@@ -433,9 +433,9 @@
}
}
},
"temperature": {
"temp": {
"type": "object",
"description": "Set how a temperature value should be displayed",
"description": "Set how temperature values should be displayed",
"properties": {
"unit": {
"type": "string",
+6 -6
View File
@@ -9,9 +9,9 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
return;
const FFOptionsDisplay* options = &instance.config.display;
const char* colorGreen = options->temperatureColorGreen.chars;
const char* colorYellow = options->temperatureColorYellow.chars;
const char* colorRed = options->temperatureColorRed.chars;
const char* colorGreen = options->tempColorGreen.chars;
const char* colorYellow = options->tempColorYellow.chars;
const char* colorRed = options->tempColorRed.chars;
uint8_t green = config.green, yellow = config.yellow;
@@ -40,13 +40,13 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
switch (options->temperatureUnit)
{
case FF_TEMPERATURE_UNIT_CELSIUS:
ffStrbufAppendF(buffer, "%.*f°C", options->temperatureNdigits, celsius);
ffStrbufAppendF(buffer, "%.*f°C", options->tempNdigits, celsius);
break;
case FF_TEMPERATURE_UNIT_FAHRENHEIT:
ffStrbufAppendF(buffer, "%.*f°F", options->temperatureNdigits, celsius * 1.8 + 32);
ffStrbufAppendF(buffer, "%.*f°F", options->tempNdigits, celsius * 1.8 + 32);
break;
case FF_TEMPERATURE_UNIT_KELVIN:
ffStrbufAppendF(buffer, "%.*f K", options->temperatureNdigits, celsius + 273.15);
ffStrbufAppendF(buffer, "%.*f K", options->tempNdigits, celsius + 273.15);
break;
}
+5 -5
View File
@@ -656,7 +656,7 @@
}
},
{
"long": "temperature-unit",
"long": "temp-unit",
"desc": "Set the unit of the temperature",
"arg": {
"type": "enum",
@@ -669,7 +669,7 @@
}
},
{
"long": "temperature-ndigits",
"long": "temp-ndigits",
"desc": "Set the number of digits to keep after the decimal point when printing temperature",
"arg": {
"type": "num",
@@ -677,7 +677,7 @@
}
},
{
"long": "temperature-color-green",
"long": "temp-color-green",
"desc": "Set color used in green state of temperature values",
"remark": "See `-h color` for the list of available colors",
"arg": {
@@ -686,7 +686,7 @@
}
},
{
"long": "temperature-color-yellow",
"long": "temp-color-yellow",
"desc": "Set color used in yellow state of temperature values",
"remark": "See `-h color` for the list of available colors",
"arg": {
@@ -695,7 +695,7 @@
}
},
{
"long": "temperature-color-red",
"long": "temp-color-red",
"desc": "Set color used in red state of temperature values",
"remark": "See `-h color` for the list of available colors",
"arg": {
+23 -23
View File
@@ -94,10 +94,10 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
yyjson_val* ndigits = yyjson_obj_get(val, "ndigits");
if (ndigits) options->percentNdigits = (uint8_t) yyjson_get_uint(ndigits);
}
else if (ffStrEqualsIgnCase(key, "temperature"))
else if (ffStrEqualsIgnCase(key, "temp"))
{
if (!yyjson_is_obj(val))
return "display.temperature must be an object";
return "display.temp must be an object";
yyjson_val* unit = yyjson_obj_get(val, "unit");
if (unit)
@@ -117,7 +117,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
}
yyjson_val* ndigits = yyjson_obj_get(val, "ndigits");
if (ndigits) options->temperatureNdigits = (uint8_t) yyjson_get_uint(ndigits);
if (ndigits) options->tempNdigits = (uint8_t) yyjson_get_uint(ndigits);
yyjson_val* color = yyjson_obj_get(val, "color");
if (color)
@@ -126,13 +126,13 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
return "display.temperature.color must be an object";
yyjson_val* green = yyjson_obj_get(color, "green");
if (green) ffOptionParseColor(yyjson_get_str(green), &options->temperatureColorGreen);
if (green) ffOptionParseColor(yyjson_get_str(green), &options->tempColorGreen);
yyjson_val* yellow = yyjson_obj_get(color, "yellow");
if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->temperatureColorYellow);
if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->tempColorYellow);
yyjson_val* red = yyjson_obj_get(color, "red");
if (red) ffOptionParseColor(yyjson_get_str(red), &options->temperatureColorRed);
if (red) ffOptionParseColor(yyjson_get_str(red), &options->tempColorRed);
}
}
else if (ffStrEqualsIgnCase(key, "percent"))
@@ -295,13 +295,13 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
});
}
else if (ffStrEqualsIgnCase(subkey, "ndigits"))
options->temperatureNdigits = (uint8_t) ffOptionParseUInt32(key, value);
options->tempNdigits = (uint8_t) ffOptionParseUInt32(key, value);
else if(ffStrEqualsIgnCase(subkey, "color-green"))
ffOptionParseColor(value, &options->temperatureColorGreen);
ffOptionParseColor(value, &options->tempColorGreen);
else if(ffStrEqualsIgnCase(subkey, "color-yellow"))
ffOptionParseColor(value, &options->temperatureColorYellow);
ffOptionParseColor(value, &options->tempColorYellow);
else if(ffStrEqualsIgnCase(subkey, "color-red"))
ffOptionParseColor(value, &options->temperatureColorRed);
ffOptionParseColor(value, &options->tempColorRed);
else
return false;
}
@@ -368,10 +368,10 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
options->keyWidth = 0;
options->temperatureUnit = FF_TEMPERATURE_UNIT_CELSIUS;
options->temperatureNdigits = 1;
ffStrbufInitStatic(&options->temperatureColorGreen, FF_COLOR_FG_GREEN);
ffStrbufInitStatic(&options->temperatureColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->temperatureColorRed, FF_COLOR_FG_LIGHT_RED);
options->tempNdigits = 1;
ffStrbufInitStatic(&options->tempColorGreen, FF_COLOR_FG_GREEN);
ffStrbufInitStatic(&options->tempColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
ffStrbufInitStatic(&options->tempColorRed, FF_COLOR_FG_LIGHT_RED);
ffStrbufInitStatic(&options->barCharElapsed, "");
ffStrbufInitStatic(&options->barCharTotal, "-");
@@ -492,21 +492,21 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
break;
}
}
if (options->temperatureNdigits != defaultOptions.temperatureNdigits)
yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->temperatureNdigits);
if (options->tempNdigits != defaultOptions.tempNdigits)
yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->tempNdigits);
{
yyjson_mut_val* color = yyjson_mut_obj(doc);
if (!ffStrbufEqual(&options->temperatureColorGreen, &defaultOptions.temperatureColorGreen))
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->temperatureColorGreen);
if (!ffStrbufEqual(&options->temperatureColorYellow, &defaultOptions.temperatureColorYellow))
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->temperatureColorYellow);
if (!ffStrbufEqual(&options->temperatureColorRed, &defaultOptions.temperatureColorRed))
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->temperatureColorRed);
if (!ffStrbufEqual(&options->tempColorGreen, &defaultOptions.tempColorGreen))
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->tempColorGreen);
if (!ffStrbufEqual(&options->tempColorYellow, &defaultOptions.tempColorYellow))
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->tempColorYellow);
if (!ffStrbufEqual(&options->tempColorRed, &defaultOptions.tempColorRed))
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->tempColorRed);
if (yyjson_mut_obj_size(color) > 0)
yyjson_mut_obj_add_val(doc, temperature, "color", color);
}
if (yyjson_mut_obj_size(temperature) > 0)
yyjson_mut_obj_add_val(doc, obj, "temperature", temperature);
yyjson_mut_obj_add_val(doc, obj, "temp", temperature);
}
{
+4 -4
View File
@@ -35,10 +35,10 @@ typedef struct FFOptionsDisplay
uint8_t sizeNdigits;
uint8_t sizeMaxPrefix;
FFTemperatureUnit temperatureUnit;
uint8_t temperatureNdigits;
FFstrbuf temperatureColorGreen;
FFstrbuf temperatureColorYellow;
FFstrbuf temperatureColorRed;
uint8_t tempNdigits;
FFstrbuf tempColorGreen;
FFstrbuf tempColorYellow;
FFstrbuf tempColorRed;
FFstrbuf barCharElapsed;
FFstrbuf barCharTotal;
uint8_t barWidth;