diff options
Diffstat (limited to 'robot/sim.h')
-rw-r--r-- | robot/sim.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/robot/sim.h b/robot/sim.h index 15a1b4b..a595042 100644 --- a/robot/sim.h +++ b/robot/sim.h @@ -3,6 +3,20 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <stdbool.h> + +#include "../shared/bin.h" + +extern bool g_w2_sim_headless; + +// debug fine-tuning +#define DBG_ENABLE_PRINTFUNC (1) +#define DBG_ENABLE_SIMWARN (1) +#define DBG_ENABLE_SIMINFO (1) +#define DBG_ENABLE_CYCLEINFO (0) +#define DBG_ENABLE_SERIAL (1) + +#define DBG_MAX_CYCLES (10) // debug print options #define DBG_BYTES_PER_LINE 16 @@ -19,12 +33,12 @@ #define COL_RST "\e[0m" // debug stdout print macros -#define simprintf(message, ...) printf(COL_RED "[SIM] " COL_RST message, ##__VA_ARGS__) +#define simprintf(message, ...) if (!g_w2_sim_headless) printf(COL_RED "[SIM] " COL_RST message, ##__VA_ARGS__) #define simprint(message) simprintf(message "\n") -#define simprintfunc(name, fmt, ...) simprintf(COL_BLU "[FUNC] " \ - COL_CYN name COL_RST "(" COL_YEL fmt COL_RST ")\n", ##__VA_ARGS__) -#define simwarn(message, ...) simprintf(COL_YEL "[WARN] " COL_RST message, ##__VA_ARGS__) -#define siminfo(message, ...) simprintf(COL_MAG "[INFO] " COL_RST message, ##__VA_ARGS__) +#define simprintfunc(name, fmt, ...) if (DBG_ENABLE_PRINTFUNC) { simprintf(COL_BLU "[FUNC] " \ + COL_CYN name COL_RST "(" COL_YEL fmt COL_RST ")\n", ##__VA_ARGS__); } +#define simwarn(message, ...) if (DBG_ENABLE_SIMWARN) { simprintf(COL_YEL "[WARN] " COL_RST message, ##__VA_ARGS__); } +#define siminfo(message, ...) if (DBG_ENABLE_SIMINFO) { simprintf(COL_MAG "[INFO] " COL_RST message, ##__VA_ARGS__); } /** * simulates pololu library functions for local testing @@ -35,6 +49,14 @@ unsigned long get_ms(); // NOLINT void red_led(unsigned char on); // NOLINT void green_led(unsigned char on); // NOLINT void clear(); // NOLINT -void play(const char* melody); // NOLINT +void play(const char *melody); // NOLINT void serial_set_baud_rate(unsigned int rate); // NOLINT -void serial_send(char* message, unsigned int length); // NOLINT +void serial_send(char *message, unsigned int length); // NOLINT +void serial_receive_ring(char *buffer, unsigned char size); // NOLINT +unsigned char serial_get_received_bytes(); // NOLINT +void set_motors(int left, int right); // NOLINT + +void w2_sim_setup(int argc, char **argv); +void w2_sim_cycle_begin(); +void w2_sim_print_serial(w2_s_bin *data); + |