split into more components
Signed-off-by: Peter Siegmund <peter@rdkr.com>
This commit is contained in:
7
ePaper-ESP-IDF/components/splash_screen/CMakeLists.txt
Normal file
7
ePaper-ESP-IDF/components/splash_screen/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
idf_component_register(SRCS "splash_screen.c"
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES
|
||||
lilygo-epd47
|
||||
connectivity
|
||||
nvs_flash
|
||||
mapView)
|
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void splash_screen(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
48
ePaper-ESP-IDF/components/splash_screen/splash_screen.c
Normal file
48
ePaper-ESP-IDF/components/splash_screen/splash_screen.c
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user