You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
3.9 KiB

2 years ago
#ifndef __ZMF_SENSOR_H__
#define __ZMF_SENSOR_H__
#ifdef __GNUC__
#pragma GCC visibility push(default)
#endif
/**
* @file zmf_sensor.h
* @brief ZMF Motion interfaces
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ZmfSensorGrvity =1,
ZmfSensorAcceleration =2,
ZmfSensorRotationRate =4,
ZmfSensorAttitude =8,
ZmfSensorLight =16,
} ZmfSensorType;
typedef enum {
ZmfSensorFastest,
ZmfSensorGame,
ZmfSensorUI,
ZmfSensorNormal
} ZmfSensorMode;
typedef struct {
unsigned types;
/** 从开始到现在经过的毫秒数 */
unsigned timeStampMs;
/** 设备参考帧的重力加速度数组 */
float gravity[3];
/** 设备的总重力加速度数组 */
float acceleration[3];
float rotationRate[3];
float pitch, roll, yaw;
float brightness;
} ZmfSensorData;
typedef void (*ZmfSensorCallback)(void* pUser, const ZmfSensorData *sensor);
/**
* @brief
* @param applicationContext
* @return int\n
* 0: \n
* -ZMF_ERROR_API_NOT_SUPPORTED: \n
*/
int Zmf_SensorInitialize (void* applicationContext);
/**
* @brief
* @return int\n
* 0: \n
* -ZMF_ERROR_API_NOT_SUPPORTED: \n
*/
int Zmf_SensorTerminate (void);
/**
* @brief
* @param *sensorTypes ZmfSensorAcceleration|ZmfSensorGrvity|ZmfSensorRotationRate
* @return int\n
* 0: \n
*/
int Zmf_SensorGetTypes (unsigned *sensorTypes);
/**
* @brief
* @param sensorTypes @ref ZmfSensorType
* @param sensorMode @ref ZmfSensorMode
* @return int\n
* 0: \n
* -ZMF_ERROR_API_NOT_SUPPORTED: \n
* @see @ref Zmf_SensorInitialize
*/
int Zmf_SensorStart (unsigned sensorTypes, unsigned sensorMode);
/**
* @brief
* @return int\n
* 0: \n
* @see @ref Zmf_SensorInitialize
*/
int Zmf_SensorStop ();
/**
* @brief
* @param[in] pUser 使NULL
* @param[in] pfnCb NULL
* @return int\n
* 0: \n
*/
int Zmf_SensorAddCallback (void *pUser, ZmfSensorCallback callback);
/**
* @brief
* @param[in] pUser 使NULL
* @return int\n
* 0: \n
*/
int Zmf_SensorRemoveCallback(void *pUser);
/**
* @brief
* @param[out] pitch , [0M_PI].
* @param[out] yaw , [-M_PIM_PI].
* @param[out] roll
* @return int\n
* 0: \n
*/
int Zmf_SensorDataGetAttitude (const ZmfSensorData *sensor, float *pitch, float *roll, float *yaw);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#ifdef __GNUC__
#pragma GCC visibility pop
#endif
#endif /* __ZMF_SENSOR_H__ */