diff options
| author | Sam Light <sam@lightscale.co.uk> | 2025-09-10 19:37:28 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2025-09-10 19:37:28 +0100 |
| commit | d9b456d738e5013d48f41f5e6315ef7c22d6acf0 (patch) | |
| tree | 2e3722f5697cbf883c4b16edc87726b9e510bce1 /src/text.c | |
Initial commit
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/text.c b/src/text.c new file mode 100644 index 0000000..df3b3c4 --- /dev/null +++ b/src/text.c @@ -0,0 +1,49 @@ +#include "text.h" + +#include "modules/pulse.h" +#include "modules/time.h" +#include "modules/battery.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <tgmath.h> + +struct text * +text_new() +{ + struct text * t = malloc(sizeof(struct text)); + + memset(t->value, '\0', TEXT_SIZE); + + t->battery = battery_new(); + t->time = time_new(); + t->pulse = pulse_new(); + + return t; +} + +void +text_free(struct text * t) +{ + time_free(t->time); + pulse_free(t->pulse); + battery_free(t->battery); + free(t); +} + +void +text_update(struct text * t) +{ + time_update(t->time); + pulse_update(t->pulse); + battery_update(t->battery); + + snprintf( + t->value, TEXT_SIZE, + "VOL: %s | BAT: %s | %s", + t->pulse->value, + t->battery->value, + t->time->value); +} |
