|
@@ -4,15 +4,36 @@
|
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
|
|
*/
|
|
|
|
|
|
-#include "wifi.h"
|
|
|
+#include <time.h>
|
|
|
|
|
|
-#include <esp_system.h>
|
|
|
+#include <freertos/FreeRTOS.h>
|
|
|
+#include <freertos/event_groups.h>
|
|
|
#include <nvs_flash.h>
|
|
|
+#include <esp_log.h>
|
|
|
+#include <esp_wifi.h>
|
|
|
|
|
|
-void app_main(void) {
|
|
|
- ESP_ERROR_CHECK(nvs_flash_init());
|
|
|
+#include "wifi.h"
|
|
|
+#include "configuration.h"
|
|
|
+#include "ds3231.h"
|
|
|
+#include "tm1637.h"
|
|
|
+#include "time_sync.h"
|
|
|
+#include "time_display.h"
|
|
|
|
|
|
- wifi_init();
|
|
|
- wifi_start();
|
|
|
- printf("Finished wifi initialization\n");
|
|
|
-}
|
|
|
+void app_main(void) {
|
|
|
+ struct tm current_time;
|
|
|
+
|
|
|
+ ESP_ERROR_CHECK(nvs_flash_init());
|
|
|
+ ESP_ERROR_CHECK(esp_netif_init());
|
|
|
+ ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
|
+ wifi_init();
|
|
|
+ wifi_start();
|
|
|
+ ds3231_init(DS3231_SDA_PIN, DS3231_SCL_PIN);
|
|
|
+ tm1637_init(TM1637_CLK_PIN, TM1637_DIO_PIN, true, 1);
|
|
|
+ ds3231_read_date_time(¤t_time);
|
|
|
+ sntp_start(21600);
|
|
|
+ if (current_time.tm_year == 0) {
|
|
|
+ await_sntp_sync();
|
|
|
+ }
|
|
|
+
|
|
|
+ xTaskCreate(display_update_task, "display_update_task", 2048, NULL, 7, NULL);
|
|
|
+}
|