Add more values

This commit is contained in:
Jasper Blanckenburg 2022-03-13 19:57:34 +01:00
parent 894ced16ef
commit 3cf68cd3cb
2 changed files with 46 additions and 26 deletions

View File

@ -38,17 +38,30 @@ void init_display() {
tft.setTextSize(5,8);
tft.clear();
gear_box.update_label("GEAR");
left_box.update_label("SPEED");
right_box.update_label("RPM");
gear_box.update_label(get_label(VAL_GEAR));
left_box.update_label(get_label(VAL_FIRST_LEFT_BOX));
right_box.update_label(get_label(VAL_RPM));
}
String get_value(Value val) {
switch (val) {
case VAL_GEAR:
if (Vehicle_data.gear == 0) {
return "N";
}
return String(Vehicle_data.gear);
case VAL_RPM:
return String(Vehicle_data.revol);
case VAL_TT_FL:
return "00";
case VAL_TT_FR:
return "01";
case VAL_TT_RL:
return "10";
case VAL_TT_RR:
return "11";
case VAL_LAPTIME:
return "93.13";
case VAL_UBATT:
return String(0.0706949 * Vehicle_data.u_batt, 2);
case VAL_TMOT:
@ -84,6 +97,16 @@ String get_label(Value val) {
return "GEAR";
case VAL_RPM:
return "RPM";
case VAL_TT_FL:
return "TEMP FL";
case VAL_TT_FR:
return "TEMP FR";
case VAL_TT_RL:
return "TEMP RL";
case VAL_TT_RR:
return "TEMP RR";
case VAL_LAPTIME:
return "LAPTIME";
case VAL_UBATT:
return "BATT VOLTAGE";
case VAL_TMOT:
@ -274,28 +297,24 @@ void redraw_page_driver() {
}
void update_page_driver() {
// Top boxes
if (millis() < 2000 || millis() > 4000) {
gear_box.update_value("N");
left_box.update_label("LAPTIME");
left_box.update_value("93.13");
right_box.update_value("1234");
fl_box.update_value(2);
fr_box.update_value(40);
rl_box.update_value(55);
rr_box.update_value(65);
} else {
gear_box.update_value("3");
left_box.update_label("SPEED");
left_box.update_value("313");
right_box.update_value("42");
fl_box.update_value(90);
fr_box.update_value(90);
rl_box.update_value(90);
rr_box.update_value(90);
static Value left_box_value = VAL_FIRST_LEFT_BOX;
if (Stw_data.button4_rises > 0) {
Stw_data.button4_rises--;
if (left_box_value == VAL_LAST) {
left_box_value = VAL_FIRST_LEFT_BOX;
} else {
left_box_value = (Value) (left_box_value + 1);
}
left_box.update_label(get_label(left_box_value));
}
// Tire temperatures
gear_box.update_value(get_value(VAL_GEAR));
left_box.update_value(get_value(left_box_value));
right_box.update_value(get_value(VAL_RPM));
fl_box.update_value(2);
fr_box.update_value(55);
rl_box.update_value(65);
rr_box.update_value(90);
}
void redraw_page_testing() {

View File

@ -26,10 +26,11 @@ enum DisplayPage {PAGE_DRIVER, PAGE_TESTING};
#define DISPLAY_PAGES 2
enum Value {
VAL_GEAR, VAL_RPM, VAL_UBATT, VAL_TMOT, VAL_TAIR, VAL_TOIL, VAL_ERR_TYPE,
VAL_PWAT, VAL_POIL, VAL_PBF, VAL_PBR, VAL_SPEED_FL, VAL_SPEED_FR, VAL_SPEED
VAL_GEAR, VAL_RPM, VAL_TT_FL, VAL_TT_FR, VAL_TT_RL, VAL_TT_RR, VAL_LAPTIME,
VAL_UBATT, VAL_TMOT, VAL_TAIR, VAL_TOIL, VAL_ERR_TYPE, VAL_PWAT, VAL_POIL,
VAL_PBF, VAL_PBR, VAL_SPEED_FL, VAL_SPEED_FR, VAL_SPEED,
VAL_FIRST_LEFT_BOX = VAL_LAPTIME, VAL_LAST = VAL_SPEED
};
#define VALUES 14
String get_value(Value val);
String get_label(Value val);