mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-14 19:51:04 +00:00
begin placing elements, add skip BT check
This commit is contained in:
@@ -21,6 +21,7 @@ Program to create a car monitor display using:
|
||||
#include "bars.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#define SKIP_BT_CHECK 1
|
||||
// #define RTT_MR 0x400E1A30U
|
||||
|
||||
#define MS(x) x * 1000
|
||||
@@ -49,6 +50,18 @@ Program to create a car monitor display using:
|
||||
|
||||
#define COLOR_ORANGE 255, 96, 33
|
||||
|
||||
/****************************************/
|
||||
/* x and y positions for several gauges */
|
||||
/****************************************/
|
||||
/* box that holds temperature gauges */
|
||||
#define TEMP_BOX_PADDING 5
|
||||
#define TEMP_BOX_X_START 300
|
||||
#define TEMP_BOX_Y_START TEMP_BOX_PADDING
|
||||
#define TEMP_BOX_CONTENT_WIDTH 180 // witdth of the box to calculate the content in it
|
||||
#define TEMP_BOX_WIDTH TEMP_BOX_CONTENT_WIDTH - TEMP_BOX_PADDING // width of the box to draw the outline
|
||||
#define TEMP_BOX_HEIGHT 200 - TEMP_BOX_PADDING
|
||||
#define TEMP_BOX_COLOR VGA_GRAY
|
||||
|
||||
enum DeviceLabel
|
||||
{
|
||||
DEV_CPU = 0,
|
||||
@@ -315,6 +328,11 @@ void on_main_enter()
|
||||
#endif
|
||||
Timer0.attachInterrupt(query_slow_obd2_values);
|
||||
Timer0.start(MS(5000));
|
||||
|
||||
// draw section for temps
|
||||
display.setColor(TEMP_BOX_COLOR);
|
||||
display.drawRect(TEMP_BOX_X_START, TEMP_BOX_Y_START, TEMP_BOX_X_START + TEMP_BOX_WIDTH, TEMP_BOX_Y_START + TEMP_BOX_HEIGHT);
|
||||
|
||||
display.setColor(VGA_AQUA);
|
||||
}
|
||||
|
||||
@@ -539,8 +557,6 @@ void setup()
|
||||
statemachine_register_state(&init_state, STATE_INIT);
|
||||
statemachine_register_state(&main_state, STATE_CAR_INFO);
|
||||
|
||||
// TODO remove
|
||||
// statemachine_register_state(&main_state, 0);
|
||||
statemachine_init();
|
||||
|
||||
display.clrScr();
|
||||
@@ -568,6 +584,10 @@ void setup()
|
||||
Serial.println(elm327.elm327->connected);
|
||||
#endif
|
||||
|
||||
#if (SKIP_BT_CHECK == 1)
|
||||
update_percent(10);
|
||||
#endif
|
||||
|
||||
display.clrScr();
|
||||
|
||||
display.setFont(OCR_A_Extended_M);
|
||||
@@ -575,32 +595,5 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
bar_draw_horizontal(0, 0, 200, 10, bar_1_x, 100, VGA_AQUA, 1, &display);
|
||||
|
||||
bar_draw_horizontal(0, 20, 200, 11, bar_2_x, 100, VGA_FUCHSIA, 0, &display);
|
||||
|
||||
bar_draw_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_clear_part_horizontal(0,0,200,10,bar_1_x,100,VGA_BLACK,0,&display);
|
||||
}
|
||||
|
||||
bar_2_x++;
|
||||
if (bar_2_x > 100)
|
||||
{
|
||||
bar_2_x = 10;
|
||||
bar_clear_part_horizontal(0,20,200,11,bar_2_x,100,VGA_BLACK,1,&display);
|
||||
}
|
||||
bar_3_y++;
|
||||
if (bar_3_y > 100)
|
||||
{
|
||||
bar_3_y = 50;
|
||||
bar_clear_part_vertical(0,50,20,100,bar_3_y,100,VGA_BLACK,0,&display);
|
||||
}
|
||||
delay(50);
|
||||
// statemachine_loop();
|
||||
statemachine_loop();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "obd2_elm327.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#define DEBUG_VALUES 1
|
||||
|
||||
#define KM_IN_MILES 1.6093440
|
||||
#define RPM_MAX 7000
|
||||
@@ -90,10 +90,9 @@ void obd2_elm327_process_fast(obd2_elm327_t *elm327)
|
||||
{
|
||||
case ENGINE_LOAD_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
float engine_load = 50;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
current_value_fast = FUEL_PRESSURE_V;
|
||||
elm327->engine_load = (uint8_t)engine_load;
|
||||
elm327->engine_load = ++elm327->engine_load % 100;
|
||||
elm327->value_updates |= (1 << UPDATE_ENGINE_LOAD_POS);
|
||||
#else
|
||||
float engine_load = elm327->elm327->engineLoad();
|
||||
@@ -113,9 +112,8 @@ void obd2_elm327_process_fast(obd2_elm327_t *elm327)
|
||||
}
|
||||
case FUEL_PRESSURE_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
float fuel_pressure = 8;
|
||||
elm327->fuel_pressure = (uint16_t)fuel_pressure;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->fuel_pressure = ++elm327->fuel_pressure % 20;
|
||||
elm327->value_updates |= (1 << UPDATE_FUEL_PRESSURE_POS);
|
||||
current_value_fast = MANIFOLD_PRESSURE_V;
|
||||
#else
|
||||
@@ -136,9 +134,8 @@ void obd2_elm327_process_fast(obd2_elm327_t *elm327)
|
||||
}
|
||||
case MANIFOLD_PRESSURE_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
float manifold_pressure = 8;
|
||||
elm327->manifold_pressure = (uint8_t)manifold_pressure;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->manifold_pressure = ++elm327->manifold_pressure % 20;
|
||||
elm327->value_updates |= (1 << UPDATE_MANIFOLD_PRESSURE_POS);
|
||||
current_value_fast = ENGINE_LOAD_V;
|
||||
#else
|
||||
@@ -167,8 +164,8 @@ void obd2_elm327_process_slow(obd2_elm327_t *elm327)
|
||||
{
|
||||
case COOLANT_TEMP_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
elm327->engine_coolant_temp = 102;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->engine_coolant_temp = ++elm327->engine_coolant_temp % 150;
|
||||
elm327->value_updates |= (1 << UPDATE_COOLANT_TEMP_POS);
|
||||
current_value_slow = INTAKE_AIR_TEMP_V;
|
||||
#else
|
||||
@@ -189,8 +186,8 @@ void obd2_elm327_process_slow(obd2_elm327_t *elm327)
|
||||
}
|
||||
case INTAKE_AIR_TEMP_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
elm327->intake_air_temp = 40;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->intake_air_temp = ++elm327->intake_air_temp % 60;
|
||||
elm327->value_updates |= (1 << UPDATE_INTAKE_AIR_TEMP_POS);
|
||||
current_value_slow = AMBIENT_AIR_TEMP_V;
|
||||
#else
|
||||
@@ -211,8 +208,8 @@ void obd2_elm327_process_slow(obd2_elm327_t *elm327)
|
||||
}
|
||||
case AMBIENT_AIR_TEMP_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
elm327->ambient_air_temp = 20;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->ambient_air_temp = ++elm327->ambient_air_temp % 60;
|
||||
elm327->value_updates |= (1 << UPDATE_AMBIENT_AIR_TEMP_POS);
|
||||
current_value_slow = OIL_TEMP_V;
|
||||
#else
|
||||
@@ -233,8 +230,8 @@ void obd2_elm327_process_slow(obd2_elm327_t *elm327)
|
||||
}
|
||||
case OIL_TEMP_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
elm327->engine_oil_temp = 80;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->engine_oil_temp = ++elm327->engine_oil_temp % 150;
|
||||
elm327->value_updates |= (1 << UPDATE_OIL_TEMP_POS);
|
||||
current_value_slow = FUEL_LEVEL_V;
|
||||
#else
|
||||
@@ -255,8 +252,8 @@ void obd2_elm327_process_slow(obd2_elm327_t *elm327)
|
||||
}
|
||||
case FUEL_LEVEL_V:
|
||||
{
|
||||
#if (DEBUG == 1)
|
||||
elm327->fuel_level = 50;
|
||||
#if (DEBUG_VALUES == 1)
|
||||
elm327->fuel_level = ++elm327->fuel_level % 100;
|
||||
elm327->value_updates |= (1 << UPDATE_FUEL_LEVEL_POS);
|
||||
current_value_slow = COOLANT_TEMP_V;
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user