diff options
-rw-r--r-- | Venus_Skeleton/Venus_Skeleton.ino | 26 | ||||
-rw-r--r-- | Venus_Skeleton/comm.h | 14 |
2 files changed, 32 insertions, 8 deletions
diff --git a/Venus_Skeleton/Venus_Skeleton.ino b/Venus_Skeleton/Venus_Skeleton.ino index 5873726..f15848d 100644 --- a/Venus_Skeleton/Venus_Skeleton.ino +++ b/Venus_Skeleton/Venus_Skeleton.ino @@ -16,14 +16,6 @@ // 2 Error: Sensor Obstacle detection on the turret // 3 Error: Sensor IR Line detection -#define DEBUG true - -#ifdef DEBUG -#define DEBUG_PRINT(str) Serial.print(str) -#else -#define DEBUG_PRINT(str) do { } while (0) -#endif - #include <Servo.h> #include <HMC5883L.h> #include <Wire.h> @@ -41,6 +33,24 @@ #include "calibration_wall-e.h" //#include "calibration.eve.h" +#include "comm.h" + +// set 0 to disable debugging +// set 1 for debugging with Serial.print (default) +// set 2 for debugging over RPi serial +#ifndef DEBUG +# define DEBUG 1 +#endif + +#if DEBUG == 1 +# define DEBUG_PRINT(str) Serial.print(str) +#elif DEBUG == 2 +# define DEBUG_PRINT(str) serial_print_debug(str) +#else +# define DEBUG_PRINT(str) do { } while (0) +#endif + + // ***************** // ** DEFINITIONS ** diff --git a/Venus_Skeleton/comm.h b/Venus_Skeleton/comm.h index 7f3b43c..26e8d7b 100644 --- a/Venus_Skeleton/comm.h +++ b/Venus_Skeleton/comm.h @@ -26,3 +26,17 @@ extern serial_state_t serial_state; void handle_serial(data_t *data, int changedBits); void serial_print_debug(const char *str); + +/* simple wrappers for Serial.print compatibility */ +static inline void serial_print_debug(String str) { + serial_print_debug(str.c_str()); +} +static inline void serial_print_debug(int n) { + serial_print_debug(String(n)); +} +static inline void serial_print_debug(long n) { + serial_print_debug(String(n)); +} +static inline void serial_print_debug(float n) { + serial_print_debug(String(n)); +} |