mcu_ab568x/app/platform/libs/imu_10M.h
2025-05-30 18:03:10 +08:00

57 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* imu_10M.h
*
* Created on: 2022年10月7日
* Author: Connor.zhang
*/
#ifndef IMU_H_
#define IMU_H_
#include <stdint.h>
typedef struct
{
int16_t x;
int16_t y;
int16_t Speed;
int16_t X_Throw;
int16_t Y_Throw;
int16_t Speed_Throw;
int8_t Count_Throw;
int16_t X_Move_Distance;
int16_t Y_Move_Distance;
}game_data_struct;
extern uint8_t lib_imu_3axis_10M_version;//获取当前库的版本号0~99; 10表示1.0;20就表示2.0.
/*读取IMU数据处理的初始化 ,每次进入游戏前调用一次
* param: freq_Hz: 处理的频率; 比如1000 Hz,就填1000; 200Hz,就填200
*/
void imu_10M_init(int16_t freq_Hz);
/*
* IMU_10M_DataHandle 处理陀螺仪/加速计数据,输出速度等信息。
* x轴正向 为 手表平放时 手表正前方。
* y轴正向为 手表平方时 手边左侧方向。
* z轴正向为 手表平方时 手边正上方。
*
*param:
* freq_Hz: 处理的频率; 比如1000 Hz,就填1000; 200Hz,就填200
* gyro: 校准后的陀螺仪数据地址弧度单位gyro[0]: 陀螺仪 X轴; gyro[1]: 陀螺仪 Y轴; gyro[2]: 陀螺仪 Z轴; <<<<<<<之前使用的陀螺仪设置量程:+-500也可以调大试试>>>>>>>>>>
* acc: 校准后的加速计数据地址, acc[0]: 加速计 X轴; acc[1]: 加速计Y轴; acc[2]: 加速计 Z轴; <<<<<<<之前使用的加速计设置量程: +-4G; 也可以调大试试>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
加速计数据需要而外处理一下,如下:
传入IMU_10M_DataHandle前需要先行处理如下
acc[0],acc[1],acc[2]输入到IMU_10M_DataHandle 的数据。
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
* throw_speed_threshold 投掷速度判断门限值, 游戏应用app通过指令 0x53 第二个数据字节设置。
*output: 输出game_data_struct 格式数据对应和游戏app通讯的0x55指令数据格式
*/
void IMU_10M_DataHandle(int16_t *acc, game_data_struct *output);
#endif /* IMU_H_ */