Files
xInfo/main/main.cpp
T
2026-08-31 15:05:13 +08:00

38 lines
1000 B
C++

/**
* @file main.cpp
* @brief Main entry point for the ESP-IDF E-paper Demo.
*
* This file handles the initial NVS flash initialization and bootstraps the
* main application execution encapsulated within the App class.
*/
#include "App.h"
#include "esp_log.h"
#include "nvs_flash.h"
static const char *TAG = "EPD_DEMO_MAIN";
/**
* @brief Application entry point called by the ESP-IDF framework.
*
* It ensures the Non-Volatile Storage (NVS) is initialized before passing
* control to the App instance.
*/
extern "C" void app_main(void) {
ESP_LOGI(TAG, "Starting NVS...");
// Initialize NVS, erasing it first if it contains an unsupported version
// or no free pages.
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);
// Instantiate and run the main application logic
App app;
app.init();
app.run();
}