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

143 lines
4.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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采样频率100Hz
#define MS2S 1000 // 秒转毫秒单位
#define DOWN_SAMPLE_NUM 4 // 降采样数量
#define ACC_SAMPLE_TIME MS2S / IMU_SAMPLE_FREQ // ACC采样间隔10ms
#define GYRO_SAMPLE_TIME MS2S / IMU_SAMPLE_FREQ // GYR采样间隔10ms
#define SAMPLE_TIME_MIN 9
#define PEDOMETER_FREQ IMU_SAMPLE_FREQ / DOWN_SAMPLE_NUM // 计步器的频率是
#define SampleFrequencyFour 100
#define SampleFrequencydouble 50
#define SampleFrequencyOPF (37.5l)
#define SampleFrequencySix 150
#define AvergeFilterOrder 5
#define AXIS_NUM 4 // 轴的数量有4个: x、y、z、xyz
#define FILTER_NUM 4
#define FiltDifNumber 4
#define FILTER_AXIS_NUM AXIS_NUM * FILTER_NUM // 轴数量4滤波器数量4总共16轴滤波器输出
#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
#define WINDOW_LENGTH_MIN2MAX (ACC_INSPECT_TIMEWIDTH/2 - 1) //25hz , 1 second
#define PLATFORM_PC_WINDOWS
#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;
}stateNowDfine;
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 : 获取计步器版本
* Date : 2023/02/24
*---------------------------------------------------------------------**/
const char* Pedometer_GetVersion(void);
/**---------------------------------------------------------------------
* Function : initPedometer
* Description : PDR 初始化计步器
* Date : 2020/2/20 logzhan
*---------------------------------------------------------------------**/
void Pedometer_Init(void);
/**---------------------------------------------------------------------
* Function : Pedometer_ReInit
* Description : 重新初始化计步器
* Date : 2023/02/24 logzhan
*---------------------------------------------------------------------**/
void Pedometer_ReInit(void);
/**---------------------------------------------------------------------
* Function : PedometerUpdate
* Description : PDR 计步器的加速度输入, 并通过指针返回用户步数
* Date : 2023/02/25 logzhan 重构函数
*---------------------------------------------------------------------**/
void Pedometer_Update(IMU_t* ss_data, unsigned long* step);
void Pedometer_GetState(StepState_t* state);
/**---------------------------------------------------------------------
* Function : DetVehicleMode
* Description : PDR 检测汽车模式, 如果是检测到汽车模式,那么不计步数
* Date : 2023/02/24 logzhan
*---------------------------------------------------------------------**/
void DetVehicleMode(double ax, double ay, double az);
#endif
#ifdef __cplusplus
}
#endif