aboutsummaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
authorRenze Nicolai <renze@rnplus.nl>2022-06-03 01:30:50 +0200
committerRenze Nicolai <renze@rnplus.nl>2022-06-03 01:30:50 +0200
commitcf5f513f102f000d514ea785821e4282166ed2db (patch)
treea4bdbf0870a1a070ea5d98f21556119a3362bb58 /main/main.c
parent1412a861087c82d31a5005510d7a6bf10d48b266 (diff)
downloadmch2022-cf5f513f102f000d514ea785821e4282166ed2db.tar.gz
mch2022-cf5f513f102f000d514ea785821e4282166ed2db.tar.bz2
mch2022-cf5f513f102f000d514ea785821e4282166ed2db.zip
Factory test and a couple of bugfixes
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/main/main.c b/main/main.c
index 1b5f8a3..872d032 100644
--- a/main/main.c
+++ b/main/main.c
@@ -48,6 +48,8 @@
#include "menus/start.h"
+#include "factory_test.h"
+
extern const uint8_t wallpaper_png_start[] asm("_binary_wallpaper_png_start");
extern const uint8_t wallpaper_png_end[] asm("_binary_wallpaper_png_end");
@@ -102,9 +104,19 @@ void app_main(void) {
esp_restart();
}
- display_boot_screen(pax_buffer, ili9341, "Starting...");
+ /* Start NVS */
+ res = nvs_init();
+ if (res != ESP_OK) {
+ ESP_LOGE(TAG, "NVS init failed: %d", res);
+ display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "NVS failed to initialize", "Flash may be corrupted", NULL);
+ esp_restart();
+ }
audio_init();
+
+ factory_test(pax_buffer, ili9341);
+
+ display_boot_screen(pax_buffer, ili9341, "Starting...");
if (bsp_rp2040_init() != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize the RP2040 co-processor");
@@ -178,16 +190,6 @@ void app_main(void) {
display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "AppFS failed to initialize", "Flash may be corrupted", NULL);
esp_restart();
}
-
- //display_boot_screen(pax_buffer, ili9341, "Initializing NVS...");
-
- /* Start NVS */
- res = nvs_init();
- if (res != ESP_OK) {
- ESP_LOGE(TAG, "NVS init failed: %d", res);
- display_fatal_error(pax_buffer, ili9341, "Failed to initialize", "NVS failed to initialize", "Flash may be corrupted", NULL);
- esp_restart();
- }
//display_boot_screen(pax_buffer, ili9341, "Initializing filesystem...");
@@ -217,12 +219,14 @@ void app_main(void) {
bool sdcard_ready = (res == ESP_OK);
if (sdcard_ready) {
ESP_LOGI(TAG, "SD card filesystem mounted");
- }
- /* Start LEDs */
- ws2812_init(GPIO_LED_DATA);
- uint8_t ledBuffer[15] = {50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0, 50, 0, 0};
- ws2812_send_data(ledBuffer, sizeof(ledBuffer));
+ /* LED power is on: start LED driver and turn LEDs off */
+ ws2812_init(GPIO_LED_DATA);
+ const uint8_t led_off[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ ws2812_send_data(led_off, sizeof(led_off));
+ } else {
+ gpio_set_level(GPIO_SD_PWR, 0); // Disable power to LEDs and SD card
+ }
/* Start WiFi */
wifi_init();