adafruit / Adafruit-PWM-Servo-Driver-Library

Adafruit PWM Servo Driver Library
Other
477 stars 311 forks source link

Eliminate Warnings #95

Closed GSTCH closed 1 year ago

GSTCH commented 1 year ago

Warnings when using "Adafruit-PWM-Servo-Driver-Library" and "Adafruit_Motor_Shield_V2_Library" in same sketch. There are only some additional #ifndef and no changes into the logic of the library.

caternuson commented 1 year ago

Can you provide more information on what the warning are? (paste them here)

GSTCH commented 1 year ago

In file included from ... libraries\Adafruit_PWM_Servo_Driver_Library/Adafruit_PWMServoDriver.h:31:0: warning: "PCA9685_MODE1" redefined

define PCA9685_MODE1 0x00 /*< Mode Register 1 /

... \libraries\Adafruit_Motor_Shield_V2_Library/utility/Adafruit_MS_PWMServoDriver.h:42:0: note: this is the location of the previous definition

define PCA9685_MODE1 0x0

In file included from ... libraries\Adafruit_PWM_Servo_Driver_Library/Adafruit_PWMServoDriver.h:31:0: warning: "PCA9685_MODE1" redefined

define PCA9685_MODE1 0x00 /*< Mode Register 1 /

In file included ... libraries\Adafruit_Motor_Shield_V2_Library/utility/Adafruit_MS_PWMServoDriver.h:42:0: note: this is the location of the previous definition

define PCA9685_MODE1 0x0


The following defines are in both libraries ("Adafruit_PWM_Servo_Driver_Library\Adafruit_PWMServoDriver.h" and "Adafruit_Motor_Shield_V2_Library\utility\Adafruit_MS_PWMServoDriver.h"). This gives the above redefined warnings.

define PCA9685_MODE1 0x00 /*< Mode Register 1 /

define PCA9685_SUBADR1 0x02 /*< I2C-bus subaddress 1 /

define PCA9685_SUBADR2 0x03 /*< I2C-bus subaddress 2 /

define PCA9685_SUBADR3 0x04 /*< I2C-bus subaddress 3 /

Enclose them all with #ifndef e.g for "PCA9685_MODE1"

ifndef PCA9685_MODE1

define PCA9685_MODE1 0x00 /*< Mode Register 1 /

endif

and it works.

caternuson commented 1 year ago

Thanks. Those are just warns. So if the rest of the compilation worked, then the sketch is probably OK.

But would be good to fix this.

Opened a new issue for this here: https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library/issues/50

caternuson commented 1 year ago

Closing here. This should be fixed in the Motor Shield library. See issue linked above.

GSTCH commented 1 year ago

It's a question of the include order. When "Motor Shield library" has been included first, you have to fix it in your library. Else it writes a warning and good software compiles without any warnings. Both has to modify it, or one changes the define names. Both libraries are from Adafruit so why should they no work simultaneously without warnings?

caternuson commented 1 year ago

They should. But the fix should be done in the other library (Motor Shield). So an issue has been opened there. It's referenced above.