Some changes :)
This commit is contained in:
parent
8ec317b07d
commit
646aa9fce4
@ -77,9 +77,9 @@ void showDailyText(String losung, String lehrtext, String losungPosition, String
|
|||||||
// display title
|
// display title
|
||||||
paint.Clear(UNCOLORED);
|
paint.Clear(UNCOLORED);
|
||||||
int startTitleAtX = round((paint.GetWidth()-strlen(TITLE_TEXT)*TITLE_FONT.Width)/2);
|
int startTitleAtX = round((paint.GetWidth()-strlen(TITLE_TEXT)*TITLE_FONT.Width)/2);
|
||||||
paint.DrawStringAt(startTitleAtX, 2, TITLE_TEXT, &TITLE_FONT, COLORED);
|
paint.DrawStringAt(startTitleAtX, 0, TITLE_TEXT, &TITLE_FONT, COLORED);
|
||||||
paint.DrawHorizontalLine(startTitleAtX+15, TITLE_FONT.Height+1, paint.GetWidth()-(startTitleAtX+15)*2, COLORED);
|
paint.DrawHorizontalLine(startTitleAtX+15, TITLE_FONT.Height+1, paint.GetWidth()-(startTitleAtX+15)*2, COLORED);
|
||||||
|
text_y = TITLE_PADDING_TOP;
|
||||||
epd.TransmitPartialData(paint.GetImage(), text_x, text_y, paint.GetWidth(), paint.GetHeight());
|
epd.TransmitPartialData(paint.GetImage(), text_x, text_y, paint.GetWidth(), paint.GetHeight());
|
||||||
text_y += TITLE_FONT.Height+2;
|
text_y += TITLE_FONT.Height+2;
|
||||||
|
|
||||||
|
@ -21,13 +21,22 @@ const int daylightOffset_sec = 3600; // for daylight saving
|
|||||||
// style of the frame shown
|
// style of the frame shown
|
||||||
sFONT TITLE_FONT = Font20;
|
sFONT TITLE_FONT = Font20;
|
||||||
char TITLE_TEXT[] = "Losung heute";
|
char TITLE_TEXT[] = "Losung heute";
|
||||||
|
int TITLE_PADDING_TOP = 10;
|
||||||
sFONT TEXT_FONT = Font12; // for the daily text
|
sFONT TEXT_FONT = Font12; // for the daily text
|
||||||
int TEXT_WIDTH = 168; // width of the box around the text; should be a multiple of the width of the font (eg. Font8 => multiple of 8)
|
int TEXT_WIDTH = 168; // width of the box around the text; should be a multiple of the width of the font (eg. Font8 => multiple of 8)
|
||||||
int TEXT_PADDING_TOP = 30;
|
int TEXT_PADDING_TOP = 20;
|
||||||
int TEXT_PADDING_BETWEEN_BLOCKS = 20; // pixels between the lines
|
int TEXT_PADDING_BETWEEN_BLOCKS = 20; // pixels between the lines
|
||||||
int TEXT_PADDING_BETWEEN_LINES = 1; // pixels between the lines
|
int TEXT_PADDING_BETWEEN_LINES = 1; // pixels between the lines
|
||||||
sFONT SOURCE_FONT = Font8; // for the position in bible
|
sFONT SOURCE_FONT = Font8; // for the position in bible
|
||||||
|
|
||||||
|
void deepSleep() {
|
||||||
|
// deep sleep for DEEP_SLEEP_TIME seconds
|
||||||
|
esp_sleep_enable_timer_wakeup(DEEP_SLEEP_TIME*us_s_conversion_factor);
|
||||||
|
Serial.printf("[ESP32] Entering deep sleep mode for %ds\n", DEEP_SLEEP_TIME);
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool gotLosung = false; // if everything worked and http get returned HTTP 200
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -39,16 +48,34 @@ void setup() {
|
|||||||
}
|
}
|
||||||
Serial.println("[INFO] Initialized e-Paper!");
|
Serial.println("[INFO] Initialized e-Paper!");
|
||||||
|
|
||||||
connectWiFi();
|
if(connectWiFi()) {
|
||||||
|
Serial.println("[NTP] Getting time...");
|
||||||
|
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer.c_str());
|
||||||
|
Serial.println("[NTP] Got time.");
|
||||||
|
}
|
||||||
String html = getHTML();
|
String html = getHTML();
|
||||||
|
if(html != "") gotLosung = true;
|
||||||
|
|
||||||
showDailyText(getLosungFromHTML(html), getLehrtextFromHTML(html), getLosungSourceFromHTML(html), getLehrtextSourceFromHTML(html));
|
if(gotLosung) {
|
||||||
|
showDailyText(getLosungFromHTML(html), getLehrtextFromHTML(html), getLosungSourceFromHTML(html), getLehrtextSourceFromHTML(html));
|
||||||
// deep sleep for DEEP_SLEEP_TIME seconds
|
deepSleep();
|
||||||
esp_sleep_enable_timer_wakeup(DEEP_SLEEP_TIME*us_s_conversion_factor);
|
}
|
||||||
Serial.printf("[ESP32] Entering deep sleep mode for %ds\n", DEEP_SLEEP_TIME);
|
|
||||||
esp_deep_sleep_start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if(!gotLosung) {
|
||||||
|
if(connectWiFi()) {
|
||||||
|
Serial.println("[NTP] Getting time...");
|
||||||
|
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer.c_str());
|
||||||
|
Serial.println("[NTP] Got time.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String html = getHTML();
|
||||||
|
if(html != "") gotLosung = true;
|
||||||
|
|
||||||
|
if(gotLosung) {
|
||||||
|
showDailyText(getLosungFromHTML(html), getLehrtextFromHTML(html), getLosungSourceFromHTML(html), getLehrtextSourceFromHTML(html));
|
||||||
|
deepSleep();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
18
wifi.ino
18
wifi.ino
@ -1,8 +1,8 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
void connectWiFi() { // connect to the wifi with the above defined credentials
|
bool connectWiFi() { // connect to the wifi with the above defined credentials
|
||||||
if(WiFi.status() == WL_CONNECTED) { return; } // return if not connected
|
if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected
|
||||||
|
|
||||||
Serial.print("[WiFi] Connecting to WiFi...");
|
Serial.print("[WiFi] Connecting to WiFi...");
|
||||||
|
|
||||||
@ -10,19 +10,15 @@ void connectWiFi() { // connect to the wifi with the above defined credentials
|
|||||||
while(WiFi.status() != WL_CONNECTED) {
|
while(WiFi.status() != WL_CONNECTED) {
|
||||||
delay(2000); Serial.printf(".");
|
delay(2000); Serial.printf(".");
|
||||||
if(WiFi.status() == WL_NO_SSID_AVAIL) {
|
if(WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||||
Serial.println("[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL");
|
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL");
|
||||||
return;
|
return false;
|
||||||
} else if(WiFi.status() == WL_CONNECT_FAILED) {
|
} else if(WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
Serial.println("[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED");
|
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.printf("\n[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID);
|
Serial.printf("\n[WiFi] Connected to WiFi \"%s\", got IP-Adress ", wiFiSSID);
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
Serial.println("[NTP] Getting time...");
|
return true;
|
||||||
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer.c_str());
|
|
||||||
Serial.println("[NTP] Got time.");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user