From 742a0ef6bb05e856e2f7dc682d2568438f4dcfba Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Thu, 18 Jan 2024 20:50:08 -0500 Subject: [PATCH] Actually bother implementing Fahrenheit --- src/temp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/temp.c b/src/temp.c index addc8ba..8eb2ae4 100644 --- a/src/temp.c +++ b/src/temp.c @@ -18,9 +18,18 @@ #define COLD_THRESHOLD 4.0 /* °C */ static ssize_t format_text(hexagram_text *text, char *buf, size_t len) { + const char *formats[2] = { + "%.1f°C", + "%.1f°F" + }; + hexagram_temp *temp = (hexagram_temp *)text; - return snprintf(buf, len, "%.1f°C", temp->value); + double value = temp->units == HEXAGRAM_TEMP_CELSIUS? + temp->value: + temp->value * (9.0 / 5.0) + 32; + + return snprintf(buf, len, formats[temp->units], value); } static int draw_fg(hexagram_gauge *gauge, cairo_t *cr) {