49 #define PEDOMETER_STATUS_ACTIVITY_BITNUM 0 50 #define PEDOMETER_STATUS_SUSPEND_BITNUM 3 51 #define PEDOMETER_STATUS_ACTCHG_BITNUM 4 52 #define PEDOMETER_STATUS_STEPCHG_BITNUM 5 53 #define PEDOMETER_STATUS_SUSPCHG_BITNUM 6 54 #define PEDOMETER_STATUS_MRGFLG_BITNUM 7 56 #define PEDOMETER_STATUS_ACTIVITY_MASK (7 << PEDOMETER_STATUS_ACTIVITY_BITNUM) 57 #define PEDOMETER_STATUS_SUSPEND_MASK (1 << PEDOMETER_STATUS_SUSPEND_BITNUM) 58 #define PEDOMETER_STATUS_ACTCHG_MASK (1 << PEDOMETER_STATUS_ACTCHG_BITNUM) 59 #define PEDOMETER_STATUS_STEPCHG_MASK (1 << PEDOMETER_STATUS_STEPCHG_BITNUM) 60 #define PEDOMETER_STATUS_SUSPCHG_MASK (1 << PEDOMETER_STATUS_SUSPCHG_BITNUM) 61 #define PEDOMETER_STATUS_MRGFLG_MASK (1 << PEDOMETER_STATUS_MRGFLG_BITNUM) 63 #define PEDOMETER_STATUS_CHG_MASK \ 64 (PEDOMETER_STATUS_ACTCHG_MASK | PEDOMETER_STATUS_STEPCHG_MASK | PEDOMETER_STATUS_SUSPCHG_MASK) 65 #define SQUARED(x) ((x) * (x)) 72 static void status_update(
pedometer_t *pedometer, uint32_t events,
bool suspend);
81 static uint16_t uint32_to_uint16(uint32_t val);
92 .sleepcount_threshold = 1,
93 .bits = {.config = 1},
125 *pPedometer = pedometer_default;
139 pPedometer->
config = *pConfig;
155 bool suspend = suspend_compute(pPedometer, pData);
158 events = KeynetikHandleIncomingEvent(pData->
accel[0], pData->
accel[1], pData->
accel[2]);
160 status_update(pPedometer, events, suspend);
172 static void status_update(
pedometer_t *pPedometer, uint32_t events,
bool suspend)
174 bool activity_stable =
179 uint16_t stepcount = uint32_to_uint16(keynetikStepCount);
233 uint16_t uint32_to_uint16(uint32_t val)
235 if (val > 0x0000FFFF)
237 return ((uint16_t)val);
254 *count = (*count + 1) < threshold ? *count + 1 : threshold;
262 *count = (*count - 1) > 0 ? *count - 1 : 0;
264 return ((
bool)(*count >= threshold));
pedometer_config_t config
void pedometer_init(pedometer_t *pPedometer)
The interface function initialize the pedometer.
This defines the configuration structure of the pedometer.
The pedometer.h file contains the interface and structure definitions for pedometer application...
#define PEDO_FREQHZ_DEFAULT
struct pedometer_config_t::@291 bits
This defines the acceleration input data for the pedometer.
#define PEDOMETER_STATUS_SUSPCHG_MASK
#define PEDO_STEP_THRESHOLD_DEFAULT
#define PEDOMETER_STATUS_SUSPEND_MASK
This defines the pedometer instance.
KeynetikActivityLevel activitylevel_t
#define PEDOMETER_STATUS_ACTCHG_MASK
#define PEDOMETER_STATUS_STEPCHG_MASK
debounce_count_t sleepcount
#define PEDO_SPEED_PERIOD_DEFAULT
debounce_count_t sleepcount_threshold
union pedometer_t::pedometer_status_tag::@292 status
void pedometer_configure(pedometer_t *pPedometer, const pedometer_config_t *pConfig)
The interface function to configure the pedometer.
int32_t pedometer_run(pedometer_t *pPedometer, ped_accel_t *pData)
The interface function excutes the pedometer algorithm.
debounce_count_t activitycount
debounce_count_t activitycount_threshold
struct pedometer_t::pedometer_status_tag status
#define PEDOMETER_STATUS_CHG_MASK
#define PEDO_FILTER_STEPS_DEFAULT
uint16_t stepchg_stepcount
struct pedometer_t::pedometer_status_tag::@292::@293 bits
#define PEDOMETER_STATUS_ACTIVITY_BITNUM
struct pedometer_t::pedometer_private_tag private
#define PEDOMETER_STATUS_MRGFLG_MASK
uint16_t debounce_count_t
#define PEDOMETER_STATUS_ACTIVITY_MASK
#define PEDO_FILTER_TIME_DEFAULT