Loading...
Searching...
No Matches
goal_latch.h
Go to the documentation of this file.
1
18#pragma once
19#include <stdint.h>
20
25
37
39#define GOAL_LATCH_BIT(goal) ((uint8_t)(1u << (goal)))
40
44typedef struct
45{
46 int day;
47 uint8_t below;
48 uint8_t met;
49} GoalLatch;
50
51#define GOAL_LATCH_EMPTY {.day = -1}
52
66uint8_t goal_latch_update(GoalLatch *latch, int day, const int readings[GOAL_LATCH_COUNT],
67 const int targets[GOAL_LATCH_COUNT]);
68
uint8_t goal_latch_update(GoalLatch *latch, int day, const int readings[GOAL_LATCH_COUNT], const int targets[GOAL_LATCH_COUNT])
Takes the latest readings and says which goals they just met.
Definition goal_latch.c:9
GoalLatchGoal
The goals the latch watches, in the order it reads their readings and targets.
Definition goal_latch.h:30
@ GOAL_LATCH_ACTIVE
Active minutes so far today.
Definition goal_latch.h:34
@ GOAL_LATCH_STEPS
Steps so far today.
Definition goal_latch.h:31
@ GOAL_LATCH_COUNT
How many goals the latch watches.
Definition goal_latch.h:35
@ GOAL_LATCH_DISTANCE
Walked distance so far today, in metres.
Definition goal_latch.h:33
@ GOAL_LATCH_CALORIES
Active calories so far today.
Definition goal_latch.h:32
Remembers which goals were met today.
Definition goal_latch.h:45
int day
The day the marks belong to, as tm_yday, or -1 before the first look.
Definition goal_latch.h:46
uint8_t met
One GOAL_LATCH_BIT for each goal already met today.
Definition goal_latch.h:48
uint8_t below
One GOAL_LATCH_BIT for each goal with a reading below its target today.
Definition goal_latch.h:47