mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-15 20:21:03 +00:00
add updating init percent and add getting OBD2 PIDS
This commit is contained in:
@@ -118,6 +118,12 @@ state_t main_state =
|
||||
/* Standard Arduino Mega/Due shield : <display model>,38,39,40,41 */
|
||||
UTFT display(ILI9486, 38, 39, 40, 41);
|
||||
|
||||
void update_percent(uint8_t amount)
|
||||
{
|
||||
init_percent += amount;
|
||||
init_flag |= (1 << FLAG_INIT_UPDATE_PERCENT_POS);
|
||||
}
|
||||
|
||||
/****************************/
|
||||
/*INIT STATE*/
|
||||
/****************************/
|
||||
@@ -136,12 +142,13 @@ void on_init_enter()
|
||||
Timer2.start(MS(100));
|
||||
|
||||
// TODO change to update when initializing bluetooth..
|
||||
Timer1.attachInterrupt(update_percent_test);
|
||||
Timer1.start(MS(60));
|
||||
// Timer1.attachInterrupt(update_percent_test);
|
||||
// Timer1.start(MS(60));
|
||||
|
||||
Timer3.attachInterrupt(update_ram_kb);
|
||||
|
||||
logo_flag |= (1 << FLAG_LOGO_UPDATE);
|
||||
init_flag |= (1 << FLAG_INIT_UPDATE_PERCENT_POS);
|
||||
}
|
||||
|
||||
void on_init_run()
|
||||
@@ -214,6 +221,7 @@ void on_init_run()
|
||||
text_temp[0] = cpu_text[device_label_i];
|
||||
int x_position = x_offset + (device_label_i * display.getFontXsize());
|
||||
display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3));
|
||||
update_percent(1);
|
||||
break;
|
||||
}
|
||||
case DEV_RAM:
|
||||
@@ -229,6 +237,7 @@ void on_init_run()
|
||||
text_temp[0] = display_size_text[device_label_i];
|
||||
int x_position = x_offset + (device_label_i * display.getFontXsize());
|
||||
display.print(text_temp, x_position, 10 + (init_device_info * display.getFontYsize() + 3));
|
||||
update_percent(1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -255,6 +264,7 @@ void on_init_run()
|
||||
if (logo_pos_y >= LOGO_MAX_POS_Y)
|
||||
{
|
||||
logo_flag &= ~(1 << FLAG_LOGO_UPDATE);
|
||||
update_percent(10);
|
||||
}
|
||||
if (logo_pos_i > LOGO_MIN_STEP)
|
||||
{
|
||||
@@ -308,21 +318,6 @@ void update_init_text()
|
||||
init_flag |= (1 << FLAG_INIT_UPDATE_TEXT_POS);
|
||||
}
|
||||
|
||||
void update_percent_test()
|
||||
{
|
||||
init_percent++;
|
||||
if (init_percent > 100)
|
||||
{
|
||||
init_percent = 0;
|
||||
}
|
||||
init_flag |= (1 << FLAG_INIT_UPDATE_PERCENT_POS);
|
||||
|
||||
/* count KB up */
|
||||
if (init_device_info == DEV_RAM && (0 == (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS))))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void update_device_info()
|
||||
{
|
||||
if (init_flag & (1 << FLAG_DEVICE_LABEL_SHOULD_UPDATE_POS))
|
||||
@@ -337,9 +332,6 @@ void update_device_info()
|
||||
init_device_info = DEV_RAM;
|
||||
device_label_i = 0;
|
||||
Timer3.start(50);
|
||||
#if (DEBUG == 1)
|
||||
Serial.println("DEV RAM");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case DEV_RAM:
|
||||
@@ -349,6 +341,7 @@ void update_device_info()
|
||||
Timer3.stop();
|
||||
init_device_info = DEV_DISPLAY;
|
||||
device_label_i = 0;
|
||||
update_percent(10);
|
||||
}
|
||||
break;
|
||||
case DEV_DISPLAY:
|
||||
@@ -357,6 +350,7 @@ void update_device_info()
|
||||
{
|
||||
init_device_info = DEV_DONE;
|
||||
// init_flag &= ~(1 << FLAG_DEVICE_LABEL_UPDATE_POS);
|
||||
update_percent(10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -369,6 +363,7 @@ void update_device_info()
|
||||
{
|
||||
case DEV_CPU:
|
||||
device_label_i++;
|
||||
update_percent(1);
|
||||
if (device_label_i > DEV_LABEL_LENGTH)
|
||||
{
|
||||
init_device_info = DEV_RAM;
|
||||
@@ -378,6 +373,7 @@ void update_device_info()
|
||||
break;
|
||||
case DEV_RAM:
|
||||
device_label_i++;
|
||||
update_percent(1);
|
||||
if (device_label_i > DEV_LABEL_LENGTH)
|
||||
{
|
||||
init_device_info = DEV_DISPLAY;
|
||||
@@ -387,6 +383,7 @@ void update_device_info()
|
||||
break;
|
||||
case DEV_DISPLAY:
|
||||
device_label_i++;
|
||||
update_percent(1);
|
||||
if (device_label_i > DEV_LABEL_LENGTH)
|
||||
{
|
||||
device_label_i = 0;
|
||||
@@ -411,6 +408,11 @@ void update_ram_kb()
|
||||
init_flag |= (1 << FLAG_DEVICE_LABEL_UPDATE_POS);
|
||||
}
|
||||
|
||||
void bt_state_changed()
|
||||
{
|
||||
update_percent(10);
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
||||
{
|
||||
@@ -447,6 +449,7 @@ void setup()
|
||||
display.print("Waiting for ELM327", (display.getDisplayXSize() / 2) - ((18 * display.getFontXsize()) / 2), 160);
|
||||
|
||||
obd2_elm327_init(&elm327);
|
||||
elm327.on_state_change = &bt_state_changed;
|
||||
#if (DEBUG == 1)
|
||||
Serial.println("done with elm327 init");
|
||||
Serial.println(elm327.elm327->connected);
|
||||
|
||||
Reference in New Issue
Block a user