PDR/3.BackUp/PDR-Origin-Version/include/steps.h

221 lines
7.1 KiB
C
Raw Permalink 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 2017 VIVO************************************
* File Name : Steps_Algorithm.h
* Department : Sensor Team
* Current Version : V1.0
* Author : Xiaoyong Li
* Date of Issued : 2017.05.8
* Comments: step counter algorithm added
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR REFERENCE OR
* EDUCATION. AS A RESULT, VIVO SOFTWARE SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
********************************************************************************
* Release Log
*
* Comments: step counter algorithm released
* Version Number : V1.0
* Author : Xiaoyong Li
* Date of Issued : 2017.05.8
*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _STEPS_ALGORITHM_H_
#define _STEPS_ALGORITHM_H_
#include "pdr_sensor.h"
#define ACC_SAMPLE_RATE_100HZ
//#define ACC_SAMPLE_RATE_25HZ
#ifdef ACC_SAMPLE_RATE_25HZ
#define DownResampleTimes 1
#define ACC_SAMPLE_TIME 40
#define SAMPLE_TIME_MIN 36
#else
#define DOWN_SAMPLE_TIMES 4
#define ACC_SAMPLE_TIME 10 //origin acc sampleFrequency is 100 hz
#define GYRO_SAMPLE_TIME 10
#define SAMPLE_TIME_MIN 9
#endif
#define SampleFrequency 25
#define SampleFrequencyFour 100
#define SampleFrequencydouble 50
#define SampleFrequencyOPF (37.5l)
#define SampleFrequencySix 150
#define AvergeFilterOrder 5
#define AxisNumber 4
#define FiltDifNumber 4
#define AxisNumberFiltOut 16 //(AxisNumber * FiltDifNumber)
#define AxisNumberStepSaveState 20 //(AxisNumberFiltOut + FiltDifNumber)
#define AccelerationNumber 39
#define ORI_ACC_SAMPLE_RATE 100 //origin acc sampleFrequency is 100 hz
#define WIN_LENGTH_AVE_DEVI 50 //
#define PI2A (180/3.1415926)
//#define NSTOS 1000000000
#define MS2S 1000
#define ACC_INSPECT_TIMEWIDTH 200 //origin acc sampleFrequency is 100 hz
#define WINDOW_LENGTH_MIN2MAX (ACC_INSPECT_TIMEWIDTH/2 - 1) //25hz , 1 second
//#define WINDOW_LENGTH_IN_VEHICLE
#define STARTSTEPS 8
/*#define PLATFORM_ANDROID_QCOM_AP*/
/*#define PLATFORM_ANDROID_QCOM_ADSP*/
#define PLATFORM_PC_WINDOWS
//#define PLATFORM_PC_LINUX
#if defined PLATFORM_ANDROID_QCOM_ADSP
#define STEPLIB_MEMSET SNS_OS_MEMSET
#if 1
#define SAM_STEP_LIB_NAME "steplib"
#define SAM_STEP_LIB_MSG_0(msg) UMSG(MSG_SSID_SNS,DBG_ERROR_PRIO, SAM_STEP_LIB_NAME" - "msg)
#define SAM_STEP_LIB_MSG_1(msg,p1) UMSG_1(MSG_SSID_SNS,DBG_ERROR_PRIO, SAM_STEP_LIB_NAME" - "msg,p1)
#define SAM_STEP_LIB_MSG_2(msg,p1,p2) UMSG_2(MSG_SSID_SNS,DBG_ERROR_PRIO, SAM_STEP_LIB_NAME" - "msg,p1,p2)
#define SAM_STEP_LIB_MSG_3(msg,p1,p2,p3) UMSG_3(MSG_SSID_SNS,DBG_ERROR_PRIO, SAM_STEP_LIB_NAME" - "msg,p1,p2,p3)
#define SAM_STEP_LIB_MSG_4(msg,p1,p2,p3,p4) UMSG_4(MSG_SSID_SNS,DBG_ERROR_PRIO, SAM_STEP_LIB_NAME" - "msg,p1,p2,p3,p4)
#else
#define SAM_STEP_LIB_MSG_0(msg)
#define SAM_STEP_LIB_MSG_1(msg,p1)
#define SAM_STEP_LIB_MSG_2(msg,p1,p2)
#define SAM_STEP_LIB_MSG_3(msg,p1,p2,p3)
#define SAM_STEP_LIB_MSG_4(msg,p1,p2,p3,p4)
#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
#if defined PLATFORM_ANDROID_QCOM_SLPI845
#include <string.h>
#include <limits.h>
#include "msg.h"
#include "pb_decode.h"
#include "pb_encode.h"
#include "sns_async_com_port.pb.h"
#include "sns_async_com_port_pb_utils.h"
#include "sns_attribute_util.h"
#include "sns_com_port_types.h"
#include "sns_data_stream.h"
#include "sns_diag.pb.h"
#include "sns_diag_service.h"
#include "sns_event_service.h"
#include "sns_interrupt.pb.h"
#include "sns_math_util.h"
#include "sns_mem_util.h"
#include "sns_proximity.pb.h"
#include "sns_pb_util.h"
#include "sns_physical_sensor_test.pb.h"
#include "sns_pwr_rail_service.h"
#include "sns_rc.h"
#include "sns_register.h"
#include "sns_request.h"
#include "sns_sensor.h"
#include "sns_sensor_event.h"
#include "sns_sensor_instance.h"
#include "sns_sensor_uid.h"
#include "sns_sensor_util.h"
#include "sns_service.h"
#include "sns_service_manager.h"
#include "sns_std.pb.h"
#include "sns_std_event_gated_sensor.pb.h"
#include "sns_std_sensor.pb.h"
#include "sns_stream_service.h"
#include "sns_suid.pb.h"
#include "sns_sync_com_port_service.h"
#include "sns_time.h"
#include "sns_timer.pb.h"
#include "sns_cal.pb.h"
#include "sns_types.h"
#include "sns_printf.h"
#include "sns_registry_util.h"
#endif
typedef struct {
unsigned long walkSteps;
}stepsRe;
typedef struct {
double walk;
double walkRealTime;
double nD;
}stepsDfine;
typedef enum {
nonSteps = 0,
walk,
}enumState;
typedef struct {
unsigned char sign;
enumState state;
unsigned long long stateStartTime;
unsigned long long stepsStartTime;
}stateNowDfine;
typedef struct {
enumState state;
unsigned long long startTimeStamp;
}stateDfine;
typedef struct {
int flag;
double ax;
double ay;
double az;
}downSample;
/**---------------------------------------------------------------------
* Function : getPedometerLibVersion
* Description : <20><>ȡ<EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD>
* Date : 2020/2/20 yuanlin_rjyb@vivo.com & zhanli@vivo.com
*---------------------------------------------------------------------**/
const char* getPedometerLibVersion(void);
/**---------------------------------------------------------------------
* Function : initPedometer
* Description : PDR <20><>ʼ<EFBFBD><CABC><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>
* Date : 2020/2/20 yuanlin_rjyb@vivo.com & zhanli@vivo.com
*---------------------------------------------------------------------**/
void initPedometer(void);
/**---------------------------------------------------------------------
* Function : reinitPedometer
* Description : PDR <20><><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>
* Date : 2020/2/20 yuanlin_rjyb@vivo.com & zhanli@vivo.com
*---------------------------------------------------------------------**/
void reinitPedometer(void);
/**---------------------------------------------------------------------
* Function : updatePedometer
* Description : PDR <20>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ٶ<EFBFBD><D9B6><EFBFBD><EFBFBD><EFBFBD>, <20><>ͨ<EFBFBD><CDA8>ָ<EFBFBD><EFBFBD><EBB7B5><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
* Date : 2020/2/1 yuanlin_rjyb@vivo.com & zhanli@vivo.com
*---------------------------------------------------------------------**/
void updatePedometer(imu* ss_data, unsigned long* step);
void Steps_State_Detect(enumState* state);
/**---------------------------------------------------------------------
* Function : detVehicleMode
* Description : PDR <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ, <20><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD><E2B5BD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>
* Date : 2020/2/1 yuanlin_rjyb@vivo.com & zhanli@vivo.com
*---------------------------------------------------------------------**/
void detVehicleMode(double ax, double ay, double az);
#endif
#ifdef __cplusplus
}
#endif