Loading...
Searching...
No Matches
vibe.c File Reference

The haptic feedback wrapper implementation. More...

Functions

void vibe_pulse (VibePulse pulse)
 Fire a pulse unless in quiet time.
void vibe_custom (const uint32_t *durations, uint32_t num_segments)
 Buzz a custom on and off rhythm unless in quiet time. The durations are milliseconds that alternate buzz then pause then buzz and so on, starting on a buzz. Lets a caller play a little tune that the three canned pulses cannot.
void vibe_choice (uint8_t choice)
 Fire the pattern named by a VibeChoice (VIBE_NONE stays silent). The caller resolves the choice from wherever it likes, so the lib never has to know which setting it came from.
void vibe_bt_transition (bool connected)
 The default bluetooth-transition buzz: fire the pattern the user picked in settings for a connect or disconnect. A face installs this as system_store's vibe policy so the store itself never has to know about settings or buzzing.
static time_t current_hour_start (void)
 When the current local hour began.
void vibe_hourly (const struct tm *tick, uint8_t choice)
 Buzz once at the top of each hour. A face calls this from its time callback on every tick, and it buzzes on the first tick of each hour's minute 0.
static void play_goal_pattern (const char *text)
 Plays a list of milliseconds such as "100,80,300". A list with no numbers stays silent.
static int goal_target (SettingId id, int(*lookup)(uint8_t index))
 The goal the wearer picked for one setting, or 0 when the face does not keep that setting.
void vibe_goal (void)
 Buzz the first time each day a movement goal is met. A face calls this once at startup, after both health_store_init and time_store_init, and from its health store callback on every reading.

Variables

static HourLatch s_hour_latch = HOUR_LATCH_EMPTY
 the hour the hourly buzz last fired for
static bool s_hourly_seeded
 whether the first call has remembered its hour
static GoalLatch s_goal_latch = GOAL_LATCH_EMPTY
 the goals the goal buzz has already met today

Detailed Description

The haptic feedback wrapper implementation.

Function Documentation

◆ current_hour_start()

time_t current_hour_start ( void )
static

When the current local hour began.

It reads the clock once and breaks that same reading apart. Pairing a fresh time(NULL) with an older tick's minutes and seconds would give one hour two starts whenever a second turns over between them.

Returns
The start of the current hour, as seconds since the epoch.

◆ goal_target()

int goal_target ( SettingId id,
int(* lookup )(uint8_t index) )
static

The goal the wearer picked for one setting, or 0 when the face does not keep that setting.

Parameters
idThe goal's setting, such as SETTING_GOAL_STEPS.
lookupThe table lookup that turns its menu choice into the goal, such as goals_steps.
Returns
The goal, or 0 for none.

◆ play_goal_pattern()

void play_goal_pattern ( const char * text)
static

Plays a list of milliseconds such as "100,80,300". A list with no numbers stays silent.

Parameters
textThe list.