aboutsummaryrefslogtreecommitdiff
path: root/robot/sim.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-14 00:49:58 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-14 00:49:58 +0200
commitd9df6e65017e9f4409b33a13e4aa62f37e685946 (patch)
treef672c3b3ea4c97b83a955bf628fc0d9d60cdd144 /robot/sim.h
parent3f90c242ff00cc2a8ec26486c1d22bb0e3de0114 (diff)
error handling done + better simulation / debug messaging
Diffstat (limited to 'robot/sim.h')
-rw-r--r--robot/sim.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/robot/sim.h b/robot/sim.h
index 08faee5..15a1b4b 100644
--- a/robot/sim.h
+++ b/robot/sim.h
@@ -1,9 +1,35 @@
#pragma once
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+// debug print options
+#define DBG_BYTES_PER_LINE 16
+
+// debug colors
+#define COL_BLK "\e[0;30m"
+#define COL_RED "\e[0;31m"
+#define COL_GRN "\e[0;32m"
+#define COL_YEL "\e[0;33m"
+#define COL_BLU "\e[0;34m"
+#define COL_MAG "\e[0;35m"
+#define COL_CYN "\e[0;36m"
+#define COL_WHT "\e[0;37m"
+#define COL_RST "\e[0m"
+
+// debug stdout print macros
+#define simprintf(message, ...) 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__)
+
/**
* simulates pololu library functions for local testing
+ * NOLINT is so clang-tidy doesn't correct function names
*/
-
void time_reset(); // NOLINT
unsigned long get_ms(); // NOLINT
void red_led(unsigned char on); // NOLINT