Files
xiaozhi-esp32/main/main.cc

45 lines
1.2 KiB
C++
Raw Normal View History

2024-08-31 18:00:23 +08:00
#include <cstdio>
#include "esp_log.h"
#include "esp_err.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
2024-10-01 14:16:12 +08:00
#include "esp_event.h"
2024-08-31 18:00:23 +08:00
#include "Application.h"
#include "SystemInfo.h"
2024-09-10 00:45:13 +08:00
#include "SystemReset.h"
2024-08-31 18:00:23 +08:00
#define TAG "main"
#define STATS_TICKS pdMS_TO_TICKS(1000)
extern "C" void app_main(void)
{
2024-09-10 00:45:13 +08:00
// Check if the reset button is pressed
SystemReset system_reset;
system_reset.CheckButtons();
2024-08-31 18:00:23 +08:00
// Initialize the default event loop
ESP_ERROR_CHECK(esp_event_loop_create_default());
// Initialize NVS flash for WiFi configuration
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);
// Otherwise, launch the application
2024-09-10 05:58:56 +08:00
Application::GetInstance().Start();
2024-08-31 18:00:23 +08:00
2024-09-05 17:22:01 +08:00
// Dump CPU usage every 10 second
2024-08-31 18:00:23 +08:00
while (true) {
2024-09-05 17:22:01 +08:00
vTaskDelay(10000 / portTICK_PERIOD_MS);
2024-09-03 13:57:18 +08:00
// SystemInfo::PrintRealTimeStats(STATS_TICKS);
2024-08-31 18:00:23 +08:00
int free_sram = heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL);
2024-10-01 14:16:12 +08:00
ESP_LOGI(TAG, "Free heap size: %u minimal internal: %u", SystemInfo::GetFreeHeapSize(), free_sram);
2024-08-31 18:00:23 +08:00
}
}