mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-15 20:21:03 +00:00
add possibility to clear bars
This commit is contained in:
@@ -115,7 +115,6 @@ state_t init_state =
|
||||
.on_run = &on_init_run,
|
||||
.on_exit = &on_init_exit};
|
||||
|
||||
|
||||
state_t main_state =
|
||||
{
|
||||
.id = STATE_CAR_INFO,
|
||||
@@ -326,18 +325,19 @@ void on_main_run()
|
||||
{
|
||||
if (update_slow)
|
||||
{
|
||||
update_slow = 0;
|
||||
obd2_elm327_process_slow(&elm327);
|
||||
|
||||
} else {
|
||||
obd2_elm327_process_fast(&elm327);
|
||||
update_slow = 0;
|
||||
obd2_elm327_process_slow(&elm327);
|
||||
}
|
||||
else
|
||||
{
|
||||
obd2_elm327_process_fast(&elm327);
|
||||
}
|
||||
|
||||
if (elm327.value_updates & (1 << UPDATE_RPM_POS))
|
||||
{
|
||||
elm327.value_updates &= ~(1 << UPDATE_RPM_POS);
|
||||
int width = (int)(display.getDisplayXSize() * ((float)elm327.rpm / 7000.0));
|
||||
display.fillRect(0,20,width,20);
|
||||
display.fillRect(0, 20, width, 20);
|
||||
display.setColor(VGA_FUCHSIA);
|
||||
display.print("rpm", 0, 20);
|
||||
display.printNumI(elm327.engine_load, 30, 20, 4, '0');
|
||||
@@ -390,7 +390,7 @@ void on_main_run()
|
||||
{
|
||||
elm327.value_updates &= ~(1 << UPDATE_ENGINE_LOAD_POS);
|
||||
int width = (int)(display.getDisplayXSize() * ((float)elm327.engine_load / 100.0));
|
||||
display.fillRect(0,50,width,50);
|
||||
display.fillRect(0, 50, width, 50);
|
||||
display.setColor(VGA_FUCHSIA);
|
||||
display.print("el", 0, 50);
|
||||
display.printNumI(elm327.engine_load, 20, 50, 4, '0');
|
||||
@@ -576,29 +576,31 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
|
||||
draw_bar_horizontal(0,0,200,10,bar_1_x,100,VGA_AQUA,1,&display);
|
||||
bar_draw_horizontal(0, 0, 200, 10, bar_1_x, 100, VGA_AQUA, 1, &display);
|
||||
|
||||
draw_bar_horizontal(0,20,200,11,bar_2_x,100,VGA_FUCHSIA,1,&display);
|
||||
bar_draw_horizontal(0, 20, 200, 11, bar_2_x, 100, VGA_FUCHSIA, 0, &display);
|
||||
|
||||
draw_bar_vertical(0,50,20,100,bar_3_y,100,VGA_BLUE,1,&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_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_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_3_y = 50;
|
||||
bar_clear_part_vertical(0,50,20,100,bar_3_y,100,VGA_BLACK,0,&display);
|
||||
}
|
||||
display.clrScr();
|
||||
delay(50);
|
||||
//statemachine_loop();
|
||||
// statemachine_loop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user