Loading...
Searching...
No Matches
goal_latch.h File Reference

Decides when a daily movement goal has just been met, so the watch cheers once per goal per day. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  GoalLatch
 Remembers which goals were met today. More...

Macros

#define GOAL_LATCH_BIT(goal)
 The bit a goal takes in the mask goal_latch_update hands back.
#define GOAL_LATCH_EMPTY   {.day = -1}
 a latch that has not looked yet

Enumerations

enum  GoalLatchGoal {
  GOAL_LATCH_STEPS , GOAL_LATCH_CALORIES , GOAL_LATCH_DISTANCE , GOAL_LATCH_ACTIVE ,
  GOAL_LATCH_COUNT
}
 The goals the latch watches, in the order it reads their readings and targets. More...

Functions

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.

Detailed Description

Decides when a daily movement goal has just been met, so the watch cheers once per goal per day.

It watches steps, calories, distance, and active minutes. A goal counts as met when its reading reaches its target after a reading below the target that same day, and after that it stays met until the day changes. A reading already past the target with none below it first never counts. That keeps the face quiet on a goal met before it opened, and on yesterday's total, which the health store can still hold for up to a minute after midnight. The goal then waits for today's own readings to climb past it.

The latch only moves when it is asked. A target raised past a goal already met stays met for the day, and a target lowered below the reading reports on the next ask rather than straight away.