Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate Warnings #95

Conversation

GSTCH
Copy link

@GSTCH GSTCH commented Jun 28, 2023

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.

Warnings when using "Adafruit-PWM-Servo-Driver-Library" and "Adafruit_Motor_Shield_V2_Library" in same sketch.
@caternuson
Copy link
Contributor

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

@GSTCH
Copy link
Author

GSTCH commented Jun 28, 2023

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
Copy link
Contributor

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:
adafruit/Adafruit_Motor_Shield_V2_Library#50

@caternuson
Copy link
Contributor

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

@caternuson caternuson closed this Aug 10, 2023
@GSTCH
Copy link
Author

GSTCH commented Aug 10, 2023

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants