Actually bother implementing Fahrenheit

This commit is contained in:
XANTRONIX Development 2024-01-18 20:50:08 -05:00
parent b63ab8bf7b
commit 742a0ef6bb

View file

@ -18,9 +18,18 @@
#define COLD_THRESHOLD 4.0 /* °C */ #define COLD_THRESHOLD 4.0 /* °C */
static ssize_t format_text(hexagram_text *text, char *buf, size_t len) { 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; 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) { static int draw_fg(hexagram_gauge *gauge, cairo_t *cr) {