mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-15 20:21:03 +00:00
bars
This commit is contained in:
@@ -4,6 +4,9 @@ Program to create a car monitor display using:
|
||||
- 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
|
||||
|
||||
linux arduino library:
|
||||
/home/sem/.arduino15/packages/arduino/hardware/sam/1.6.12/system/CMSIS/Device/ATMEL/sam3xa/include
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
@@ -15,6 +18,7 @@ Program to create a car monitor display using:
|
||||
#include "statemachine.h"
|
||||
#include "obd2_util.h"
|
||||
#include "obd2_elm327.h"
|
||||
#include "bars.h"
|
||||
|
||||
#define DEBUG 1
|
||||
// #define RTT_MR 0x400E1A30U
|
||||
@@ -90,6 +94,10 @@ char update_slow = 0;
|
||||
|
||||
obd2_elm327_t elm327;
|
||||
|
||||
int bar_1_x = 0;
|
||||
int bar_2_x = 10;
|
||||
int bar_3_y = 50;
|
||||
|
||||
void on_init_enter();
|
||||
void on_init_run();
|
||||
void on_init_exit();
|
||||
@@ -107,6 +115,7 @@ state_t init_state =
|
||||
.on_run = &on_init_run,
|
||||
.on_exit = &on_init_exit};
|
||||
|
||||
|
||||
state_t main_state =
|
||||
{
|
||||
.id = STATE_CAR_INFO,
|
||||
@@ -318,6 +327,7 @@ void on_main_run()
|
||||
if (update_slow)
|
||||
{
|
||||
update_slow = 0;
|
||||
obd2_elm327_process_slow(&elm327);
|
||||
|
||||
} else {
|
||||
obd2_elm327_process_fast(&elm327);
|
||||
@@ -507,7 +517,6 @@ void query_slow_obd2_values()
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
||||
{
|
||||
|
||||
/* TODO change for TRNG (section 42 of datasheet)*/
|
||||
@@ -567,24 +576,29 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
|
||||
statemachine_loop();
|
||||
// delay(10);
|
||||
// while (Serial1.available())
|
||||
// {
|
||||
// char rec = Serial1.read();
|
||||
// #if (DEBUG == 1)
|
||||
// Serial.println(rec);
|
||||
// #endif
|
||||
// }
|
||||
draw_bar_horizontal(0,0,200,10,bar_1_x,100,VGA_AQUA,1,&display);
|
||||
|
||||
// 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;
|
||||
// }
|
||||
draw_bar_horizontal(0,20,200,11,bar_2_x,100,VGA_FUCHSIA,1,&display);
|
||||
|
||||
draw_bar_vertical(0,50,20,100,bar_3_y,100,VGA_BLUE,1,&display);
|
||||
|
||||
bar_1_x++;
|
||||
if (bar_1_x > 100)
|
||||
{
|
||||
bar_1_x = 0;
|
||||
}
|
||||
|
||||
bar_2_x++;
|
||||
if (bar_2_x > 100)
|
||||
{
|
||||
bar_2_x = 10;
|
||||
}
|
||||
bar_3_y++;
|
||||
if (bar_3_y > 100)
|
||||
{
|
||||
bar_3_y = 50;
|
||||
}
|
||||
display.clrScr();
|
||||
delay(50);
|
||||
//statemachine_loop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user