Files
cardboy/Firmware/main/src/app_main.cpp
2025-10-09 09:26:34 +02:00

76 lines
1.9 KiB
C++

// Cardboy firmware entry point: boot platform services and run the modular app system.
#include "app_system.hpp"
#include "app_framework.hpp"
#include "apps/clock_app.hpp"
#include "apps/gameboy_app.hpp"
#include "apps/menu_app.hpp"
#include "apps/tetris_app.hpp"
#include "config.hpp"
#include <bat_mon.hpp>
#include <buttons.hpp>
#include <buzzer.hpp>
#include <disp_tools.hpp>
#include <display.hpp>
#include <fs_helper.hpp>
#include <i2c_global.hpp>
#include <power_helper.hpp>
#include <shutdowner.hpp>
#include <spi_global.hpp>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_pm.h"
#include "esp_sleep.h"
#include "sdkconfig.h"
extern "C" void app_main() {
#ifdef CONFIG_PM_ENABLE
// const esp_pm_config_t pm_config = {
// .max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ,
// .min_freq_mhz = 16,
// .light_sleep_enable = true};
// ESP_ERROR_CHECK(esp_pm_configure(&pm_config));
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
#endif
PowerHelper::get();
Shutdowner::get();
Buttons::get();
ESP_ERROR_CHECK(gpio_install_isr_service(0));
Shutdowner::get().install_isr();
PowerHelper::get().install_isr();
Buttons::get().install_isr();
I2cGlobal::get();
BatMon::get();
SpiGlobal::get();
SMD::init();
DispTools::clear();
Buzzer::get().init();
FsHelper::get().mount();
static PlatformFramebuffer framebuffer;
static PlatformInput input;
static PlatformClock clock;
AppContext context(framebuffer, input, clock);
AppSystem system(context);
context.system = &system;
system.registerApp(apps::createMenuAppFactory());
system.registerApp(apps::createClockAppFactory());
system.registerApp(apps::createTetrisAppFactory());
system.registerApp(apps::createGameboyAppFactory());
system.run();
}