summaryrefslogtreecommitdiff
path: root/src/text.c
blob: df3b3c434682ad84e4c912ad9110e06a2f111565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}