PDR/1.Software/PDR 1.05/include/Pedometer.h

143 lines
4.7 KiB
C
Raw Permalink Normal View History

2022-10-17 20:33:46 +08:00
#pragma once
2023-02-25 22:43:50 +08:00
/******************** (C) COPYRIGHT 2023 Geek************************************
* File Name : Pedometer.h
2022-10-17 20:33:46 +08:00
* Department : Sensor Team
2023-02-25 22:43:50 +08:00
* Current Version : V1.0.0
* Author : logzhan
* Date of Issued : 2023.02.24
2022-10-17 20:33:46 +08:00
*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _STEPS_ALGORITHM_H_
#define _STEPS_ALGORITHM_H_
#include "pdr_sensor.h"
2023-02-25 22:43:50 +08:00
#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 AvergeFilterOrder 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
#define FiltDifNumber 4
#define FILTER_AXIS_NUM AXIS_NUM * FILTER_NUM // <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 AxisNumberStepSaveState 20 // AxisNumberFiltOut + FiltDifNumber
#define ACC_BUFF_NUM 39
#define WIN_LENGTH_AVE_DEVI 50 //
#define PI2A (180/3.1415926)
#define STARTSTEPS 8
#define ACC_INSPECT_TIMEWIDTH 200 // Origin acc sampleFrequency is 100 hz
2022-10-17 20:33:46 +08:00
#define WINDOW_LENGTH_MIN2MAX (ACC_INSPECT_TIMEWIDTH/2 - 1) //25hz , 1 second
2023-02-25 22:43:50 +08:00
2022-10-17 20:33:46 +08:00
#define PLATFORM_PC_WINDOWS
2023-02-25 22:43:50 +08:00
2022-10-17 20:33:46 +08:00
#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;
2023-02-25 22:43:50 +08:00
}StepsDefine_t;
2022-10-17 20:33:46 +08:00
typedef enum {
2023-02-25 22:43:50 +08:00
nonSteps = 0,
2022-10-17 20:33:46 +08:00
walk,
2023-02-25 22:43:50 +08:00
run,
}StepState_t;
2022-10-17 20:33:46 +08:00
typedef struct {
unsigned char sign;
2023-02-25 22:43:50 +08:00
StepState_t state;
2022-10-17 20:33:46 +08:00
unsigned long long stateStartTime;
unsigned long long stepsStartTime;
}stateNowDfine;
typedef struct {
2023-02-25 22:43:50 +08:00
StepState_t state;
2022-10-17 20:33:46 +08:00
unsigned long long startTimeStamp;
2023-02-25 22:43:50 +08:00
}StateDef_t;
2022-10-17 20:33:46 +08:00
typedef struct {
int flag;
double ax;
double ay;
double az;
2023-02-25 22:43:50 +08:00
}DownSample_t;
2022-10-17 20:33:46 +08:00
/**---------------------------------------------------------------------
2023-02-25 22:43:50 +08:00
* Function : Pedometer_GetVersion
2022-10-17 20:33:46 +08:00
* Description : <EFBFBD><EFBFBD>ȡ<EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2023-02-25 22:43:50 +08:00
* Date : 2023/02/24
2022-10-17 20:33:46 +08:00
*---------------------------------------------------------------------**/
2023-02-25 22:43:50 +08:00
const char* Pedometer_GetVersion(void);
2022-10-17 20:33:46 +08:00
/**---------------------------------------------------------------------
* Function : initPedometer
* Description : PDR <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD>
* Date : 2020/2/20 logzhan
*---------------------------------------------------------------------**/
void Pedometer_Init(void);
/**---------------------------------------------------------------------
2023-02-25 22:43:50 +08:00
* Function : Pedometer_ReInit
* Description : <EFBFBD><EFBFBD><EFBFBD>³<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><EFBFBD><EFBFBD>
* Date : 2023/02/24 logzhan
2022-10-17 20:33:46 +08:00
*---------------------------------------------------------------------**/
2023-02-25 22:43:50 +08:00
void Pedometer_ReInit(void);
2022-10-17 20:33:46 +08:00
/**---------------------------------------------------------------------
2023-02-25 22:43:50 +08:00
* Function : PedometerUpdate
2022-10-17 20:33:46 +08:00
* 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>
2023-02-25 22:43:50 +08:00
* Date : 2023/02/25 logzhan <EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-10-17 20:33:46 +08:00
*---------------------------------------------------------------------**/
2023-02-25 22:43:50 +08:00
void Pedometer_Update(IMU_t* ss_data, unsigned long* step);
2022-10-17 20:33:46 +08:00
2023-02-25 22:43:50 +08:00
void Pedometer_GetState(StepState_t* state);
2022-10-17 20:33:46 +08:00
/**---------------------------------------------------------------------
2023-02-25 22:43:50 +08:00
* Function : DetVehicleMode
2022-10-17 20:33:46 +08:00
* 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>
2023-02-25 22:43:50 +08:00
* Date : 2023/02/24 logzhan
2022-10-17 20:33:46 +08:00
*---------------------------------------------------------------------**/
2023-02-25 22:43:50 +08:00
void DetVehicleMode(double ax, double ay, double az);
2022-10-17 20:33:46 +08:00
#endif
#ifdef __cplusplus
}
#endif