Fixes Fahrenheit missing conversion when data are JSON-formatted

This commit is contained in:
Samuel FORESTIER committed 2019-08-21 19:20:46 +02:00
1 parent 7478a7da14
commit 10c4f2afdf
1 file changed
+7 -5
+7 -5
View File
@@ -69,6 +69,11 @@ void print_chip_raw(const sensors_chip_name *name)
} }
} }
static inline double deg_ctof(double cel)
{
return cel * (9.0F / 5.0F) + 32.0F;
}
void print_chip_json(const sensors_chip_name *name) void print_chip_json(const sensors_chip_name *name)
{ {
int a, b, cnt, subCnt, err; int a, b, cnt, subCnt, err;
@@ -102,6 +107,8 @@ void print_chip_json(const sensors_chip_name *name)
} else { } else {
if (subCnt > 0) if (subCnt > 0)
printf(",\n"); printf(",\n");
if (fahrenheit)
val = deg_ctof(val);
printf(" \"%s\": %.3f", sub->name, val); printf(" \"%s\": %.3f", sub->name, val);
subCnt++; subCnt++;
} }
@@ -121,11 +128,6 @@ void print_chip_json(const sensors_chip_name *name)
static const char hyst_str[] = "hyst"; static const char hyst_str[] = "hyst";
static inline double deg_ctof(double cel)
{
return cel * (9.0F / 5.0F) + 32.0F;
}
static void print_label(const char *label, int space) static void print_label(const char *label, int space)
{ {
int len = strlen(label)+1; int len = strlen(label)+1;