Added Wifi Routine on unsuccessful connect
This commit is contained in:
@@ -52,11 +52,24 @@ void loop() {
|
|||||||
|
|
||||||
void connectToWifi() {
|
void connectToWifi() {
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
|
int connectTries = 0; // Counter for unsuccessful connects to WiFi
|
||||||
Serial.print("WIFI: Connecting ");
|
Serial.print("WIFI: Connecting ");
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
|
if(connectTries % 4 == 3) {
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(connectTries >= 20) {
|
||||||
|
Serial.println("Unable to connect to " + WiFi.SSID() + ". ESP32 going to deep sleep.");
|
||||||
|
esp_wifi_stop();
|
||||||
|
esp_bt_controller_disable();
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
}
|
||||||
|
connectTries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("WIFI: Connected to network");
|
Serial.println("WIFI: Connected to network");
|
||||||
@@ -65,15 +78,14 @@ void connectToWifi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char GreeterText[] = "Reddit | Showerthoughts";
|
const char TitleText[] = "Reddit | Showerthoughts";
|
||||||
|
|
||||||
void DisplayShowerthought() {
|
void DisplayShowerthought() {
|
||||||
Serial.println("DEBUG: Showing greeting screen");
|
Serial.println("DEBUG: Printing Showerthought to display");
|
||||||
//display.setRotation(3);
|
|
||||||
display.setFont(&FreeMonoBold9pt7b);
|
display.setFont(&FreeMonoBold9pt7b);
|
||||||
display.setTextColor(GxEPD_BLACK);
|
display.setTextColor(GxEPD_BLACK);
|
||||||
int16_t tbx, tby; uint16_t tbw, tbh;
|
int16_t tbx, tby; uint16_t tbw, tbh;
|
||||||
display.getTextBounds(GreeterText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
display.getTextBounds(TitleText, 0, 0, &tbx, &tby, &tbw, &tbh);
|
||||||
uint16_t x = ((display.width() - tbw) / 2) - tbx;
|
uint16_t x = ((display.width() - tbw) / 2) - tbx;
|
||||||
uint16_t y = ((display.height() - tbh) / 2) - tby;
|
uint16_t y = ((display.height() - tbh) / 2) - tby;
|
||||||
display.setFullWindow();
|
display.setFullWindow();
|
||||||
@@ -83,7 +95,7 @@ void DisplayShowerthought() {
|
|||||||
display.fillScreen(GxEPD_WHITE);
|
display.fillScreen(GxEPD_WHITE);
|
||||||
display.drawBitmap(130, 90, logo, 125, 125, GxEPD_BLACK);
|
display.drawBitmap(130, 90, logo, 125, 125, GxEPD_BLACK);
|
||||||
display.setCursor(x, y);
|
display.setCursor(x, y);
|
||||||
display.print(GreeterText);
|
display.print(TitleText);
|
||||||
display.drawRect(x-16, y-20, tbw+32, tbh+18, GxEPD_BLACK);
|
display.drawRect(x-16, y-20, tbw+32, tbh+18, GxEPD_BLACK);
|
||||||
display.setCursor(0, 450);
|
display.setCursor(0, 450);
|
||||||
display.print(Thought);
|
display.print(Thought);
|
||||||
|
|||||||
Reference in New Issue
Block a user