PebbleOS
Loading...
Searching...
No Matches
Functions
Workout service

Manually started and stopped activity sessions. More...

Functions

void workout_service_init (void)
 Initialize the workout service.
 
void workout_service_frontend_opened (void)
 Signal that the workout app was opened.
 
void workout_service_frontend_closed (void)
 Signal that the workout app was closed.
 
void workout_service_health_event_handler (PebbleHealthEvent *event)
 Handle a health event (movement and heart rate updates).
 
void workout_service_activity_event_handler (PebbleActivityEvent *event)
 Handle an activity event.
 
void workout_service_workout_event_handler (PebbleWorkoutEvent *event)
 Handle a workout event.
 
bool workout_service_is_workout_ongoing (void)
 Check whether a workout is ongoing.
 
void workout_service_set_hrm_paused (bool paused)
 Pause or resume the workout's heart rate sampling.
 
bool workout_service_is_workout_type_supported (ActivitySessionType type)
 Check whether a session type can be a workout.
 
bool workout_service_start_workout (ActivitySessionType type)
 Start a workout.
 
bool workout_service_pause_workout (bool should_be_paused)
 Pause or resume the current workout.
 
bool workout_service_stop_workout (void)
 Stop the current workout.
 
bool workout_service_takeover_activity_session (ActivitySession *session)
 Turn a detected activity session into a workout.
 
bool workout_service_is_paused (void)
 Check whether the current workout is paused.
 
bool workout_service_get_current_workout_type (ActivitySessionType *type_out)
 Get the type of the current workout.
 
bool workout_service_get_current_workout_info (int32_t *steps_out, int32_t *duration_s_out, int32_t *distance_m_out, int32_t *current_bpm_out, HRZone *current_hr_zone_out)
 Get the current workout metrics.
 

Detailed Description

Manually started and stopped activity sessions.

Workouts are like detected activity sessions, but are started and stopped by the user and update more frequently. Only one workout runs at a time, and automatic session detection is disabled while it runs. Workouts of at least a minute are saved as manual ActivitySession entries when stopped.

int32_t steps, duration_s, distance_m, bpm;
HRZone zone;
workout_service_get_current_workout_info(&steps, &duration_s, &distance_m, &bpm, &zone);
...
}
HRZone
Heart rate zone.
Definition hr_util.h:22
bool workout_service_stop_workout(void)
Stop the current workout.
bool workout_service_get_current_workout_info(int32_t *steps_out, int32_t *duration_s_out, int32_t *distance_m_out, int32_t *current_bpm_out, HRZone *current_hr_zone_out)
Get the current workout metrics.
bool workout_service_start_workout(ActivitySessionType type)
Start a workout.
@ ActivitySessionType_Run
Run.
Definition activity.h:303

Function Documentation

◆ workout_service_activity_event_handler()

void workout_service_activity_event_handler ( PebbleActivityEvent *  event)

Handle an activity event.

Pauses the workout when activity tracking stops. Called from the KernelMain event loop.

Parameters
eventEvent.

◆ workout_service_frontend_closed()

void workout_service_frontend_closed ( void  )

Signal that the workout app was closed.

Arms a reminder notification for a workout left running. Must be called from the app task.

◆ workout_service_frontend_opened()

void workout_service_frontend_opened ( void  )

Signal that the workout app was opened.

Cancels the abandoned workout reminder. Must be called from the app task.

◆ workout_service_get_current_workout_info()

bool workout_service_get_current_workout_info ( int32_t *  steps_out,
int32_t *  duration_s_out,
int32_t *  distance_m_out,
int32_t *  current_bpm_out,
HRZone *  current_hr_zone_out 
)

Get the current workout metrics.

Each output is optional.

Parameters
[out]steps_outSteps.
[out]duration_s_outDuration excluding pauses, in seconds.
[out]distance_m_outDistance, in meters.
[out]current_bpm_outCurrent heart rate, in beats per minute.
[out]current_hr_zone_outCurrent heart rate zone.
Returns
true if a workout is ongoing.

◆ workout_service_get_current_workout_type()

bool workout_service_get_current_workout_type ( ActivitySessionType *  type_out)

Get the type of the current workout.

Parameters
[out]type_outWorkout type.
Returns
true if a workout is ongoing.

◆ workout_service_health_event_handler()

void workout_service_health_event_handler ( PebbleHealthEvent *  event)

Handle a health event (movement and heart rate updates).

Called from the KernelMain event loop.

Parameters
eventEvent.

◆ workout_service_init()

void workout_service_init ( void  )

Initialize the workout service.

◆ workout_service_is_paused()

bool workout_service_is_paused ( void  )

Check whether the current workout is paused.

Returns
true if a workout is ongoing and paused.

◆ workout_service_is_workout_ongoing()

bool workout_service_is_workout_ongoing ( void  )

Check whether a workout is ongoing.

Returns
true if a workout is ongoing, paused or not.

◆ workout_service_is_workout_type_supported()

bool workout_service_is_workout_type_supported ( ActivitySessionType  type)

Check whether a session type can be a workout.

Parameters
typeSession type.
Returns
true for walks, runs and open workouts.

◆ workout_service_pause_workout()

bool workout_service_pause_workout ( bool  should_be_paused)

Pause or resume the current workout.

Paused time does not count toward the workout duration.

Parameters
should_be_pausedtrue to pause, false to resume.
Returns
true on success, false if no workout is ongoing.

◆ workout_service_set_hrm_paused()

void workout_service_set_hrm_paused ( bool  paused)

Pause or resume the workout's heart rate sampling.

Frees the shared optical path for a SpO2 reading during a workout. No-op without a workout heart rate session.

Parameters
pausedtrue to pause, false to resume.

◆ workout_service_start_workout()

bool workout_service_start_workout ( ActivitySessionType  type)

Start a workout.

Ends ongoing detected sessions and disables automatic session detection. Every started workout must eventually be stopped.

Parameters
typeWorkout type.
Returns
true on success, false if the type is unsupported or a workout is already ongoing.

◆ workout_service_stop_workout()

bool workout_service_stop_workout ( void  )

Stop the current workout.

Saves it as a session and notifies the user if it lasted at least a minute, and re-enables automatic session detection.

Returns
true on success, false if no workout is ongoing.

◆ workout_service_takeover_activity_session()

bool workout_service_takeover_activity_session ( ActivitySession *  session)

Turn a detected activity session into a workout.

The session is removed and a workout starts with its start time, duration, steps, distance and calories.

Parameters
sessionSession to take over.
Returns
true on success.

◆ workout_service_workout_event_handler()

void workout_service_workout_event_handler ( PebbleWorkoutEvent *  event)

Handle a workout event.

Called from the KernelMain event loop.

Parameters
eventEvent.