PebbleOS v4.45.0-223-gf3212a729
Loading...
Searching...
No Matches
kraepelin.h File Reference
#include <stdint.h>
#include <time.h>

Data Structures

struct  pbl_kraepelin_sample
 Accelerometer sample, in mG. More...
 
struct  pbl_kraepelin_sleep_stats
 Ongoing sleep statistics, returned by pbl_kraepelin_get_sleep_stats(). More...
 
struct  pbl_kraepelin_step_activity
 Walk or run in progress, returned by pbl_kraepelin_get_step_activity(). More...
 
struct  pbl_kraepelin_params
 Detection parameters that depend on the accelerometer, passed to pbl_kraepelin_init(). More...
 

Macros

#define PBL_KRAEPELIN_SAMPLE_HZ   25
 Accelerometer sampling rate expected by the algorithm, in Hz.
 
#define PBL_KRAEPELIN_MAX_UNCERTAIN_SLEEP_M   19
 Maximum delay, in minutes, for the sleep algorithm to detect that the user woke up.
 
#define PBL_KRAEPELIN_PARAMS_DEFAULT
 Default pbl_kraepelin_params initializer.
 

Typedefs

typedef void(* pbl_kraepelin_session_cb_t) (void *context, enum pbl_kraepelin_activity activity_type, time_t start_utc, uint32_t len_sec, bool ongoing, bool delete, uint32_t steps, uint32_t resting_calories, uint32_t active_calories, uint32_t distance_mm)
 Callback reporting activity sessions, called by pbl_kraepelin_activities_update().
 
typedef void(* pbl_kraepelin_stats_cb_t) (uint32_t num_stats, const char **names, int32_t *stats)
 Callback receiving algorithm statistics.
 

Enumerations

enum  pbl_kraepelin_activity {
  PBL_KRAEPELIN_ACTIVITY_SLEEP , PBL_KRAEPELIN_ACTIVITY_RESTFUL_SLEEP , PBL_KRAEPELIN_ACTIVITY_WALK , PBL_KRAEPELIN_ACTIVITY_RUN ,
  PBL_KRAEPELIN_ACTIVITY_COUNT
}
 Activity types reported to pbl_kraepelin_session_cb_t. More...
 

Functions

uint32_t pbl_kraepelin_state_size (void)
 Get the size of the algorithm state.
 
bool pbl_kraepelin_init (struct pbl_kraepelin *state, const struct pbl_kraepelin_params *params, pbl_kraepelin_stats_cb_t stats_cb)
 Initialize the algorithm state.
 
uint32_t pbl_kraepelin_analyze_samples (struct pbl_kraepelin *state, const struct pbl_kraepelin_sample *samples, uint32_t num_samples, uint32_t *consumed_samples)
 Analyze accelerometer samples.
 
void pbl_kraepelin_minute_stats (struct pbl_kraepelin *state, uint16_t *vmc, uint8_t *orientation, bool *still)
 Get the last minute's stats and reset them for the next minute.
 
uint32_t pbl_kraepelin_analyze_finish_epoch (struct pbl_kraepelin *state)
 Process the partial epoch not yet processed by pbl_kraepelin_analyze_samples() (unit tests).
 
void pbl_kraepelin_activities_update (struct pbl_kraepelin *state, time_t utc_now, uint16_t steps, uint16_t vmc, uint8_t orientation, bool definitely_not_worn, uint32_t resting_calories, uint32_t active_calories, uint32_t distance_mm, bool shutting_down, pbl_kraepelin_session_cb_t sessions_cb, void *context)
 Feed a minute of data to the walk, run and sleep detectors.
 
time_t pbl_kraepelin_activity_last_processed_time (struct pbl_kraepelin *state, enum pbl_kraepelin_activity activity)
 Get the last minute processed for an activity type.
 
void pbl_kraepelin_get_step_activity (struct pbl_kraepelin *state, enum pbl_kraepelin_activity activity, struct pbl_kraepelin_step_activity *step_activity)
 Get the walk or run in progress.
 
void pbl_kraepelin_get_sleep_stats (struct pbl_kraepelin *state, struct pbl_kraepelin_sleep_stats *stats)
 Get the ongoing sleep statistics.
 
void pbl_kraepelin_enable_activity_tracking (struct pbl_kraepelin *kalg_state, bool enable, pbl_kraepelin_session_cb_t sessions_cb, void *context)
 Enable or disable automatic activity session detection.