diff --git a/main/include/main.h b/main/include/main.h index e69de29..3e534fd 100644 --- a/main/include/main.h +++ b/main/include/main.h @@ -0,0 +1,20 @@ + +#pragma once + +#include "hardware.h" +#include "pax_gfx.h" +#include "pax_codecs.h" +#include "ili9341.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "esp_system.h" +#include "nvs.h" +#include "nvs_flash.h" +#include "wifi_connect.h" +#include "wifi_connection.h" +#include "soc/rtc.h" +#include "soc/rtc_cntl_reg.h" + +void disp_flush(); +void exit_to_launcher(); diff --git a/main/main.c b/main/main.c index 24c71d3..3a7d2e7 100644 --- a/main/main.c +++ b/main/main.c @@ -2,18 +2,6 @@ // This file contains a simple hello world app which you can base you own apps on. #include "main.h" -#include "hardware.h" -#include "pax_gfx.h" -#include "pax_codecs.h" -#include "ili9341.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_system.h" -#include "nvs.h" -#include "nvs_flash.h" -#include "wifi_connect.h" -#include "wifi_connection.h" static pax_buf_t buf; xQueueHandle buttonQueue; @@ -24,6 +12,11 @@ void disp_flush() { ili9341_write(get_ili9341(), buf.buf); } +void exit_to_launcher() { + REG_WRITE(RTC_CNTL_STORE0_REG, 0); + esp_restart(); +} + void app_main() { // Init HW. bsp_init(); @@ -60,5 +53,10 @@ void app_main() { // Await any button press and do another cycle. rp2040_input_message_t message; xQueueReceive(buttonQueue, &message, portMAX_DELAY); + + if (message.input == RP2040_INPUT_BUTTON_HOME && message.state) { + // If home is pressed, exit to launcher. + exit_to_launcher(); + } } }