|
PebbleOS v4.47.0-512-g5285d4236
|
Manually started and stopped activity sessions. More...
Data Structures | |
| struct | WorkoutServiceMetrics |
| Metrics of the current workout, taken at one instant. 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. | |
| 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. | |
| bool | workout_service_get_current_workout_metrics (WorkoutServiceMetrics *metrics_out) |
| Get all metrics of the current workout at once. | |
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.
| struct WorkoutServiceMetrics |
Metrics of the current workout, taken at one instant.
| Data Fields | ||
|---|---|---|
| int32_t | active_kcal | Estimated active kilocalories. |
| int32_t | avg_bpm | Average of the valid heart rate samples, in beats per minute. |
| int32_t | current_bpm | Current heart rate, in beats per minute. |
| HRZone | current_hr_zone | Current heart rate zone. |
| int32_t | distance_m | Distance, in meters. |
| int32_t | duration_s | Duration excluding pauses, in seconds. |
| int32_t | hr_samples | Valid heart rate samples while not paused, grows with every new reading. |
| int32_t | hr_zone_time_s[HRZoneCount] | Seconds spent in each heart rate zone, indexed by HRZone. |
| int32_t | steps | Steps. |
| 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.
| event | Event. |
| 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.
| 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.
| 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.
| [out] | steps_out | Steps. |
| [out] | duration_s_out | Duration excluding pauses, in seconds. |
| [out] | distance_m_out | Distance, in meters. |
| [out] | current_bpm_out | Current heart rate, in beats per minute. |
| [out] | current_hr_zone_out | Current heart rate zone. |
| bool workout_service_get_current_workout_metrics | ( | WorkoutServiceMetrics * | metrics_out | ) |
Get all metrics of the current workout at once.
| [out] | metrics_out | Metrics, left untouched without a workout. |
| bool workout_service_get_current_workout_type | ( | ActivitySessionType * | type_out | ) |
Get the type of the current workout.
| [out] | type_out | Workout type. |
| void workout_service_health_event_handler | ( | PebbleHealthEvent * | event | ) |
Handle a health event (movement and heart rate updates).
Called from the KernelMain event loop.
| event | Event. |
| void workout_service_init | ( | void | ) |
Initialize the workout service.
| bool workout_service_is_paused | ( | void | ) |
Check whether the current workout is paused.
| bool workout_service_is_workout_ongoing | ( | void | ) |
Check whether a workout is ongoing.
| bool workout_service_is_workout_type_supported | ( | ActivitySessionType | type | ) |
Check whether a session type can be a workout.
| type | Session type. |
| bool workout_service_pause_workout | ( | bool | should_be_paused | ) |
Pause or resume the current workout.
Paused time does not count toward the workout duration.
| should_be_paused | true to pause, false to resume. |
| 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.
| type | Workout type. |
| 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.
| 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.
| session | Session to take over. |
| void workout_service_workout_event_handler | ( | PebbleWorkoutEvent * | event | ) |
Handle a workout event.
Called from the KernelMain event loop.
| event | Event. |