split into more components

Signed-off-by: Peter Siegmund <peter@rdkr.com>
This commit is contained in:
Peter Siegmund
2024-06-07 23:00:21 +02:00
parent 3cb1b31a37
commit 53d4bf2c5b
7 changed files with 78 additions and 68 deletions

View File

@@ -0,0 +1,7 @@
idf_component_register(SRCS "splash_screen.c"
INCLUDE_DIRS "include"
PRIV_REQUIRES
lilygo-epd47
connectivity
nvs_flash
mapView)

View File

@@ -0,0 +1,9 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void splash_screen(void);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,48 @@
#include "splash_screen.h"
#include <stdio.h>
#include "connectivity.h"
#include "epd_driver.h"
#include "fonts/opensans16.h"
#include "nvs_flash.h"
#include "sdkconfig.h"
void nvs_init(void) {
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);
}
void wifi_init(void) {
epd_poweron();
epd_clear();
int32_t x = 100;
int32_t y = 100;
const int16_t bufferSize = 200;
char buffer[bufferSize];
snprintf(buffer, bufferSize, "Connecting to SSDI: %s", CONFIG_WIFI_SSID);
writeln(&OpenSans16, buffer, &x, &y, NULL);
esp_err_t ret = init_wifi();
if (ret != ESP_OK) {
epd_clear();
x = 100;
y = 100;
snprintf(buffer, bufferSize, "Failed to connect to WiFi: %s",
esp_err_to_name(ret));
writeln(&OpenSans16, buffer, &x, &y, NULL);
epd_poweroff();
while (1) {
///
};
}
epd_poweroff();
}
void splash_screen(void) {
epd_init();
nvs_init();
wifi_init();
}