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) {