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

Fix bugs that prevent library compiling with the DEBUG macro set #81

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/MPU6050_6Axis_MotionApps20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,32 @@ THE SOFTWARE.
// compiler macro (Arduino IDE 1.0+ required).

//#define DEBUG
/* Control whether debugging macros are active at compile time */
#undef DB_ACTIVE
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTF(x, y) Serial.print(x, y)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINTLNF(x, y) Serial.println(x, y)
#define DB_ACTIVE 1
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTF(x, y)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINTLNF(x, y)
#endif
#define DB_ACTIVE 0
#endif /* DEBUG */

/*
** Usage: DB_PRINT((...));
** Usage: DB_PRINTLN((...));
**
** "..." is whatever extra arguments fmt requires (possibly nothing).
**
** The structure of the macros means that the code is always validated
** but is not called when DEBUG is undefined.
** -- See chapter 8 of 'The Practice of Programming', by Kernighan and Pike.
*/
#define DEBUG_PRINT(...)\
do { if (DB_ACTIVE) Serial.print(__VA_ARGS__); } while (0)
#define DEBUG_PRINTF(...)\
do { if (DB_ACTIVE) Serial.printf(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLN(...)\
do { if (DB_ACTIVE) Serial.println(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLNF(x, y)\
do { if (DB_ACTIVE) Serial.println(x, y); } while (0)

#define MPU6050_DMP_CODE_SIZE 1929 // dmpMemory[]
#define MPU6050_DMP_CONFIG_SIZE 192 // dmpConfig[]
Expand Down
33 changes: 24 additions & 9 deletions src/MPU6050_6Axis_MotionApps612.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,32 @@ THE SOFTWARE.
// compiler macro (Arduino IDE 1.0+ required).

//#define DEBUG
/* Control whether debugging macros are active at compile time */
#undef DB_ACTIVE
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTF(x, y) Serial.print(x, y)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINTLNF(x, y) Serial.println(x, y)
#define DB_ACTIVE 1
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTF(x, y)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINTLNF(x, y)
#endif
#define DB_ACTIVE 0
#endif /* DEBUG */

/*
** Usage: DB_PRINT((...));
** Usage: DB_PRINTLN((...));
**
** "..." is whatever extra arguments fmt requires (possibly nothing).
**
** The structure of the macros means that the code is always validated
** but is not called when DEBUG is undefined.
** -- See chapter 8 of 'The Practice of Programming', by Kernighan and Pike.
*/
#define DEBUG_PRINT(...)\
do { if (DB_ACTIVE) Serial.print(__VA_ARGS__); } while (0)
#define DEBUG_PRINTF(...)\
do { if (DB_ACTIVE) Serial.printf(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLN(...)\
do { if (DB_ACTIVE) Serial.println(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLNF(x, y)\
do { if (DB_ACTIVE) Serial.println(x, y); } while (0)

#define MPU6050_DMP_CODE_SIZE 3062 // dmpMemory[]

Expand Down
39 changes: 27 additions & 12 deletions src/MPU6050_9Axis_MotionApps41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,32 @@ THE SOFTWARE.
// compiler macro (Arduino IDE 1.0+ required).

//#define DEBUG
/* Control whether debugging macros are active at compile time */
#undef DB_ACTIVE
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTF(x, y) Serial.print(x, y)
#define DEBUG_PRINTLN(x) Serial.println(x)
#define DEBUG_PRINTLNF(x, y) Serial.println(x, y)
#define DB_ACTIVE 1
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTF(x, y)
#define DEBUG_PRINTLN(x)
#define DEBUG_PRINTLNF(x, y)
#endif
#define DB_ACTIVE 0
#endif /* DEBUG */

/*
** Usage: DB_PRINT((...));
** Usage: DB_PRINTLN((...));
**
** "..." is whatever extra arguments fmt requires (possibly nothing).
**
** The structure of the macros means that the code is always validated
** but is not called when DEBUG is undefined.
** -- See chapter 8 of 'The Practice of Programming', by Kernighan and Pike.
*/
#define DEBUG_PRINT(...)\
do { if (DB_ACTIVE) Serial.print(__VA_ARGS__); } while (0)
#define DEBUG_PRINTF(...)\
do { if (DB_ACTIVE) Serial.printf(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLN(...)\
do { if (DB_ACTIVE) Serial.println(__VA_ARGS__); } while (0)
#define DEBUG_PRINTLNF(x, y)\
do { if (DB_ACTIVE) Serial.println(x, y); } while (0)

#define MPU6050_DMP_CODE_SIZE 1962 // dmpMemory[]
#define MPU6050_DMP_CONFIG_SIZE 232 // dmpConfig[]
Expand Down Expand Up @@ -345,10 +360,10 @@ uint8_t MPU6050_9Axis_MotionApps41::dmpInitialize() {
setSleepEnabled(false);

// get MPU product ID
DEBUG_PRINTLN(F("Getting product ID..."));
//DEBUG_PRINTLN(F("Getting product ID..."));
//uint8_t productID = 0; //getProductID();
DEBUG_PRINT(F("Product ID = "));
DEBUG_PRINT(productID);
//DEBUG_PRINT(F("Product ID = "));
//DEBUG_PRINT(productID);

// get MPU hardware revision
DEBUG_PRINTLN(F("Selecting user bank 16..."));
Expand Down
Loading