 struct EngineVariable
 {
   String shortLabel;
-  //String longLabel;
   double currentValue;
   double previousValue;
   double minimum;

  lcd.createChar(2, fill3);
  lcd.createChar(3, fill4);
  lcd.createChar(4, fill5);

  idleGauges[0] = &engine_rpm;
  idleGauges[1] = &engine_map;
  idleGauges[2] = &engine_afr;
  idleGauges[3] = &engine_adv;
  idleGauges[4] = &engine_clt;
  idleGauges[5] = &engine_iat;
  idleGauges[6] = &engine_pw1;
  idleGauges[7] = &engine_bat;
  
  lcd.begin(20, 4);
  //lcd.print(engine_rpm.shortLabel);
  //lcd.setCursor(0, 2);
  //lcd.print(engine_afr.shortLabel);

  Serial.begin(115200);
  while (CAN_OK != CAN.begin(CAN_500KBPS))              // init can bus : baudrate = 500k

  if(currentMillis - lastMillis >= interval) {
    lastMillis = currentMillis;
    if(engine_rpm.currentValue < 2000) {
      draw_octo_gauges();
    }
    else {
      draw_dual_gauges();
      
 
    }
  }
}


void clear_mode() {
  dualModeReady = false;
  quadModeReady = false;
  octoModeReady = false;
  lcd.clear();
}

void draw_dual_gauges() {
  if(!dualModeReady) {
    clear_mode();
    lcd.setCursor(0, 0);
    lcd.print(dualModeGauges[0][0]->shortLabel);
    lcd.setCursor(0, 2);
    lcd.print(dualModeGauges[0][1]->shortLabel);
    dualModeReady = true;
  }
  //if(dualModeGauges[0][0]->currentValue != dualModeGauges[0][0]->previousValue) {
    lcd.setCursor(4, 0);
    if(is_current_value_shorter(*dualModeGauges[0][0])) {
      lcd.print("     ");
      lcd.setCursor(4, 0);
    }
    lcd.print(dualModeGauges[0][0]->currentValue, dualModeGauges[0][0]->decimalPlaces);
    draw_bar(*dualModeGauges[0][0], 1);
  //}
  //if(dualModeGauges[0][1]->currentValue != dualModeGauges[0][1]->previousValue) {
    lcd.setCursor(4, 2);
    if(is_current_value_shorter(*dualModeGauges[0][1])) {
      lcd.print("     ");
      lcd.setCursor(4, 2);
    }
    lcd.print(dualModeGauges[0][1]->currentValue, dualModeGauges[0][1]->decimalPlaces);
    draw_bar(*dualModeGauges[0][1], 3);
  //}
}

void draw_quad_gauges() {
  if(!quadModeReady) {
    clear_mode();
    lcd.setCursor(0, 0);
    lcd.print(quadModeGauges[0][0]->shortLabel);
    lcd.setCursor(0, 1);
    lcd.print(quadModeGauges[0][1]->shortLabel);
    lcd.setCursor(0, 2);
    lcd.print(quadModeGauges[0][2]->shortLabel);
    lcd.setCursor(0, 3);
    lcd.print(quadModeGauges[0][3]->shortLabel);
    quadModeReady = true;
  }

  lcd.setCursor(4, 0);
  if(is_current_value_shorter(*quadModeGauges[0][0])) {
    lcd.print("     ");
    lcd.setCursor(4, 0);
  }
  lcd.print(quadModeGauges[0][0]->currentValue, quadModeGauges[0][0]->decimalPlaces);

  lcd.setCursor(4, 1);
  lcd.print(quadModeGauges[0][1]->currentValue, quadModeGauges[0][1]->decimalPlaces);

  lcd.setCursor(4, 2);
  lcd.print(quadModeGauges[0][2]->currentValue, quadModeGauges[0][2]->decimalPlaces);

  lcd.setCursor(4, 3);
  lcd.print(quadModeGauges[0][3]->currentValue, quadModeGauges[0][3]->decimalPlaces);
}

void draw_octo_gauges() {

  if(!octoModeReady) {
    clear_mode();
    //left column of labels
    lcd.setCursor(0, 0);
    lcd.print(octoModeGauges[0][0]->shortLabel);
    lcd.setCursor(0, 1);
    lcd.print(octoModeGauges[0][1]->shortLabel);
    lcd.setCursor(0, 2);
    lcd.print(octoModeGauges[0][2]->shortLabel);
    lcd.setCursor(0, 3);
    lcd.print(octoModeGauges[0][3]->shortLabel);

    //draw dividing line
    lcd.setCursor(9, 0);
