Move private IMU data into its mgos_imu_internal.h
This commit is contained in:
@ -17,20 +17,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "mgos.h"
|
||||
#include "mgos_i2c.h"
|
||||
|
||||
struct mgos_imu_mag;
|
||||
struct mgos_imu_acc;
|
||||
struct mgos_imu_gyro;
|
||||
|
||||
typedef bool (*mgos_imu_mag_detect_fn)(struct mgos_imu_mag *dev);
|
||||
typedef bool (*mgos_imu_mag_start_fn)(struct mgos_imu_mag *dev);
|
||||
typedef bool (*mgos_imu_mag_read_fn)(struct mgos_imu_mag *dev);
|
||||
typedef bool (*mgos_imu_acc_detect_fn)(struct mgos_imu_acc *dev);
|
||||
typedef bool (*mgos_imu_acc_start_fn)(struct mgos_imu_acc *dev);
|
||||
typedef bool (*mgos_imu_acc_read_fn)(struct mgos_imu_acc *dev);
|
||||
typedef bool (*mgos_imu_gyro_detect_fn)(struct mgos_imu_gyro *dev);
|
||||
typedef bool (*mgos_imu_gyro_start_fn)(struct mgos_imu_gyro *dev);
|
||||
typedef bool (*mgos_imu_gyro_read_fn)(struct mgos_imu_gyro *dev);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum mgos_imu_acc_type {
|
||||
ACC_NONE = 0,
|
||||
@ -47,53 +38,7 @@ enum mgos_imu_mag_type {
|
||||
MAG_AK8963
|
||||
};
|
||||
|
||||
struct mgos_imu {
|
||||
struct mgos_imu_mag *mag;
|
||||
struct mgos_imu_acc *acc;
|
||||
struct mgos_imu_gyro *gyro;
|
||||
};
|
||||
|
||||
struct mgos_imu_mag {
|
||||
mgos_imu_mag_detect_fn detect;
|
||||
mgos_imu_mag_start_fn start;
|
||||
mgos_imu_mag_read_fn read;
|
||||
|
||||
struct mgos_i2c *i2c;
|
||||
uint8_t i2caddr;
|
||||
enum mgos_imu_mag_type type;
|
||||
|
||||
float gain[3];
|
||||
int16_t data[3];
|
||||
};
|
||||
|
||||
struct mgos_imu_acc {
|
||||
mgos_imu_acc_detect_fn detect;
|
||||
mgos_imu_acc_start_fn start;
|
||||
mgos_imu_acc_read_fn read;
|
||||
|
||||
struct mgos_i2c *i2c;
|
||||
uint8_t i2caddr;
|
||||
enum mgos_imu_acc_type type;
|
||||
|
||||
float scale;
|
||||
int16_t data[3];
|
||||
};
|
||||
|
||||
struct mgos_imu_gyro {
|
||||
mgos_imu_gyro_detect_fn detect;
|
||||
mgos_imu_gyro_start_fn start;
|
||||
mgos_imu_gyro_read_fn read;
|
||||
|
||||
struct mgos_i2c *i2c;
|
||||
uint8_t i2caddr;
|
||||
enum mgos_imu_gyro_type type;
|
||||
|
||||
float scale;
|
||||
float bias[3];
|
||||
int16_t data[3];
|
||||
int16_t temperature;
|
||||
};
|
||||
|
||||
struct mgos_imu;
|
||||
|
||||
struct mgos_imu *mgos_imu_create_i2c(struct mgos_i2c *i2c);
|
||||
bool mgos_imu_add_gyroscope_i2c(struct mgos_imu *sensor, uint8_t i2caddr, enum mgos_imu_gyro_type type);
|
||||
@ -106,23 +51,26 @@ bool mgos_imu_has_accelerometer(struct mgos_imu *sensor);
|
||||
bool mgos_imu_has_gyroscope(struct mgos_imu *sensor);
|
||||
bool mgos_imu_has_magnetometer(struct mgos_imu *sensor);
|
||||
|
||||
/* Read all available sensor data in the IMU */
|
||||
/* Read all available sensor data from the IMU */
|
||||
bool mgos_imu_read(struct mgos_imu *sensor);
|
||||
|
||||
/* Return accelerometer data in units of G */
|
||||
/* Return accelerometer data in units of m/s/s */
|
||||
bool mgos_imu_get_accelerometer(struct mgos_imu *sensor, float *x, float *y, float *z);
|
||||
|
||||
/* Return accelerometer data in units of deg/sec rotation rate */
|
||||
bool mgos_imu_get_gyroscope(struct mgos_imu *sensor, float *x, float *y, float *z);
|
||||
|
||||
/* Return magnetometer data in units of microTesla */
|
||||
/* Return magnetometer data in units of microtesla (1 microtesla = 10 milligauss) */
|
||||
bool mgos_imu_get_magnetometer(struct mgos_imu *sensor, float *x, float *y, float *z);
|
||||
|
||||
/* Return compass heading based on magnetometer data, from [0..359] */
|
||||
bool mgos_imu_get_compass_heading(struct mgos_imu *sensor, uint16_t *heading);
|
||||
|
||||
/*
|
||||
* Initialization function for MGOS -- currently a noop.
|
||||
*/
|
||||
bool mgos_imu_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user