141 lines
5.0 KiB
C
141 lines
5.0 KiB
C
|
#pragma once
|
|||
|
/******************** (C) COPYRIGHT 2023 Geek************************************
|
|||
|
* File Name : Pedometer.h
|
|||
|
* Department : Sensor Team
|
|||
|
* Current Version : V1.0.0
|
|||
|
* Author : logzhan
|
|||
|
* Date of Issued : 2023.02.24
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
#ifndef _STEPS_ALGORITHM_H_
|
|||
|
#define _STEPS_ALGORITHM_H_
|
|||
|
|
|||
|
#include "pdr_sensor.h"
|
|||
|
#define IMU_SAMPLE_FREQ 100 // IMU<4D><55><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>100Hz
|
|||
|
#define MS2S 1000 // <20><>ת<EFBFBD><D7AA><EFBFBD>뵥λ
|
|||
|
|
|||
|
#define DOWN_SAMPLE_NUM 4 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define ACC_SAMPLE_TIME MS2S / IMU_SAMPLE_FREQ // ACC<43><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10ms
|
|||
|
#define GYRO_SAMPLE_TIME MS2S / IMU_SAMPLE_FREQ // GYR<59><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10ms
|
|||
|
#define SAMPLE_TIME_MIN 9
|
|||
|
|
|||
|
#define PEDOMETER_FREQ IMU_SAMPLE_FREQ / DOWN_SAMPLE_NUM // <20>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
|||
|
#define SampleFrequencyFour 100
|
|||
|
#define SampleFrequencydouble 50
|
|||
|
#define SampleFrequencyOPF (37.5l)
|
|||
|
#define SampleFrequencySix 150
|
|||
|
#define AVG_FILTER_BUFF_LEN 5 // <20><>ֵ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD>Ĭ<EFBFBD><C4AC>Ϊ5
|
|||
|
#define AXIS_NUM 4 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34>: x<><78>y<EFBFBD><79>z<EFBFBD><7A>xyz
|
|||
|
#define FILTER_NUM 4 // <20>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34>
|
|||
|
#define FILTER_AXIS_NUM AXIS_NUM * FILTER_NUM // 4*4=16, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>ܹ<EFBFBD>16<31><36><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define AXIS_ALL 20 // AxisNumberFiltOut + FiltDifNumber
|
|||
|
#define ACC_BUFF_NUM 39 // ACC<43><43><EFBFBD>泤<EFBFBD><E6B3A4>39
|
|||
|
#define WIN_LENGTH_AVE_DEVI 50 //
|
|||
|
#define PI2A (180/3.1415926)
|
|||
|
|
|||
|
#define STARTSTEPS 8
|
|||
|
|
|||
|
#define DET_VEHICLE_ACC_BUFF_LEN 200 // Origin acc sampleFrequency is 100 hz
|
|||
|
|
|||
|
#define WINDOW_LENGTH_MIN2MAX (DET_VEHICLE_ACC_BUFF_LEN/2 - 1) // 25hz , 1 second
|
|||
|
#define PLATFORM_PC_WINDOWS
|
|||
|
|
|||
|
#define STEP_TRUE 1
|
|||
|
#define STEP_FALSE 0
|
|||
|
#define AXIS_XYZ 3
|
|||
|
|
|||
|
#if defined PLATFORM_ANDROID_QCOM_ADSP
|
|||
|
#define STEPLIB_MEMSET SNS_OS_MEMSET
|
|||
|
|
|||
|
#if 1
|
|||
|
#endif
|
|||
|
#elif defined PLATFORM_ANDROID_QCOM_AP || defined PLATFORM_PC_WINDOWS || defined PLATFORM_PC_LINUX || defined PLATFORM_ANDROID_MTK || defined PLATFORM_ANDROID_QCOM_SLPI845
|
|||
|
#define STEPLIB_MEMSET memset
|
|||
|
#endif
|
|||
|
#if defined PLATFORM_ANDROID_MTK
|
|||
|
#define ABS_INT abs_value
|
|||
|
#else
|
|||
|
#define ABS_INT abs
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
typedef struct {
|
|||
|
unsigned long walkSteps;
|
|||
|
}stepsRe;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
double walk;
|
|||
|
double walkRealTime;
|
|||
|
double nD;
|
|||
|
}StepsDefine_t;
|
|||
|
|
|||
|
typedef enum {
|
|||
|
NonSteps = 0,
|
|||
|
walk,
|
|||
|
run,
|
|||
|
}StepState_t;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
unsigned char sign;
|
|||
|
StepState_t state;
|
|||
|
unsigned long long stateStartTime;
|
|||
|
unsigned long long stepsStartTime;
|
|||
|
}stateNowDefine;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
StepState_t state;
|
|||
|
unsigned long long startTimeStamp;
|
|||
|
}StateDef_t;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
int flag;
|
|||
|
double ax;
|
|||
|
double ay;
|
|||
|
double az;
|
|||
|
}DownSample_t;
|
|||
|
|
|||
|
/**---------------------------------------------------------------------
|
|||
|
* Function : Pedometer_GetVersion
|
|||
|
* Description : <EFBFBD><EFBFBD>ȡ<EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾
|
|||
|
* Date : 2023/02/24
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
const char* Pedometer_GetVersion(void);
|
|||
|
|
|||
|
/**---------------------------------------------------------------------
|
|||
|
* Function : initPedometer
|
|||
|
* Description : PDR <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Date : 2020/2/20 logzhan
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
void Pedometer_Init(void);
|
|||
|
|
|||
|
/**---------------------------------------------------------------------
|
|||
|
* Function : Pedometer_ReInit
|
|||
|
* Description : <EFBFBD><EFBFBD><EFBFBD>³<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Date : 2023/02/24 logzhan
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
void Pedometer_ReInit(void);
|
|||
|
|
|||
|
/**---------------------------------------------------------------------
|
|||
|
* Function : PedometerUpdate
|
|||
|
* Description : PDR <EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ٶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ָ<EFBFBD>뷵<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Date : 2023/02/25 logzhan <EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
void Pedometer_Update(IMU_t* imu, uint32_t* step);
|
|||
|
|
|||
|
void Pedometer_GetState(StepState_t* state);
|
|||
|
|
|||
|
/**---------------------------------------------------------------------
|
|||
|
* Function : DetVehicleMode
|
|||
|
* Description : PDR <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* Date : 2023/02/24 logzhan
|
|||
|
*---------------------------------------------------------------------**/
|
|||
|
void DetVehicleMode(double ax, double ay, double az);
|
|||
|
|
|||
|
#endif
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|