23 #define PEDOMETER_STATUS_ACTIVITY_BITNUM 0 24 #define PEDOMETER_STATUS_SUSPEND_BITNUM 3 25 #define PEDOMETER_STATUS_ACTCHG_BITNUM 4 26 #define PEDOMETER_STATUS_STEPCHG_BITNUM 5 27 #define PEDOMETER_STATUS_SUSPCHG_BITNUM 6 28 #define PEDOMETER_STATUS_MRGFLG_BITNUM 7 30 #define PEDOMETER_STATUS_ACTIVITY_MASK (7 << PEDOMETER_STATUS_ACTIVITY_BITNUM) 31 #define PEDOMETER_STATUS_SUSPEND_MASK (1 << PEDOMETER_STATUS_SUSPEND_BITNUM) 32 #define PEDOMETER_STATUS_ACTCHG_MASK (1 << PEDOMETER_STATUS_ACTCHG_BITNUM) 33 #define PEDOMETER_STATUS_STEPCHG_MASK (1 << PEDOMETER_STATUS_STEPCHG_BITNUM) 34 #define PEDOMETER_STATUS_SUSPCHG_MASK (1 << PEDOMETER_STATUS_SUSPCHG_BITNUM) 35 #define PEDOMETER_STATUS_MRGFLG_MASK (1 << PEDOMETER_STATUS_MRGFLG_BITNUM) 37 #define PEDOMETER_STATUS_CHG_MASK \ 38 (PEDOMETER_STATUS_ACTCHG_MASK | PEDOMETER_STATUS_STEPCHG_MASK | PEDOMETER_STATUS_SUSPCHG_MASK) 39 #define SQUARED(x) ((x) * (x)) 46 static void status_update(
pedometer_t *pedometer, uint32_t events,
bool suspend);
55 static uint16_t uint32_to_uint16(uint32_t val);
66 .sleepcount_threshold = 1,
67 .bits = {.config = 1},
99 *pPedometer = pedometer_default;
113 pPedometer->
config = *pConfig;
129 bool suspend = suspend_compute(pPedometer, pData);
132 events = KeynetikHandleIncomingEvent(pData->
accel[0], pData->
accel[1], pData->
accel[2]);
134 status_update(pPedometer, events, suspend);
146 static void status_update(
pedometer_t *pPedometer, uint32_t events,
bool suspend)
148 bool activity_stable =
153 uint16_t stepcount = uint32_to_uint16(keynetikStepCount);
207 uint16_t uint32_to_uint16(uint32_t val)
209 if (val > 0x0000FFFF)
211 return ((uint16_t)val);
228 *count = (*count + 1) < threshold ? *count + 1 : threshold;
236 *count = (*count - 1) > 0 ? *count - 1 : 0;
238 return ((
bool)(*count >= threshold));
struct pedometer_t::pedometer_status_tag status
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer.
#define PEDOMETER_STATUS_MRGFLG_MASK
#define PEDOMETER_STATUS_SUSPEND_MASK
KeynetikActivityLevel activitylevel_t
#define PEDOMETER_STATUS_ACTIVITY_MASK
The pedometer.h file contains the interface and structure definitions for pedometer application...
#define PEDOMETER_STATUS_CHG_MASK
#define PEDO_FILTER_STEPS_DEFAULT
#define PEDOMETER_STATUS_SUSPCHG_MASK
This defines the configuration structure of the pedometer.
#define PEDOMETER_STATUS_STEPCHG_MASK
debounce_count_t sleepcount_threshold
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
struct pedometer_t::pedometer_status_tag::@351::@352 bits
#define PEDO_FREQHZ_DEFAULT
debounce_count_t activitycount_threshold
This defines the pedometer instance.
uint16_t stepchg_stepcount
This defines the acceleration input data for the pedometer.
#define PEDO_FILTER_TIME_DEFAULT
debounce_count_t activitycount
struct pedometer_t::pedometer_private_tag private
pedometer_config_t config
uint16_t debounce_count_t
#define PEDO_SPEED_PERIOD_DEFAULT
debounce_count_t sleepcount
union pedometer_t::pedometer_status_tag::@351 status
#define PEDOMETER_STATUS_ACTCHG_MASK
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm.
#define PEDO_STEP_THRESHOLD_DEFAULT
struct pedometer_config_t::@350 bits
#define PEDOMETER_STATUS_ACTIVITY_BITNUM
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer.