mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-15 04:01:04 +00:00
Add project
This commit is contained in:
71
due_obd2/due_obd2/due_obd2.ino
Normal file
71
due_obd2/due_obd2/due_obd2.ino
Normal file
@@ -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 <UTFT.h>
|
||||
|
||||
#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 : <display model>,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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user