void main() {

  Start_TP();

  Init_GPIO();
  Init_SDIO();
  Init_Ext_Mem();
  Init_FAT();
  RTC_Init();
  
  I2C2_Init_Advanced(400000, &_GPIO_MODULE_I2C2_PF01);
  UART2_Init_Advanced(9600, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_USART2_PD5_PA3);
  MPU9150A_FSY = 0;
  MPU9150A_Init();
  MPU9150A_Detect();
  MAG_Detect();
  tmrTicks = 0;
  initTimer2();
  Timer2_On();
  MPU9150A_Read(); //initial read
  delay_ms(10);

  while (1) {
    DisableInterrupts();
    Check_TP();
    EnableInterrupts();
    //DrawScreen(&Boot);
    //DrawScreen(&Speedometer_graphics);
    Run_logger();

  }
}
void Start_TP() {
  Init_MCU();

  Init_Ext_Mem();

  InitializeTouchPanel();

  // You can get calibration constants using touch panel calibration example
  TP_TFT_Set_Calibration_Consts(149, 776, 68, 765);    // Set calibration constants

  InitializeObjects();
  display_width = Screen1.Width;
  display_height = Screen1.Height;
  DrawScreen(&Screen1);
}
void Start_TP() {
  Init_MCU();

  Init_Ext_Mem();

  InitializeTouchPanel();

  Delay_ms(1000);
  TFT_Fill_Screen(0);
  Calibrate();
  TFT_Fill_Screen(0);

  InitializeObjects();
  display_width = Screen1.Width;
  display_height = Screen1.Height;
  DrawScreen(&Screen1);
}