summaryrefslogtreecommitdiff
path: root/src/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/text.c b/src/text.c
index df3b3c4..ece25d5 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1,5 +1,7 @@
#include "text.h"
+#include "signal.h"
+
#include "modules/pulse.h"
#include "modules/time.h"
#include "modules/battery.h"
@@ -17,6 +19,8 @@ text_new()
memset(t->value, '\0', TEXT_SIZE);
+ t->last_update = 0;
+
t->battery = battery_new();
t->time = time_new();
t->pulse = pulse_new();
@@ -36,9 +40,21 @@ text_free(struct text * t)
void
text_update(struct text * t)
{
+ time_t now_time = time(NULL);
+ double time_diff = difftime(now_time, t->last_update);
+ bool should_update = signal_should_update();
+
+ t->last_update = now_time;
+
time_update(t->time);
- pulse_update(t->pulse);
- battery_update(t->battery);
+
+ if(should_update || time_diff > 3) {
+ pulse_update(t->pulse);
+ }
+
+ if(should_update || time_diff > 5) {
+ battery_update(t->battery);
+ }
snprintf(
t->value, TEXT_SIZE,