FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
mpu6050.h
Go to the documentation of this file.
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
23#ifndef MPU6050_H
24#define MPU6050_H
25
26#include <math.h>
27#include <stdint.h>
28#include "common_magneto.h"
29#include "../array.h"
30#include "../bits.h"
31#include "../functors.h"
32#include "../i2c_device.h"
33#include "../i2c_device_utilities.h"
34#include "../utilities.h"
35
36//TODO rename namespace: "magneto" is not relevant here, eg "motion" or "motion_sensor"
37namespace devices::magneto
38{
45 enum class GyroRange : uint8_t
46 {
47 RANGE_250 = 0 << 3,
48 RANGE_500 = 1 << 3,
49 RANGE_1000 = 2 << 3,
50 RANGE_2000 = 3 << 3,
51 };
52
56 static constexpr uint16_t GYRO_RANGE_DPS(GyroRange range)
57 {
58 if (range == GyroRange::RANGE_2000) return 2000;
59 if (range == GyroRange::RANGE_1000) return 1000;
60 if (range == GyroRange::RANGE_500) return 500;
61 return 250;
62 }
63
70 enum class AccelRange : uint8_t
71 {
72 RANGE_2G = 0 << 3,
73 RANGE_4G = 1 << 3,
74 RANGE_8G = 2 << 3,
75 RANGE_16G = 3 << 3,
76 };
77
81 static constexpr uint16_t ACCEL_RANGE_G(AccelRange range)
82 {
83 if (range == AccelRange::RANGE_16G) return 16;
84 if (range == AccelRange::RANGE_8G) return 8;
85 if (range == AccelRange::RANGE_4G) return 4;
86 return 2;
87 }
88
95 enum class ClockSelect : uint8_t
96 {
97 INTERNAL_8MHZ = 0,
98 PLL_X_AXIS_GYRO = 1,
99 PLL_Y_AXIS_GYRO = 2,
100 PLL_Z_AXIS_GYRO = 3,
101 PLL_EXTERNAL_32KHZ = 4,
102 PLL_EXTERNAL_19MHZ = 5,
103 STOPPED = 7
104 };
105
117 enum class DLPF : uint8_t
118 {
119 ACCEL_BW_260HZ = 0,
120 ACCEL_BW_184HZ = 1,
121 ACCEL_BW_94HZ = 2,
122 ACCEL_BW_44HZ = 3,
123 ACCEL_BW_21HZ = 4,
124 ACCEL_BW_10HZ = 5,
125 ACCEL_BW_5HZ = 6,
126
127 GYRO_BW_256HZ = 0,
128 GYRO_BW_188HZ = 1,
129 GYRO_BW_98HZ = 2,
130 GYRO_BW_42HZ = 3,
131 GYRO_BW_20HZ = 4,
132 GYRO_BW_10HZ = 5,
133 GYRO_BW_5HZ = 6
134 };
135
144 {
145 public:
154 constexpr FIFOEnable(
155 bool accel = false, bool gyro_x = false, bool gyro_y = false, bool gyro_z = false, bool temperature = false)
156 : data_{bits::ORIF8(accel, ACCEL_FIFO_EN, temperature, TEMP_FIFO_EN,
157 gyro_x, XG_FIFO_EN, gyro_y, YG_FIFO_EN, gyro_z, ZG_FIFO_EN)} {}
158
160 bool accel() const
161 {
162 return data_ & ACCEL_FIFO_EN;
163 }
164
166 bool gyro_x() const
167 {
168 return data_ & XG_FIFO_EN;
169 }
170
172 bool gyro_y() const
173 {
174 return data_ & YG_FIFO_EN;
175 }
176
178 bool gyro_z() const
179 {
180 return data_ & ZG_FIFO_EN;
181 }
182
184 bool temperature() const
185 {
186 return data_ & TEMP_FIFO_EN;
187 }
188
189 private:
190 static constexpr uint8_t TEMP_FIFO_EN = bits::BV8(7);
191 static constexpr uint8_t XG_FIFO_EN = bits::BV8(6);
192 static constexpr uint8_t YG_FIFO_EN = bits::BV8(5);
193 static constexpr uint8_t ZG_FIFO_EN = bits::BV8(4);
194 static constexpr uint8_t ACCEL_FIFO_EN = bits::BV8(3);
195
196 uint8_t data_;
197 };
198
208 {
209 public:
215 constexpr INTStatus(bool data_ready = false, bool overflow = false)
216 : data_{bits::ORIF8(data_ready, DATA_RDY_INT, overflow, FIFO_OFLOW_INT)} {}
217
219 bool data_ready() const
220 {
221 return data_ & DATA_RDY_INT;
222 }
223
225 bool overflow() const
226 {
227 return data_ & FIFO_OFLOW_INT;
228 }
229
230 private:
231 static constexpr uint8_t FIFO_OFLOW_INT = bits::BV8(4);
232 static constexpr uint8_t DATA_RDY_INT = bits::BV8(0);
233
234 uint8_t data_;
235 };
236
244
252 {
256 int16_t temperature;
259 };
260
267 enum class AD0 : uint8_t
268 {
270 LOW = 0,
272 HIGH = 1
273 };
274
281 template<typename MANAGER>
282 class MPU6050 : public i2c::I2CDevice<MANAGER>
283 {
284 private:
286 template<typename OUT, typename IN> using FUTURE = typename PARENT::template FUTURE<OUT, IN>;
287
288 // Forward declarations needed by compiler
289 template<uint8_t REGISTER, typename T = uint8_t, typename FUNCTOR = functor::ChangeEndianness<T>>
291 template<uint8_t REGISTER, typename T = uint8_t, typename FUNCTOR = functor::ChangeEndianness<T>>
293
294 template<uint8_t REGISTER>
296
297 static constexpr const uint8_t SMPRT_DIV = 0x19;
298 static constexpr const uint8_t CONFIG = 0x1A;
299 static constexpr const uint8_t GYRO_CONFIG = 0x1B;
300 static constexpr const uint8_t ACCEL_CONFIG = 0x1C;
301
302 static constexpr const uint8_t FIFO_EN = 0x23;
303 static constexpr const uint8_t INT_PIN_CFG = 0x37;
304 static constexpr const uint8_t INT_ENABLE = 0x38;
305 static constexpr const uint8_t INT_STATUS = 0x3A;
306
307 static constexpr const uint8_t ACCEL_XOUT = 0x3B;
308 static constexpr const uint8_t TEMP_OUT = 0x41;
309 static constexpr const uint8_t GYRO_XOUT = 0x43;
310
311 static constexpr const uint8_t USER_CTRL = 0x6A;
312 static constexpr const uint8_t FIFO_RESET = 0x04;
313 static constexpr const uint8_t FIFO_ENABLE = 0x40;
314
315 static constexpr const uint8_t PWR_MGMT_1 = 0x6B;
316 static constexpr const uint8_t PWR_MGMT_2 = 0x6C;
317
318 static constexpr const uint8_t FIFO_COUNT = 0x72;
319 static constexpr const uint8_t FIFO_R_W = 0x74;
320
321 static constexpr const uint8_t WHO_AM_I = 0x75;
322
323 class PowerManagement;
325
326 public:
336 explicit MPU6050(MANAGER& manager, AD0 ad0 = AD0::LOW)
337 : PARENT{manager, DEVICE_ADDRESS(ad0), i2c::I2C_FAST, true} {}
338
339 // Asynchronous API
340 //==================
355 class BeginFuture : public FUTURE<void, containers::array<uint8_t, 6>>
356 {
357 using PARENT = FUTURE<void, containers::array<uint8_t, 6>>;
358 public:
360 explicit BeginFuture( GyroRange gyro_range = GyroRange::RANGE_250,
361 AccelRange accel_range = AccelRange::RANGE_2G,
362 DLPF low_pass_filter = DLPF::ACCEL_BW_260HZ,
363 ClockSelect clock_select = ClockSelect::INTERNAL_8MHZ)
364 : PARENT{{ CONFIG, uint8_t(low_pass_filter), uint8_t(gyro_range), uint8_t(accel_range),
365 PWR_MGMT_1, utils::as_uint8_t(PowerManagement{clock_select})}} {}
367 };
368
391 {
392 // We split the transaction in 2 write commands (3 bytes starting at CONFIG, 1 byte at PWR_MGT_1)
393 return this->launch_commands(future, {this->write(4), this->write(2)});
394 }
395
416 class FifoBeginFuture : public FUTURE<void, containers::array<uint8_t, 15>>
417 {
418 using PARENT = FUTURE<void, containers::array<uint8_t, 15>>;
419 public:
421 explicit FifoBeginFuture( FIFOEnable fifo_enable,
422 INTEnable int_enable,
423 uint8_t sample_rate_divider,
424 GyroRange gyro_range = GyroRange::RANGE_250,
425 AccelRange accel_range = AccelRange::RANGE_2G,
426 DLPF low_pass_filter = DLPF::ACCEL_BW_260HZ,
427 ClockSelect clock_select = ClockSelect::INTERNAL_8MHZ)
428 : PARENT{{ CONFIG, uint8_t(low_pass_filter), uint8_t(gyro_range), uint8_t(accel_range),
429 PWR_MGMT_1, utils::as_uint8_t(PowerManagement{clock_select}),
430 SMPRT_DIV, sample_rate_divider,
431 FIFO_EN, utils::as_uint8_t(fifo_enable),
432 INT_PIN_CFG, 0, utils::as_uint8_t(int_enable),
433 USER_CTRL, FIFO_ENABLE | FIFO_RESET}} {}
435 };
436
461 {
462 return this->launch_commands(future, {
463 // CONFIG, GYRO_CONFIG, ACCEL_CONFIG
464 this->write(4),
465 // PWR_MGMT_1
466 this->write(2),
467 // SMPRT_DIV
468 this->write(2),
469 // FIFO_EN
470 this->write(2),
471 // INT_PIN_CFG
472 this->write(3),
473 // USER_CONTROL
474 this->write(2),
475 });
476 }
477
487 {
488 public:
490 EndFuture() : PowerManagementFuture{PowerManagement{false, false, true, false}} {}
492 };
493
514 {
515 // Put to sleep mode
516 return this->async_write(future);
517 }
518
528 {
529 public:
531 ResetFuture() : PowerManagementFuture{PowerManagement{false, false, false, true}} {}
533 };
534
552 {
553 return this->async_write(future);
554 }
555
565
583 {
584 return this->async_read(future);
585 }
586
599
619 {
620 return this->async_read(future);
621 }
622
627 static constexpr int16_t convert_temp_to_centi_degrees(int16_t temp)
628 {
629 // MPU-6000 Register Map datasheet §4.18 formula: Tc = TEMP / 340 + 36.53
630 return int16_t(temp * 10L / 34L + 3653);
631 }
632
642
660 {
661 return this->async_read(future);
662 }
663
674
693 {
694 return this->async_read(future);
695 }
696
706
726 {
727 return this->async_read(future);
728 }
729
740
758 {
759 return this->async_write(future);
760 }
761
771
793 {
794 return this->async_read(future);
795 }
796
811 template<typename T>
813
838 template<typename T> int fifo_pop(FifoPopFuture<T>& future)
839 {
840 return this->async_read(future);
841 }
842
854
876 {
877 return this->async_write(future);
878 }
879
880 // Synchronous API
881 //=================
899 bool begin( GyroRange gyro_range = GyroRange::RANGE_250,
900 AccelRange accel_range = AccelRange::RANGE_2G,
901 DLPF low_pass_filter = DLPF::ACCEL_BW_260HZ,
902 ClockSelect clock_select = ClockSelect::INTERNAL_8MHZ)
903 {
904 BeginFuture future{gyro_range, accel_range, low_pass_filter, clock_select};
905 if (begin(future) != 0) return false;
906 return (future.await() == future::FutureStatus::READY);
907 }
908
936 bool begin( FIFOEnable fifo_enable,
937 INTEnable int_enable,
938 uint8_t sample_rate_divider,
939 GyroRange gyro_range = GyroRange::RANGE_250,
940 AccelRange accel_range = AccelRange::RANGE_2G,
941 DLPF low_pass_filter = DLPF::ACCEL_BW_260HZ,
942 ClockSelect clock_select = ClockSelect::INTERNAL_8MHZ)
943 {
945 fifo_enable, int_enable, sample_rate_divider, gyro_range, accel_range, low_pass_filter, clock_select};
946 if (begin(future) != 0) return false;
947 return (future.await() == future::FutureStatus::READY);
948 }
949
961 bool end() INLINE
962 {
963 return this->template sync_write<EndFuture>();
964 }
965
976 {
977 return this->template sync_write<ResetFuture>();
978 }
979
992 {
993 return this->template sync_read<GyroFuture>(gyro);
994 }
995
1008 int16_t temperature()
1009 {
1010 int16_t temp = INT16_MIN;
1011 this->template sync_read<TemperatureFuture>(temp);
1012 return temp;
1013 }
1014
1027 {
1028 return this->template sync_read<AccelFuture>(accel);
1029 }
1030
1044 {
1045 return this->template sync_read<AllMeasuresFuture>(sensors);
1046 }
1047
1061 {
1062 INTStatus status;
1063 this->template sync_read<InterruptStatusFuture>(status);
1064 return status;
1065 }
1066
1077 {
1078 return this->template sync_write<ResetFifoFuture>();
1079 }
1080
1095 uint16_t fifo_count()
1096 {
1097 uint16_t count = 0;
1098 this->template sync_read<FifoCountFuture>(count);
1099 return count;
1100 }
1101
1121 template<typename T> bool fifo_pop(T& output)
1122 {
1123 return this->template sync_read<FifoPopFuture<T>>(output);
1124 }
1125
1136 bool fifo_push(uint8_t data)
1137 {
1138 return this->template sync_write<FifoPushFuture>(data);
1139 }
1140
1141 private:
1142 class PowerManagement
1143 {
1144 public:
1145 constexpr PowerManagement() : value_{} {}
1146 explicit constexpr PowerManagement(ClockSelect clock_select, bool temp_disable = false,
1147 bool cycle = false, bool sleep = false, bool device_reset = false)
1148 : value_{ bits::OR8(uint8_t(clock_select), bits::IF8(temp_disable, TEMP_DIS_MASK),
1149 bits::IF8(cycle, CYCLE_MASK), bits::IF8(sleep, SLEEP_MASK),
1150 bits::IF8(device_reset, RESET_MASK))} {}
1151 constexpr PowerManagement(bool temp_disable, bool cycle, bool sleep, bool device_reset)
1152 : value_{ bits::ORIF8(temp_disable, TEMP_DIS_MASK, cycle, CYCLE_MASK,
1153 sleep, SLEEP_MASK, device_reset, RESET_MASK)} {}
1154
1155 ClockSelect clock_select() const
1156 {
1157 return static_cast<ClockSelect>(value_ & CLOCK_SEL_MASK);
1158 }
1159
1160 bool temp_disable() const
1161 {
1162 return value_ & TEMP_DIS_MASK;
1163 }
1164
1165 bool cycle() const
1166 {
1167 return value_ & CYCLE_MASK;
1168 }
1169
1170 bool sleep() const
1171 {
1172 return value_ & SLEEP_MASK;
1173 }
1174
1175 bool device_reset() const
1176 {
1177 return value_ & RESET_MASK;
1178 }
1179
1180 private:
1181 static constexpr uint8_t CLOCK_SEL_MASK = bits::BV8(0, 1, 2);
1182 static constexpr uint8_t TEMP_DIS_MASK = bits::BV8(3);
1183 static constexpr uint8_t CYCLE_MASK = bits::BV8(5);
1184 static constexpr uint8_t SLEEP_MASK = bits::BV8(6);
1185 static constexpr uint8_t RESET_MASK = bits::BV8(7);
1186 uint8_t value_;
1187 };
1188
1189 static constexpr uint8_t DEVICE_ADDRESS(AD0 ad0)
1190 {
1191 return uint8_t(uint8_t(0x68 | uint8_t(ad0)) << 1);
1192 }
1193 };
1194}
1195
1196#endif /* MPU6050_H */
Configuration for MPU6050 FIFO Enable register (register map §4.6).
Definition: mpu6050.h:144
bool temperature() const
If true, chip temperature will be loaded to FIFO buffer.
Definition: mpu6050.h:184
bool accel() const
If true, accelerometer measures on 3 axes will be loaded to FIFO buffer.
Definition: mpu6050.h:160
bool gyro_x() const
If true, gyroscope measures on X axis will be loaded to FIFO buffer.
Definition: mpu6050.h:166
constexpr FIFOEnable(bool accel=false, bool gyro_x=false, bool gyro_y=false, bool gyro_z=false, bool temperature=false)
Create a new FIFOEnable configuration value.
Definition: mpu6050.h:154
bool gyro_z() const
If true, gyroscope measures on Z axis will be loaded to FIFO buffer.
Definition: mpu6050.h:178
bool gyro_y() const
If true, gyroscope measures on Y axis will be loaded to FIFO buffer.
Definition: mpu6050.h:172
The structure of the Interrupt Status register (register map §4.16).
Definition: mpu6050.h:208
bool overflow() const
If true, a FIFO buffer overflow will generate an interrupt.
Definition: mpu6050.h:225
bool data_ready() const
If true, the Data Ready interrupt is enabled.
Definition: mpu6050.h:219
constexpr INTStatus(bool data_ready=false, bool overflow=false)
Create a new INTStatus configuration value.
Definition: mpu6050.h:215
Create a future to be used by asynchronous method begin(BeginFuture&).
Definition: mpu6050.h:356
Create a future to be used by asynchronous method end(EndFuture&).
Definition: mpu6050.h:487
Create a future to be used by asynchronous method begin(FifoBeginFuture&).
Definition: mpu6050.h:417
Create a future to be used by asynchronous method reset(ResetFuture&).
Definition: mpu6050.h:528
I2C device driver for the MPU6050 gyroscope/accelerometer chip.
Definition: mpu6050.h:283
MPU6050(MANAGER &manager, AD0 ad0=AD0::LOW)
Create a new device driver for a MPU6050 chip.
Definition: mpu6050.h:336
int fifo_count(FifoCountFuture &future)
Get the number of bytes currently stored in the FIFO buffer (register map §4.30).
Definition: mpu6050.h:792
bool begin(FIFOEnable fifo_enable, INTEnable int_enable, uint8_t sample_rate_divider, GyroRange gyro_range=GyroRange::RANGE_250, AccelRange accel_range=AccelRange::RANGE_2G, DLPF low_pass_filter=DLPF::ACCEL_BW_260HZ, ClockSelect clock_select=ClockSelect::INTERNAL_8MHZ)
Start operation of this gyroscope/accelerometer chip.
Definition: mpu6050.h:936
bool accel_measures(Sensor3D &accel)
Get latest accelerometer measurements from the device (register map §4.17).
Definition: mpu6050.h:1026
int gyro_measures(GyroFuture &future)
Get latest gyroscope measurements from the device (register map §4.19).
Definition: mpu6050.h:582
bool reset_fifo()
Reset the FIFO buffer (parameter map §4.27).
Definition: mpu6050.h:1076
int end(EndFuture &future) INLINE
Put the chip to sleep mode (low-power mode); stops sampling operations if any.
Definition: mpu6050.h:513
int all_measures(AllMeasuresFuture &future)
Get latest measurements of all device sensors (gyroscope, accelerometer, temperature).
Definition: mpu6050.h:692
bool fifo_push(uint8_t data)
Push one byte to the FIFO buffer (register map §4.31).
Definition: mpu6050.h:1136
uint16_t fifo_count()
Get the number of bytes currently stored in the FIFO buffer (register map §4.30).
Definition: mpu6050.h:1095
bool gyro_measures(Sensor3D &gyro)
Get latest gyroscope measurements from the device (register map §4.19).
Definition: mpu6050.h:991
bool all_measures(AllSensors &sensors)
Get latest measurements of all device sensors (gyroscope, accelerometer, temperature).
Definition: mpu6050.h:1043
int begin(FifoBeginFuture &future)
Start operation of this gyroscope/accelerometer chip.
Definition: mpu6050.h:460
static constexpr int16_t convert_temp_to_centi_degrees(int16_t temp)
Convert the raw temperature obtained from temperature() to centi-degrees Celsius.
Definition: mpu6050.h:627
bool reset() INLINE
Reset the chip (register map §4.28).
Definition: mpu6050.h:975
bool begin(GyroRange gyro_range=GyroRange::RANGE_250, AccelRange accel_range=AccelRange::RANGE_2G, DLPF low_pass_filter=DLPF::ACCEL_BW_260HZ, ClockSelect clock_select=ClockSelect::INTERNAL_8MHZ)
Start operation of this gyroscope/accelerometer chip.
Definition: mpu6050.h:899
int accel_measures(AccelFuture &future)
Get latest accelerometer measurements from the device (register map §4.17).
Definition: mpu6050.h:659
int reset_fifo(ResetFifoFuture &future)
Reset the FIFO buffer (parameter map §4.27).
Definition: mpu6050.h:757
int fifo_push(FifoPushFuture &future)
Push one byte to the FIFO buffer (register map §4.31).
Definition: mpu6050.h:875
int reset(ResetFuture &future) INLINE
Reset the chip (register map §4.28).
Definition: mpu6050.h:551
int temperature(TemperatureFuture &future)
Get latest chip temperature measurement (register map §4.18).
Definition: mpu6050.h:618
int begin(BeginFuture &future)
Start operation of this gyroscope/accelerometer chip.
Definition: mpu6050.h:390
int fifo_pop(FifoPopFuture< T > &future)
Get one sample out of the FIFO buffer (register map §4.31).
Definition: mpu6050.h:838
INTStatus interrupt_status()
Get the interrupt status (register map §4.16) after an interrupt has occurred.
Definition: mpu6050.h:1060
bool end() INLINE
Put the chip to sleep mode (low-power mode); stops sampling operations if any.
Definition: mpu6050.h:961
bool fifo_pop(T &output)
Get one sample out of the FIFO buffer (register map §4.31).
Definition: mpu6050.h:1121
int interrupt_status(InterruptStatusFuture &future)
Get the interrupt status (register map §4.16) after an interrupt has occurred.
Definition: mpu6050.h:725
int16_t temperature()
Get latest chip temperature measurement (register map §4.18).
Definition: mpu6050.h:1008
Base class for all I2C devices.
Definition: i2c_device.h:84
static constexpr I2CLightCommand write(uint8_t write_count=0, bool finish_future=false, bool stop=false)
Build a write I2CLightCommand that can be later pushed to the I2C Manager for proper handling.
Definition: i2c_device.h:202
int async_write(F &future, bool stop=true)
Helper method that asynchronously launches I2C commands for a simple Future performing only one write...
Definition: i2c_device.h:357
MANAGER MANAGER
the type of I2C Manager that can handle this device.
Definition: i2c_device.h:87
int async_read(F &future, bool stop=true)
Helper method that asynchronously launches I2C commands for a simple Future performing one write foll...
Definition: i2c_device.h:309
int launch_commands(ABSTRACT_FUTURE &future, utils::range< I2CLightCommand > commands)
Launch execution (asynchronously or synchronously, depending on MANAGER) of a chain of I2CLightComman...
Definition: i2c_device.h:243
Generic Future that can be used to read an I2C device register.
Generic Future that can be used to write to an I2C device register.
Common types used by 3D sensors (e.g.
#define INLINE
Specific GCC attribute to force the compiler to always inline code of a given function.
Definition: defines.h:57
Defines utility methods for bits manipulation.
Definition: bits.h:34
static constexpr uint8_t BV8(uint8_t bit)
Create a uint8_t bitmask for the given bit number.
Definition: bits.h:41
Defines API for magnetic sensors for direction, speed and acceleration properties.
DLPF
The Digital Low Pass Filter bandwidth to select for the chip (register map §4.3).
Definition: mpu6050.h:118
AccelRange
The full-scale range of the accelerometer in g (datasheet §6.2).
Definition: mpu6050.h:71
ClockSelect
The clock to select for the chip (datasheet §6.6).
Definition: mpu6050.h:96
static constexpr uint16_t GYRO_RANGE_DPS(GyroRange range)
Convert a GyroRange constant to the real gyroscope range in dps.
Definition: mpu6050.h:56
AD0
Possible values of I2C address lower bit for the chip (the chip may have one of two possible addresse...
Definition: mpu6050.h:268
@ LOW
When AD0 pin is low, I2C address is 0x68.
@ HIGH
When AD0 pin is high, I2C address is 0x69.
static constexpr uint16_t ACCEL_RANGE_G(AccelRange range)
Convert an AccelRange constant to the real accelerometer range in g.
Definition: mpu6050.h:81
GyroRange
The full-scale range of the gyroscope in dps (datasheet §6.1).
Definition: mpu6050.h:46
Contains the API around Future implementation.
Definition: future.h:312
@ READY
The status of a Future once its output value has been fully set by a provider.
Define API to define and manage I2C devices.
Definition: i2c.h:51
constexpr uint8_t as_uint8_t(T input)
Cast a one byte long bit-fields struct into a byte.
Definition: utilities.h:506
Structure to store all MPU6050 sensors data (3 axis gyroscope and accelerometer, chip temperature).
Definition: mpu6050.h:252
Sensor3D accel
3 axis accelerometer measurements
Definition: mpu6050.h:254
Sensor3D gyro
3 axis gyroscope measurements
Definition: mpu6050.h:258
int16_t temperature
Temperature measurement.
Definition: mpu6050.h:256
Structure to store 3 axis data for one sensor (gyroscope or accelerometer).