PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
kraepelin_algorithm.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <time.h>

Data Structures

struct  KAlgOngoingSleepStats
 Ongoing sleep statistics, returned by kalg_get_sleep_stats(). More...
 

Macros

#define KALG_SAMPLE_HZ   25
 Accelerometer sampling rate expected by the algorithm, in Hz.
 
#define KALG_GRAMS_PER_KG   1000
 Number of grams per kilogram.
 
#define KALG_ENCODED_VMC_NOT_WORN   0
 Encoded VMC value meaning the watch was not worn.
 
#define KALG_ENCODED_VMC_MIN_WORN_VALUE   1
 Minimum encoded VMC value when the watch was worn.
 
#define KALG_MAX_UNCERTAIN_SLEEP_M   19
 Maximum delay, in minutes, for the sleep algorithm to detect that the user woke up.
 

Typedefs

typedef struct KAlgState KAlgState
 Opaque algorithm state.
 
typedef void(* KAlgActivitySessionCallback) (void *context, KAlgActivityType 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 kalg_activities_update().
 
typedef void(* KAlgStatsCallback) (uint32_t num_stats, const char **names, int32_t *stats)
 Callback receiving algorithm statistics.
 

Enumerations

enum  KAlgActivityType {
  KAlgActivityType_Sleep , KAlgActivityType_RestfulSleep , KAlgActivityType_Walk , KAlgActivityType_Run ,
  KAlgActivityTypeCount
}
 Activity types reported to KAlgActivitySessionCallback. More...
 

Functions

uint32_t kalg_state_size (void)
 Get the size of the algorithm state.
 
bool kalg_init (KAlgState *state, KAlgStatsCallback stats_cb)
 Initialize the algorithm state.
 
void kalg_deinit (KAlgState *state)
 Release the resources held by the state.
 
uint32_t kalg_analyze_samples (KAlgState *state, AccelRawData *samples, uint32_t num_samples, uint32_t *consumed_samples)
 Analyze accelerometer samples.
 
void kalg_minute_stats (KAlgState *state, uint16_t *vmc, uint8_t *orientation, bool *still)
 Get the last minute's stats and reset them for the next minute.
 
uint32_t kalg_analyze_finish_epoch (KAlgState *state)
 Process the partial epoch not yet processed by kalg_analyze_samples() (unit tests).
 
void kalg_activities_update (KAlgState *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, KAlgActivitySessionCallback sessions_cb, void *context)
 Feed a minute of data to the walk, run and sleep detectors.
 
time_t kalg_activity_last_processed_time (KAlgState *state, KAlgActivityType activity)
 Get the last minute processed for an activity type.
 
void kalg_get_sleep_stats (KAlgState *state, KAlgOngoingSleepStats *stats)
 Get the ongoing sleep statistics.
 
void kalg_enable_activity_tracking (KAlgState *kalg_state, bool enable)
 Enable or disable automatic activity session detection.
 
bool kalg_activity_hrm_is_active (KAlgState *kalg_state)
 Check whether a continuous heart rate session is active for a detected activity.
 
void kalg_activity_hrm_set_paused (KAlgState *kalg_state, bool paused)
 Pause or resume the heart rate sessions of detected activities.