Skip to content

Commit 2e91008

Browse files
committed
further tidying, fixed build warnings
1 parent 33c2663 commit 2e91008

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

src/NineAxesMotion.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,26 @@ void NineAxesMotion::initSensor(unsigned int address, int int_pin, int reset_pin
7777
RESET_PIN = reset_pin;
7878

7979
//Initialize the GPIO peripheral
80-
pinMode(INT_PIN, INPUT_PULLUP); //Configure Interrupt pin
81-
pinMode(RESET_PIN, OUTPUT); //Configure Reset pin
80+
pinMode(int_pin, INPUT_PULLUP); //Configure Interrupt pin
81+
pinMode(reset_pin, OUTPUT); //Configure Reset pin
8282

8383
//Power on the BNO055
84-
resetSensor(address);
84+
resetSensor(address, reset_pin);
8585
}
8686

8787
/*******************************************************************************************
8888
*Description: This function is used to reset the BNO055
89-
*Input Parameters: None
89+
*Input Parameters:
90+
unsigned int address: I2C address of the BNO055. Default 0x28
91+
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
9092
*Return Parameter: None
9193
*******************************************************************************************/
92-
void NineAxesMotion::resetSensor(unsigned int address)
94+
void NineAxesMotion::resetSensor(unsigned int address, int reset_pin)
9395
{
9496
//Reset sequence
95-
digitalWrite(RESET_PIN, LOW); //Set the Reset pin LOW
97+
digitalWrite(reset_pin, LOW); //Set the Reset pin LOW
9698
delay(RESET_PERIOD); //Hold it for a while
97-
digitalWrite(RESET_PIN, HIGH); //Set the Reset pin HIGH
99+
digitalWrite(reset_pin, HIGH); //Set the Reset pin HIGH
98100
delay(INIT_PERIOD); //Pause for a while to let the sensor initialize completely (Anything >500ms should be fine)
99101
//Initialization sequence
100102
//Link the function pointers for communication (late-binding)
@@ -985,7 +987,7 @@ signed char BNO055_I2C_bus_read(unsigned char dev_addr,unsigned char reg_addr, u
985987
}
986988

987989

988-
signed char BNO055_I2C_bus_write(unsigned char dev_addr,unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt)
990+
signed char BNO055_I2C_bus_write(unsigned char dev_addr, unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt)
989991
{
990992
BNO055_RETURN_FUNCTION_TYPE comres = BNO055_ZERO_U8X;
991993
I2C.beginTransmission(dev_addr); //Start of transmission
@@ -1006,7 +1008,7 @@ void _delay(u_32 period)
10061008
}
10071009

10081010

1009-
void NineAxesMotion::begin(unsigned int address = 0x28)
1011+
void NineAxesMotion::begin(unsigned int address)
10101012
{
10111013
initSensor(address);
10121014
}

src/NineAxesMotion.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959

6060
extern "C" {
61-
#include <utility/BNO055.h>
61+
#include "utility/BNO055.h"
6262
}
6363
#include <Wire.h>
6464
#include "Arduino.h"
@@ -92,18 +92,6 @@ struct bno055_accel_stat_t {
9292
uint8_t powerMode; //Power mode: Normal - Deep suspend
9393
};
9494

95-
//GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
96-
int RESET_PIN = 7; // 7 or 4 are most likely candidate pins
97-
98-
//GPIO to receive the Interrupt from the BNO055 (Interrupt is visible on the INT LED on the Shield)
99-
#if defined(__AVR_ATmega32U4__) //Arduino Yun and Leonardo have I2C shared with pins 2 and 3
100-
int INT_PIN = 7;
101-
#elif defined(ARDUINO_SAMD)
102-
int INT_PIN = 7; // Older SAMD boards have NMI mapped on pin 2
103-
#else
104-
int INT_PIN = 2;
105-
#endif
106-
10795
#define ENABLE 1 //For use in function parameters
10896
#define DISABLE 0 //For use in function parameters
10997
#define NO_MOTION 1 //Enables the no motion interrupt
@@ -156,10 +144,12 @@ class NineAxesMotion {
156144

157145
/*******************************************************************************************
158146
*Description: This function is used to reset the BNO055
159-
*Input Parameters: None
147+
*Input Parameters:
148+
unsigned int address: I2C address of the BNO055. Default 0x28
149+
int reset_pin: GPIO to reset the BNO055 (RESET pin has to be HIGH for the BNO055 to operate)
160150
*Return Parameter: None
161151
*******************************************************************************************/
162-
void resetSensor(unsigned int address);
152+
void resetSensor(unsigned int address, int reset_pin = 7);
163153

164154
/*******************************************************************************************
165155
*Description: This function is used to set the operation mode of the BNO055
@@ -756,4 +746,4 @@ signed char BNO055_I2C_bus_read(unsigned char,unsigned char, unsigned char*, uns
756746
signed char BNO055_I2C_bus_write(unsigned char ,unsigned char , unsigned char* , unsigned char );
757747
void _delay(u_32);
758748

759-
#endif __NAXISMOTION_H__
749+
#endif

0 commit comments

Comments
 (0)