commit b0ad3529b774dd645bc39e58391f3ed0ef2d43de Author: Sem van der Hoeven Date: Thu Oct 26 23:15:16 2023 +0200 Add project diff --git a/due_obd2/due_obd2/due_obd2.ino b/due_obd2/due_obd2/due_obd2.ino new file mode 100644 index 0000000..b82f708 --- /dev/null +++ b/due_obd2/due_obd2/due_obd2.ino @@ -0,0 +1,71 @@ +/** +Program to create a car monitor display using: + - Arduino Due + - a TFT display (https://www.tinytronics.nl/shop/en/displays/tft/3.5-inch-tft-display-320*480-pixels-mega-compatible-ili9486) + - ELM327 Bluetooth OBD2 scanner + - FSC-DB004 (BT 836B) bluetooth module +*/ + +/* include UTFT library */ +#include + +#define DEBUG 1 + +/* pins */ +#define PIN_BT_RX 19 +#define PIN_BT_TX 18 +#define PIN_BT_STATE 3 /* connected/disconnected state of BT */ + +/* display size */ +#define LCD_W 480 +#define LCD_H 320 + +extern uint8_t BigFont[]; +extern uint8_t SmallFont[]; + +char should_clear = 1; + +/* Set the pins for the display and dev board */ +/* Standard Arduino Mega/Due shield : ,38,39,40,41 */ +UTFT display(ILI9486,38,39,40,41); + +void setup() { + randomSeed(analogRead(0)); + + #if (DEBUG == 1) + Serial.begin(9600); + #endif + /* Serial1 is bluetooth module, pin 18 and 19. */ + Serial1.begin(115200); + + /* Init display */ + display.InitLCD(); + display.setFont(BigFont); + + #if (DEBUG == 1) + Serial.println("Starting"); + #endif +} + +void loop() { + // put your main code here, to run repeatedly: + while (Serial1.available()) { + char rec = Serial1.read(); + #if (DEBUG == 1) + Serial.println(rec); + #endif + } + + if (should_clear) + { + display.clrScr(); + display.setColor(255, 0, 166); + display.fillRect(LCD_W/2-200,LCD_H/2-100,LCD_W/2+200,LCD_H/2+100); + display.setColor(0, 247, 255); + display.print("OBD2 display yeet",CENTER,LCD_H/2); + delay(10); + should_clear = 0; + } + + +}