PebbleOS
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
Activity insights

Sleep and activity rewards, summary pins and session notifications. More...

Data Structures

struct  ActivityInsightMetricHistoryStats
 Statistics of a metric's history, used to decide whether an insight can trigger. More...
 

Enumerations

enum  PercentTier {
  PercentTier_AboveAverage = 0 , PercentTier_OnAverage , PercentTier_BelowAverage , PercentTier_Fail ,
  PercentTierCount
}
 How a value compares to the user's average. More...
 
enum  ActivityInsightType {
  ActivityInsightType_Unknown = 0 , ActivityInsightType_SleepReward , ActivityInsightType_ActivityReward , ActivityInsightType_SleepSummary ,
  ActivityInsightType_ActivitySummary , ActivityInsightType_Day1 , ActivityInsightType_Day4 , ActivityInsightType_Day10 ,
  ActivityInsightType_ActivitySessionSleep , ActivityInsightType_ActivitySessionNap , ActivityInsightType_ActivitySessionWalk , ActivityInsightType_ActivitySessionRun ,
  ActivityInsightType_ActivitySessionOpen
}
 Insight types, reported to analytics. More...
 
enum  ActivityInsightResponseType {
  ActivityInsightResponseTypePositive = 0 , ActivityInsightResponseTypeNeutral , ActivityInsightResponseTypeNegative , ActivityInsightResponseTypeClassified ,
  ActivityInsightResponseTypeMisclassified
}
 User responses to an insight, reported to analytics. More...
 
enum  ActivationDelayInsightType { ActivationDelayInsightType_Day1 , ActivationDelayInsightType_Day4 , ActivationDelayInsightType_Day10 , ActivationDelayInsightTypeCount }
 Insights sent a number of days after activation. More...
 

Functions

void activity_insights_recalculate_stats (void)
 Recalculate the metric history statistics.
 
void activity_insights_init (time_t now_utc)
 Initialize activity insights.
 
void activity_insights_process_sleep_data (time_t now_utc)
 Process updated sleep metrics.
 
void activity_insights_process_minute_data (time_t now_utc)
 Check the step insights.
 
void activity_insights_push_activity_session_notification (time_t notif_time, ActivitySession *session, int32_t avg_hr, int32_t *hr_zone_time_s)
 Push the notification summarizing a walk, run or open workout session.
 
void activity_insights_test_push_summary_pins (void)
 Push the 3 variants of each summary pin, with a notification for the last one (test apps).
 
void activity_insights_test_push_rewards (void)
 Push the sleep and activity rewards (test apps).
 
void activity_insights_test_push_walk_run_sessions (void)
 Push a run and a walk notification (test apps).
 
void activity_insights_test_push_nap_session (void)
 Push a nap pin and notification (test apps).
 

Detailed Description

Sleep and activity rewards, summary pins and session notifications.

Insights compare today's sleep and steps against the user's history and push timeline pins and notifications. Their parameters come from the insights settings (see Insights settings).


Data Structure Documentation

◆ ActivityInsightMetricHistoryStats

struct ActivityInsightMetricHistoryStats

Statistics of a metric's history, used to decide whether an insight can trigger.

Computed over past days only, ignoring days with no data.

Data Fields
uint8_t consecutive_days Consecutive days with data, starting yesterday.
ActivityScalarStore mean Mean value.
ActivityScalarStore median Median value.
ActivityMetric metric Metric.
uint8_t total_days Days with data.

Enumeration Type Documentation

◆ ActivationDelayInsightType

Insights sent a number of days after activation.

Used as bit positions in a prefs bitfield: new values go at the end.

Enumerator
ActivationDelayInsightType_Day1 

Day 1.

ActivationDelayInsightType_Day4 

Day 4.

ActivationDelayInsightType_Day10 

Day 10.

ActivationDelayInsightTypeCount 

Number of activation delay insights.

◆ ActivityInsightResponseType

User responses to an insight, reported to analytics.

Enumerator
ActivityInsightResponseTypePositive 

Positive feedback.

ActivityInsightResponseTypeNeutral 

Neutral feedback.

ActivityInsightResponseTypeNegative 

Negative feedback.

ActivityInsightResponseTypeClassified 

Session correctly classified.

ActivityInsightResponseTypeMisclassified 

Session misclassified.

◆ ActivityInsightType

Insight types, reported to analytics.

Enumerator
ActivityInsightType_Unknown 

Unknown.

ActivityInsightType_SleepReward 

Sleep reward.

ActivityInsightType_ActivityReward 

Activity reward.

ActivityInsightType_SleepSummary 

Sleep summary pin.

ActivityInsightType_ActivitySummary 

Activity summary pin.

ActivityInsightType_Day1 

Day 1 after activation.

ActivityInsightType_Day4 

Day 4 after activation.

ActivityInsightType_Day10 

Day 10 after activation.

ActivityInsightType_ActivitySessionSleep 

Sleep session.

ActivityInsightType_ActivitySessionNap 

Nap session.

ActivityInsightType_ActivitySessionWalk 

Walk session.

ActivityInsightType_ActivitySessionRun 

Run session.

ActivityInsightType_ActivitySessionOpen 

Open workout session.

◆ PercentTier

How a value compares to the user's average.

Enumerator
PercentTier_AboveAverage 

Above the average threshold.

PercentTier_OnAverage 

Between the below and above average thresholds.

PercentTier_BelowAverage 

Below the average threshold.

PercentTier_Fail 

Below the fail threshold.

PercentTierCount 

Number of tiers.

Function Documentation

◆ activity_insights_init()

void activity_insights_init ( time_t  now_utc)

Initialize activity insights.

Not thread safe: only called from activity_init(), during boot.

Parameters
now_utcCurrent UTC time.

◆ activity_insights_process_minute_data()

void activity_insights_process_minute_data ( time_t  now_utc)

Check the step insights.

Called once per minute by the minute handler. Not thread safe: the caller must hold the activity state mutex.

Parameters
now_utcCurrent UTC time.

◆ activity_insights_process_sleep_data()

void activity_insights_process_sleep_data ( time_t  now_utc)

Process updated sleep metrics.

Called by the minute handler when it updates the sleep metrics. Not thread safe: the caller must hold the activity state mutex.

Parameters
now_utcCurrent UTC time.

◆ activity_insights_push_activity_session_notification()

void activity_insights_push_activity_session_notification ( time_t  notif_time,
ActivitySession *  session,
int32_t  avg_hr,
int32_t *  hr_zone_time_s 
)

Push the notification summarizing a walk, run or open workout session.

Does nothing for sessions shorter than a minute.

Parameters
notif_timeNotification time, UTC.
sessionSession.
avg_hrAverage heart rate, in beats per minute, 0 if unknown.
hr_zone_time_sSeconds spent in each HRZone (HRZoneCount entries), or NULL.

◆ activity_insights_recalculate_stats()

void activity_insights_recalculate_stats ( void  )

Recalculate the metric history statistics.

Called at midnight rollover. Not thread safe: the caller must hold the activity state mutex.

◆ activity_insights_test_push_nap_session()

void activity_insights_test_push_nap_session ( void  )

Push a nap pin and notification (test apps).

◆ activity_insights_test_push_rewards()

void activity_insights_test_push_rewards ( void  )

Push the sleep and activity rewards (test apps).

◆ activity_insights_test_push_summary_pins()

void activity_insights_test_push_summary_pins ( void  )

Push the 3 variants of each summary pin, with a notification for the last one (test apps).

◆ activity_insights_test_push_walk_run_sessions()

void activity_insights_test_push_walk_run_sessions ( void  )

Push a run and a walk notification (test apps).