text: /*
   * @Author: your name
   * @Date: 2021-10-11 09:13:16
   * @LastEditTime: 2021-11-04 09:25:36
   * @LastEditors: Please set LastEditors
   * @Description: In User Settings Edit
   * @FilePath: \Peak-ESP32-fw\src\HAL\HAL.cpp
   */
  #include "HAL/HAL.h"
  #include "App/Configs/Version.h"
  
  #define DISP_HOR_RES         CONFIG_SCREEN_HOR_RES
  #define DISP_VER_RES         CONFIG_SCREEN_VER_RES
  #define DISP_BUF_SIZE        CONFIG_SCREEN_BUFFER_SIZE
  extern lv_color_t* lv_disp_buf_p;
  
  void HAL::Init()
  {
      Serial.begin(115200);
      Serial.println(VERSION_FIRMWARE_NAME);
      Serial.println("Version: " VERSION_SOFTWARE);
      Serial.println("Author: " VERSION_AUTHOR_NAME);
  
      // Move the malloc process to Init() to make sure that the largest heap can be used for this buffer.
      /* lv_disp_buf_p = static_cast<lv_color_t*>(malloc(DISP_BUF_SIZE * sizeof(lv_color_t)));
      if (lv_disp_buf_p == nullptr)
          LV_LOG_WARN("lv_port_disp_init malloc failed!\n"); */
  
      HAL::BT_Init(); // ToDo: some of the process below will interrupt BLE connection, find it out
      HAL::Power_Init();
      HAL::Backlight_Init();
      //HAL::Encoder_Init();
      HAL::Buzz_init();
      HAL::Audio_Init();
      HAL::SD_Init();
      HAL::I2C_Init(true);
      HAL::IMU_Init();
  
      HAL::Audio_PlayMusic("Startup");
  }
  
  void HAL::Update()
  {
      HAL::Power_Update();
      //HAL::Encoder_Update();
      HAL::Audio_Update();
      HAL::IMU_Update();
      HAL::BT_Update();
      __IntervalExecute(HAL::SD_Update(), 500);
  }
  