Add separate method for setting thermometer units

This commit is contained in:
XANTRONIX Development 2024-01-18 20:49:52 -05:00
parent 06c00208fd
commit b63ab8bf7b
3 changed files with 12 additions and 7 deletions

View file

@ -19,8 +19,9 @@ typedef struct _hexagram_temp {
int hexagram_temp_init(hexagram_temp *temp, int hexagram_temp_init(hexagram_temp *temp,
double x, double x,
double y, double y,
hexagram_text_align align, hexagram_text_align align);
hexagram_temp_units units);
void hexagram_temp_set_units(hexagram_temp *temp, hexagram_temp_units units);
void hexagram_temp_cleanup(hexagram_temp *temp); void hexagram_temp_cleanup(hexagram_temp *temp);

View file

@ -149,8 +149,7 @@ int hexagram_cluster_init(hexagram_cluster *cluster) {
if (hexagram_temp_init(&cluster->temp, if (hexagram_temp_init(&cluster->temp,
CLUSTER_WIDTH - 0.8 * CLUSTER_HEIGHT, CLUSTER_WIDTH - 0.8 * CLUSTER_HEIGHT,
CLUSTER_HEIGHT - (SECTION_HEIGHT_BOTTOM - HEXAGRAM_TEXT_FONT_SIZE) / 2, CLUSTER_HEIGHT - (SECTION_HEIGHT_BOTTOM - HEXAGRAM_TEXT_FONT_SIZE) / 2,
HEXAGRAM_TEXT_RIGHT, HEXAGRAM_TEXT_RIGHT) < 0) {
HEXAGRAM_TEMP_CELSIUS) < 0) {
goto error_temp_init; goto error_temp_init;
} }

View file

@ -5,6 +5,8 @@
#include <hexagram/temp.h> #include <hexagram/temp.h>
#include <hexagram/status.h> #include <hexagram/status.h>
#define DEFAULT_UNITS HEXAGRAM_TEMP_CELSIUS
#define ICON_ID HEXAGRAM_STATUS_COLD #define ICON_ID HEXAGRAM_STATUS_COLD
#define ICON_NAME "cold" #define ICON_NAME "cold"
#define ICON_STYLE "path {stroke: %1$s; stroke-width: 8}" #define ICON_STYLE "path {stroke: %1$s; stroke-width: 8}"
@ -80,8 +82,7 @@ error_format_text:
int hexagram_temp_init(hexagram_temp *temp, int hexagram_temp_init(hexagram_temp *temp,
double x, double x,
double y, double y,
hexagram_text_align align, hexagram_text_align align) {
hexagram_temp_units units) {
if (hexagram_text_init(&temp->text, if (hexagram_text_init(&temp->text,
x, x,
y, y,
@ -102,7 +103,7 @@ int hexagram_temp_init(hexagram_temp *temp,
goto error_icon_init; goto error_icon_init;
} }
temp->units = units; temp->units = DEFAULT_UNITS;
temp->value = 0; temp->value = 0;
return 0; return 0;
@ -112,6 +113,10 @@ error_text_init:
return -1; return -1;
} }
void hexagram_temp_set_units(hexagram_temp *temp, hexagram_temp_units units) {
temp->units = units;
}
void hexagram_temp_cleanup(hexagram_temp *temp) { void hexagram_temp_cleanup(hexagram_temp *temp) {
hexagram_icon_cleanup(&temp->icon); hexagram_icon_cleanup(&temp->icon);
} }