From 7099d468d3a6940101108c09261f0da3d046b61e Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Sat, 13 Jan 2024 16:06:26 +0100 Subject: [PATCH] change Serial1 to BT_SERIAL and add debug preprocessor commands to all debug prints to console --- due_obd2/due_obd2.ino | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/due_obd2/due_obd2.ino b/due_obd2/due_obd2.ino index b1023eb..ed09a96 100644 --- a/due_obd2/due_obd2.ino +++ b/due_obd2/due_obd2.ino @@ -22,6 +22,7 @@ Program to create a car monitor display using: #define PIN_BT_RX 19 #define PIN_BT_TX 18 #define PIN_BT_STATE 3 /* connected/disconnected state of BT */ +#define BT_SERIAL Serial1 #define MS(x) x * 1000 #define S(x) MS(x) * 1000 @@ -95,7 +96,7 @@ char logo_flag = 0; /* device info variables */ char init_device_info = 0; /* wether we are drawing CPU (0), RAM (1) or DISPLAY (2) */ -uint32_t ram_b_amount = 0; /* counts up to 96 to show the KB of ram */ +uint32_t ram_b_amount = 0; /* counts up to 96 to show the KB of ram */ char device_label_i = -1; /* counter in the current device label */ char bt_state = BT_INITIALISING; @@ -150,8 +151,9 @@ void on_init_enter() Timer3.attachInterrupt(update_ram_kb); logo_flag |= (1 << FLAG_LOGO_UPDATE); - +#if (DEBUG == 1) Serial.println("Entering init state!"); +#endif } void on_init_run() @@ -275,7 +277,9 @@ void on_init_run() void on_init_exit() { +#if (DEBUG == 1) Serial.println("Exiting init state!"); +#endif display.clrScr(); Timer0.detachInterrupt(); Timer0.stop(); @@ -289,13 +293,17 @@ void on_init_exit() void on_main_enter() { +#if (DEBUG == 1) Serial.println("Entering main loop"); +#endif } void on_main_run() { delay(500); +#if (DEBUG == 1) Serial.println("main!"); +#endif } void update_init_text() @@ -338,7 +346,9 @@ void update_device_info() init_device_info = DEV_RAM; device_label_i = 0; Timer3.start(50); +#if (DEBUG == 1) Serial.println("DEV RAM"); +#endif } break; case DEV_RAM: @@ -421,7 +431,7 @@ void setup() Serial.begin(9600); #endif /* Serial1 is bluetooth module, pin 18 and 19. */ - Serial1.begin(115200); + BT_SERIAL.begin(115200); /* Init display */ display.InitLCD();