Add separate method for setting thermometer units
This commit is contained in:
parent
06c00208fd
commit
b63ab8bf7b
3 changed files with 12 additions and 7 deletions
|
@ -19,8 +19,9 @@ typedef struct _hexagram_temp {
|
|||
int hexagram_temp_init(hexagram_temp *temp,
|
||||
double x,
|
||||
double y,
|
||||
hexagram_text_align align,
|
||||
hexagram_temp_units units);
|
||||
hexagram_text_align align);
|
||||
|
||||
void hexagram_temp_set_units(hexagram_temp *temp, hexagram_temp_units units);
|
||||
|
||||
void hexagram_temp_cleanup(hexagram_temp *temp);
|
||||
|
||||
|
|
|
@ -149,8 +149,7 @@ int hexagram_cluster_init(hexagram_cluster *cluster) {
|
|||
if (hexagram_temp_init(&cluster->temp,
|
||||
CLUSTER_WIDTH - 0.8 * CLUSTER_HEIGHT,
|
||||
CLUSTER_HEIGHT - (SECTION_HEIGHT_BOTTOM - HEXAGRAM_TEXT_FONT_SIZE) / 2,
|
||||
HEXAGRAM_TEXT_RIGHT,
|
||||
HEXAGRAM_TEMP_CELSIUS) < 0) {
|
||||
HEXAGRAM_TEXT_RIGHT) < 0) {
|
||||
goto error_temp_init;
|
||||
}
|
||||
|
||||
|
|
11
src/temp.c
11
src/temp.c
|
@ -5,6 +5,8 @@
|
|||
#include <hexagram/temp.h>
|
||||
#include <hexagram/status.h>
|
||||
|
||||
#define DEFAULT_UNITS HEXAGRAM_TEMP_CELSIUS
|
||||
|
||||
#define ICON_ID HEXAGRAM_STATUS_COLD
|
||||
#define ICON_NAME "cold"
|
||||
#define ICON_STYLE "path {stroke: %1$s; stroke-width: 8}"
|
||||
|
@ -80,8 +82,7 @@ error_format_text:
|
|||
int hexagram_temp_init(hexagram_temp *temp,
|
||||
double x,
|
||||
double y,
|
||||
hexagram_text_align align,
|
||||
hexagram_temp_units units) {
|
||||
hexagram_text_align align) {
|
||||
if (hexagram_text_init(&temp->text,
|
||||
x,
|
||||
y,
|
||||
|
@ -102,7 +103,7 @@ int hexagram_temp_init(hexagram_temp *temp,
|
|||
goto error_icon_init;
|
||||
}
|
||||
|
||||
temp->units = units;
|
||||
temp->units = DEFAULT_UNITS;
|
||||
temp->value = 0;
|
||||
|
||||
return 0;
|
||||
|
@ -112,6 +113,10 @@ error_text_init:
|
|||
return -1;
|
||||
}
|
||||
|
||||
void hexagram_temp_set_units(hexagram_temp *temp, hexagram_temp_units units) {
|
||||
temp->units = units;
|
||||
}
|
||||
|
||||
void hexagram_temp_cleanup(hexagram_temp *temp) {
|
||||
hexagram_icon_cleanup(&temp->icon);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue