72 lines
1.5 KiB
C
72 lines
1.5 KiB
C
#include "esp_log.h"
|
|
#include "nvs_flash.h"
|
|
|
|
#include "board_config.h"
|
|
#include "display.h"
|
|
#include "imu.h"
|
|
#include "lvgl_port.h"
|
|
#include "motion_gesture.h"
|
|
#include "touch.h"
|
|
#include "ui.h"
|
|
#include "ui_handlers.h"
|
|
#include "ui_nav.h"
|
|
#include "ble_manager.h"
|
|
#include "settings/settings_store.h"
|
|
|
|
#if BOARD_WIFI_ENABLED
|
|
#include "wifi_manager.h"
|
|
#endif
|
|
|
|
static const char *TAG = "app";
|
|
|
|
void app_main(void)
|
|
{
|
|
esp_log_level_set("*", ESP_LOG_INFO);
|
|
|
|
esp_err_t ret = nvs_flash_init();
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
ret = nvs_flash_init();
|
|
}
|
|
ESP_ERROR_CHECK(ret);
|
|
|
|
esp_lcd_panel_io_handle_t io_handle = NULL;
|
|
esp_lcd_panel_handle_t panel_handle = NULL;
|
|
ESP_ERROR_CHECK(display_init(&io_handle, &panel_handle));
|
|
|
|
lv_display_t *display = lvgl_port_init(io_handle, panel_handle);
|
|
|
|
#if BOARD_TOUCH_ENABLED
|
|
ESP_ERROR_CHECK(touch_init(display));
|
|
#endif
|
|
|
|
lvgl_port_lock();
|
|
ui_init();
|
|
ui_nav_init();
|
|
lvgl_port_unlock();
|
|
|
|
settings_store_load();
|
|
settings_store_apply();
|
|
|
|
ui_handlers_init();
|
|
|
|
motion_gesture_init(NULL);
|
|
|
|
#if BOARD_IMU_ENABLED
|
|
ret = imu_init();
|
|
if (ret == ESP_OK) {
|
|
imu_start_task(motion_gesture_on_sample);
|
|
} else {
|
|
ESP_LOGW(TAG, "IMU init failed, shake navigation unavailable");
|
|
}
|
|
#endif
|
|
|
|
#if BOARD_WIFI_ENABLED
|
|
ESP_LOGI(TAG, "Starting WiFi");
|
|
wifi_manager_init();
|
|
#endif
|
|
|
|
ESP_LOGI(TAG, "Starting BLE");
|
|
ble_manager_init();
|
|
}
|