Actually bother implementing Fahrenheit
This commit is contained in:
parent
b63ab8bf7b
commit
742a0ef6bb
1 changed files with 10 additions and 1 deletions
11
src/temp.c
11
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue