M5Unit-IMU 0.0.2 git rev:e5b00aa
Loading...
Searching...
No Matches
imu_types.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_IMU_IMU_IMU_TYPES_HPP
11#define M5_UNIT_IMU_IMU_IMU_TYPES_HPP
12
13#include <cstdint>
14
15namespace m5 {
16namespace imu {
17
22enum class Capability : uint8_t {
23 None = 0,
24 Accel = 1 << 0,
25 Gyro = 1 << 1,
26 Mag = 1 << 2,
27 Baro = 1 << 3,
28 Temp = 1 << 4,
29};
30
32constexpr Capability operator|(const Capability a, const Capability b)
33{
34 return static_cast<Capability>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
35}
37constexpr Capability operator&(const Capability a, const Capability b)
38{
39 return static_cast<Capability>(static_cast<uint8_t>(a) & static_cast<uint8_t>(b));
40}
43{
44 a = a | b;
45 return a;
46}
48constexpr bool any(const Capability c)
49{
50 return c != Capability::None;
51}
52
58 int16_t accel[3]{};
59 int16_t gyro[3]{};
60 int32_t mag[3]{};
61 int32_t baro{};
62 int16_t temp{};
63};
64
70 float accel_res{8.0f / 32768};
71 float gyro_res{2000.0f / 32768};
72 float mag_res{4912.0f / 32760};
73 float temp_res{1.0f};
74 float temp_offset{0.0f};
75};
76
82 float accel[3]{};
83 float gyro[3]{};
84 float mag[3]{};
85 float temp{};
86};
87
88} // namespace imu
89} // namespace m5
90#endif
Capability & operator|=(Capability &a, const Capability b)
Bitwise OR assignment.
Definition imu_types.hpp:42
constexpr Capability operator&(const Capability a, const Capability b)
Bitwise AND.
Definition imu_types.hpp:37
constexpr Capability operator|(const Capability a, const Capability b)
Bitwise OR.
Definition imu_types.hpp:32
constexpr bool any(const Capability c)
Any bit set?
Definition imu_types.hpp:48
Capability
Capability of the IMU data source (bitwise combinable)
Definition imu_types.hpp:22
@ Accel
3-axis accelerometer
@ Mag
3-axis magnetometer
@ Temp
Temperature output.
@ Baro
Barometric pressure (reserved for future)
@ Gyro
3-axis gyroscope
Top level namespace of M5Stack.
Definition ahrs_controller.cpp:26
Raw to physical unit conversion coefficients.
Definition imu_types.hpp:69
float gyro_res
dps per LSB
Definition imu_types.hpp:71
float temp_res
degC per LSB
Definition imu_types.hpp:73
float mag_res
uT per LSB
Definition imu_types.hpp:72
float accel_res
G per LSB.
Definition imu_types.hpp:70
float temp_offset
degC offset
Definition imu_types.hpp:74
Merged, converted physical-unit IMU sample (AhrsController::latest())
Definition imu_types.hpp:81
float gyro[3]
Gyroscope X/Y/Z (dps)
Definition imu_types.hpp:83
float accel[3]
Accelerometer X/Y/Z (G)
Definition imu_types.hpp:82
float temp
Temperature (degC)
Definition imu_types.hpp:85
float mag[3]
Magnetometer X/Y/Z (uT)
Definition imu_types.hpp:84
Unified raw data (chip-native axes, no remap applied)
Definition imu_types.hpp:57
int16_t temp
Raw temperature.
Definition imu_types.hpp:62
int16_t accel[3]
Raw accelerometer X/Y/Z.
Definition imu_types.hpp:58
int32_t baro
Raw pressure (reserved)
Definition imu_types.hpp:61
int16_t gyro[3]
Raw gyroscope X/Y/Z.
Definition imu_types.hpp:59
int32_t mag[3]
Raw magnetometer X/Y/Z (32bit for BMM350)
Definition imu_types.hpp:60