From d1241ba9551fac43f8ab65d73149a6d55b53ea31 Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Tue, 9 Mar 2021 21:06:07 +0900 Subject: [PATCH] support MPU9255 without code change --- MPU9250.h | 7 +++---- README.md | 14 ++------------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/MPU9250.h b/MPU9250.h index 445e923..af93cc7 100644 --- a/MPU9250.h +++ b/MPU9250.h @@ -65,7 +65,7 @@ struct MPU9250Setting { ACCEL_DLPF_CFG accel_dlpf_cfg {ACCEL_DLPF_CFG::DLPF_45HZ}; }; -template +template class MPU9250_ { static constexpr uint8_t MPU9250_DEFAULT_ADDRESS {0x68}; // Device address when ADO = 0 static constexpr uint8_t AK8963_ADDRESS {0x0C}; // Address of magnetometer @@ -175,7 +175,7 @@ class MPU9250_ { Serial.print("MPU9250 WHO AM I = "); Serial.println(c, HEX); } - return (c == WHO_AM_I); + return (c == MPU9250_WHOAMI_DEFAULT_VALUE) || (c == MPU9255_WHOAMI_DEFAULT_VALUE); } bool isConnectedAK8963() { @@ -951,7 +951,6 @@ class MPU9250_ { } }; -using MPU9250 = MPU9250_; -using MPU9255 = MPU9250_; +using MPU9250 = MPU9250_; #endif // MPU9250_H diff --git a/README.md b/README.md index d2919c0..bb10902 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ This library is based on the [great work](https://github.com/kriswiner/MPU9250) ``` C++ #include "MPU9250.h" -MPU9250 mpu; -// MPU9255 mpu; // You can also use MPU9255 +MPU9250 mpu; // You can also use MPU9255 as is void setup() { Serial.begin(115200); @@ -40,8 +39,7 @@ void loop() { ``` C++ #include "MPU9250.h" -MPU9250 mpu; -// MPU9255 mpu; // You can also use MPU9255 +MPU9250 mpu; // You can also use MPU9255 as is void setup() { Serial.begin(115200); @@ -191,14 +189,6 @@ MPU9250Setting setting; mpu.setup(0x70, setting, sw); ``` -### MPU9255 - -To use MPU9255 instead of MPU9250, just declare MPU9255. - -```C++ -MPU9255 mpu; -``` - ## APIs ``` C++