From 29d958f27fb21abf69ae0fa0de39bb4735ccd422 Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 17:24:25 +0100 Subject: [PATCH 1/7] Added in a getMode() method to obtain the operating mode --- Adafruit_BNO055.cpp | 23 +++++++++++++++++++++++ Adafruit_BNO055.h | 1 + 2 files changed, 24 insertions(+) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index f5ae19a..14dcaed 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -158,6 +158,29 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { delay(30); } +/*! + * @brief Gets the current operating mode of the chip + * @param mode + * mode values + * [OPERATION_MODE_CONFIG, + * OPERATION_MODE_ACCONLY, + * OPERATION_MODE_MAGONLY, + * OPERATION_MODE_GYRONLY, + * OPERATION_MODE_ACCMAG, + * OPERATION_MODE_ACCGYRO, + * OPERATION_MODE_MAGGYRO, + * OPERATION_MODE_AMG, + * OPERATION_MODE_IMUPLUS, + * OPERATION_MODE_COMPASS, + * OPERATION_MODE_M4G, + * OPERATION_MODE_NDOF_FMC_OFF, + * OPERATION_MODE_NDOF] + */ +uint8_t Adafruit_BNO055::getMode() { + uint8_t _my_mode_return = (uint8_t)read8(BNO055_OPR_MODE_ADDR); + return _my_mode_return; +} + /*! * @brief Changes the chip's axis remap * @param remapcode diff --git a/Adafruit_BNO055.h b/Adafruit_BNO055.h index ac09a4d..dda8fb6 100644 --- a/Adafruit_BNO055.h +++ b/Adafruit_BNO055.h @@ -284,6 +284,7 @@ class Adafruit_BNO055 : public Adafruit_Sensor { bool begin(adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF); void setMode(adafruit_bno055_opmode_t mode); + uint8_t getMode(); void setAxisRemap(adafruit_bno055_axis_remap_config_t remapcode); void setAxisSign(adafruit_bno055_axis_remap_sign_t remapsign); void getRevInfo(adafruit_bno055_rev_info_t *); From 270fcffa4a076b0da59f17fe7467e45f8332af5b Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 17:44:30 +0100 Subject: [PATCH 2/7] Tidy up naming --- Adafruit_BNO055.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index 14dcaed..6eaccf6 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -159,26 +159,12 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { } /*! - * @brief Gets the current operating mode of the chip - * @param mode - * mode values - * [OPERATION_MODE_CONFIG, - * OPERATION_MODE_ACCONLY, - * OPERATION_MODE_MAGONLY, - * OPERATION_MODE_GYRONLY, - * OPERATION_MODE_ACCMAG, - * OPERATION_MODE_ACCGYRO, - * OPERATION_MODE_MAGGYRO, - * OPERATION_MODE_AMG, - * OPERATION_MODE_IMUPLUS, - * OPERATION_MODE_COMPASS, - * OPERATION_MODE_M4G, - * OPERATION_MODE_NDOF_FMC_OFF, - * OPERATION_MODE_NDOF] + * @brief Gets the current operating mode of the chip + * @return operating_mode */ uint8_t Adafruit_BNO055::getMode() { - uint8_t _my_mode_return = (uint8_t)read8(BNO055_OPR_MODE_ADDR); - return _my_mode_return; + uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); + return operating_mode; } /*! From 829f103f802742842cb1bd410c4ff21e4bf24a9c Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 17:54:09 +0100 Subject: [PATCH 3/7] Updated docstring --- Adafruit_BNO055.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index 6eaccf6..abafc6a 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -160,7 +160,7 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { /*! * @brief Gets the current operating mode of the chip - * @return operating_mode + * @return operating_mode in integer which can be mapped in Section 3.3 e.g.Return 12 (0X0C) => NDOF */ uint8_t Adafruit_BNO055::getMode() { uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); From adbc7ab9480489af3a0d195e9df01a58db05f1be Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 18:20:17 +0100 Subject: [PATCH 4/7] Reduce line length --- Adafruit_BNO055.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index abafc6a..ba76ca7 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -160,7 +160,8 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { /*! * @brief Gets the current operating mode of the chip - * @return operating_mode in integer which can be mapped in Section 3.3 e.g.Return 12 (0X0C) => NDOF + * @return operating_mode in integer which can be mapped in Section 3.3 + * for example: a return of 12 (0X0C) => NDOF */ uint8_t Adafruit_BNO055::getMode() { uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); From ec2687f2b99e53d90ee8fa88d52e2dfe08df5ecf Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 18:36:07 +0100 Subject: [PATCH 5/7] Fixed spacing --- Adafruit_BNO055.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index ba76ca7..4798022 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -164,8 +164,8 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { * for example: a return of 12 (0X0C) => NDOF */ uint8_t Adafruit_BNO055::getMode() { - uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); - return operating_mode; + uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); + return operating_mode; } /*! From 8bc20da9952ea927a037b49b9b02bb1c4bf93fa2 Mon Sep 17 00:00:00 2001 From: David Gibbons Date: Fri, 12 Aug 2022 22:52:11 +0100 Subject: [PATCH 6/7] Replaced uint8_t with adafruit_bno055_opmode_t --- Adafruit_BNO055.cpp | 4 ++-- Adafruit_BNO055.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index 4798022..5c05a1a 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -163,8 +163,8 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { * @return operating_mode in integer which can be mapped in Section 3.3 * for example: a return of 12 (0X0C) => NDOF */ -uint8_t Adafruit_BNO055::getMode() { - uint8_t operating_mode = read8(BNO055_OPR_MODE_ADDR); +adafruit_bno055_opmode_t Adafruit_BNO055::getMode() { + adafruit_bno055_opmode_t operating_mode = read8(BNO055_OPR_MODE_ADDR); return operating_mode; } diff --git a/Adafruit_BNO055.h b/Adafruit_BNO055.h index dda8fb6..54961c9 100644 --- a/Adafruit_BNO055.h +++ b/Adafruit_BNO055.h @@ -284,7 +284,7 @@ class Adafruit_BNO055 : public Adafruit_Sensor { bool begin(adafruit_bno055_opmode_t mode = OPERATION_MODE_NDOF); void setMode(adafruit_bno055_opmode_t mode); - uint8_t getMode(); + adafruit_bno055_opmode_t getMode(); void setAxisRemap(adafruit_bno055_axis_remap_config_t remapcode); void setAxisSign(adafruit_bno055_axis_remap_sign_t remapsign); void getRevInfo(adafruit_bno055_rev_info_t *); From fbe39c88bdcde4b40b268fc352c2851977a1e67f Mon Sep 17 00:00:00 2001 From: lady ada Date: Sun, 14 Aug 2022 00:09:30 -0400 Subject: [PATCH 7/7] move typedef out of object so its accessable --- Adafruit_BNO055.cpp | 3 +-- Adafruit_BNO055.h | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Adafruit_BNO055.cpp b/Adafruit_BNO055.cpp index 5c05a1a..c7418a2 100644 --- a/Adafruit_BNO055.cpp +++ b/Adafruit_BNO055.cpp @@ -164,8 +164,7 @@ void Adafruit_BNO055::setMode(adafruit_bno055_opmode_t mode) { * for example: a return of 12 (0X0C) => NDOF */ adafruit_bno055_opmode_t Adafruit_BNO055::getMode() { - adafruit_bno055_opmode_t operating_mode = read8(BNO055_OPR_MODE_ADDR); - return operating_mode; + return (adafruit_bno055_opmode_t)read8(BNO055_OPR_MODE_ADDR); } /*! diff --git a/Adafruit_BNO055.h b/Adafruit_BNO055.h index 54961c9..35a0274 100644 --- a/Adafruit_BNO055.h +++ b/Adafruit_BNO055.h @@ -57,6 +57,23 @@ typedef struct { int16_t mag_radius; /**< magnetometer radius */ } adafruit_bno055_offsets_t; +/** Operation mode settings **/ +typedef enum { + OPERATION_MODE_CONFIG = 0X00, + OPERATION_MODE_ACCONLY = 0X01, + OPERATION_MODE_MAGONLY = 0X02, + OPERATION_MODE_GYRONLY = 0X03, + OPERATION_MODE_ACCMAG = 0X04, + OPERATION_MODE_ACCGYRO = 0X05, + OPERATION_MODE_MAGGYRO = 0X06, + OPERATION_MODE_AMG = 0X07, + OPERATION_MODE_IMUPLUS = 0X08, + OPERATION_MODE_COMPASS = 0X09, + OPERATION_MODE_M4G = 0X0A, + OPERATION_MODE_NDOF_FMC_OFF = 0X0B, + OPERATION_MODE_NDOF = 0X0C +} adafruit_bno055_opmode_t; + /*! * @brief Class that stores state and functions for interacting with * BNO055 Sensor @@ -219,23 +236,6 @@ class Adafruit_BNO055 : public Adafruit_Sensor { POWER_MODE_SUSPEND = 0X02 } adafruit_bno055_powermode_t; - /** Operation mode settings **/ - typedef enum { - OPERATION_MODE_CONFIG = 0X00, - OPERATION_MODE_ACCONLY = 0X01, - OPERATION_MODE_MAGONLY = 0X02, - OPERATION_MODE_GYRONLY = 0X03, - OPERATION_MODE_ACCMAG = 0X04, - OPERATION_MODE_ACCGYRO = 0X05, - OPERATION_MODE_MAGGYRO = 0X06, - OPERATION_MODE_AMG = 0X07, - OPERATION_MODE_IMUPLUS = 0X08, - OPERATION_MODE_COMPASS = 0X09, - OPERATION_MODE_M4G = 0X0A, - OPERATION_MODE_NDOF_FMC_OFF = 0X0B, - OPERATION_MODE_NDOF = 0X0C - } adafruit_bno055_opmode_t; - /** Remap settings **/ typedef enum { REMAP_CONFIG_P0 = 0x21,