summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1a73845..a4f80a8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,8 +2,10 @@
#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
+#include <WiFi.h>
#include "tux.h"
+#include "secrets.h"
/*
see GxEPD2_WS_ESP32_Driver.ino and esp32-waveshare-epd/src/DEV_Config.h
@@ -47,13 +49,42 @@ void draw() {
} while(display.nextPage());
}
+void wifi_connect() {
+ WiFi.begin(wifi_ssid, wifi_psk);
+ while (WiFi.status() != WL_CONNECTED) {
+ delay(500);
+ }
+}
+
+void wifi_disconnect() {
+ WiFi.disconnect();
+ WiFi.mode(WIFI_OFF);
+}
+
+void update_time() {
+ struct tm timeinfo;
+ configTime(0, 0, "de.pool.ntp.org");
+ getLocalTime(&timeinfo, 5000);
+}
+
void setup() {
- display_setup();
- draw();
+ Serial.begin(115200);
+
+ //display_setup();
+ //draw();
+ //display.powerOff();
- display.powerOff();
+ wifi_connect();
+ update_time();
+ wifi_disconnect();
}
void loop() {
+ struct tm timeinfo;
+ if (getLocalTime(&timeinfo)) {
+ Serial.println(&timeinfo);
+ } else {
+ Serial.println("Unknown time");
+ }
delay(1000);
}