aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRobotMan2412 <julian@scheffers.net>2022-06-20 23:14:16 +0200
committerRobotMan2412 <julian@scheffers.net>2022-06-20 23:14:16 +0200
commita56e6942f1593db530fb5042ca7719770704e943 (patch)
treeeba79f4d0391597632e8acb39e18ef64b9d409cf /main
parent68328d5a853c2e09f6d271f2f85f3aba1b9c4974 (diff)
downloadmch2022-a56e6942f1593db530fb5042ca7719770704e943.tar.gz
mch2022-a56e6942f1593db530fb5042ca7719770704e943.tar.bz2
mch2022-a56e6942f1593db530fb5042ca7719770704e943.zip
Clean up a bit, add exit to launcher function.
Diffstat (limited to 'main')
-rw-r--r--main/include/main.h20
-rw-r--r--main/main.c22
2 files changed, 30 insertions, 12 deletions
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();
+ }
}
}