Initial commit
This commit is contained in:
47
main/app_main.c
Normal file
47
main/app_main.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bsp/esp-bsp.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "lvgl.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "ui_main.h"
|
||||
|
||||
static const char *TAG = "tarot_app";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
err = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(err);
|
||||
|
||||
ESP_ERROR_CHECK(settings_init());
|
||||
|
||||
lv_display_t *display = bsp_display_start();
|
||||
if (display == NULL) {
|
||||
ESP_LOGE(TAG, "Waveshare BSP failed to initialize display/touch");
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_TAROT_START_BRIGHTNESS_FROM_NVS
|
||||
tarot_settings_t settings = settings_get();
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(bsp_display_brightness_set(settings.brightness));
|
||||
#else
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(bsp_display_backlight_on());
|
||||
#endif
|
||||
|
||||
if (bsp_display_lock(1000)) {
|
||||
ui_main_init();
|
||||
ui_show_home();
|
||||
bsp_display_unlock();
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Timed out taking LVGL lock during UI startup");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user