Only redraw spinner while waiting for connection

This commit is contained in:
Paul Brinkmeier 2025-04-27 15:30:24 +02:00
parent f8fe64b1b3
commit 1c1aad5846

View File

@ -42,9 +42,9 @@
#define CLOCK_X MARGIN_LEFT #define CLOCK_X MARGIN_LEFT
#define CLOCK_Y 113 #define CLOCK_Y 113
#define STATUS_X 95 #define STATUS_X 83
#define STATUS_Y CLOCK_Y #define STATUS_Y CLOCK_Y
#define STATUS_WIDTH (10 * CX) #define STATUS_WIDTH (12 * CX)
#define STATUS_HEIGHT CY #define STATUS_HEIGHT CY
// Function definitions // Function definitions
@ -104,14 +104,18 @@ void setState(Args&&... args) {
void StateConnecting::enter() { void StateConnecting::enter() {
Serial.println("Entering StateConnecting"); Serial.println("Entering StateConnecting");
display.fillRect(STATUS_X, STATUS_Y, STATUS_WIDTH, STATUS_HEIGHT, COLOR_BG);
display.setCursor(STATUS_X, STATUS_Y);
display.printf("connecting");
} }
void StateConnecting::tick() { void StateConnecting::tick() {
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
display.fillRect(STATUS_X, STATUS_Y, STATUS_WIDTH, STATUS_HEIGHT, COLOR_BG); display.fillRect(STATUS_X + 11 * CX, STATUS_Y, CX, CY, COLOR_BG);
display.setCursor(STATUS_X, STATUS_Y); display.setCursor(STATUS_X + 11 * CX, STATUS_Y);
display.printf(" connect %c", "|/-\\"[currentTick % 4]); display.print("|/-\\"[currentTick % 4]);
delay(250); delay(125);
return; return;
} }
@ -119,7 +123,7 @@ void StateConnecting::tick() {
} }
// Fetching is a bit of an ugly duckling; it performs all its logic in enter(). // Fetching is a bit of an ugly duckling; it performs all its logic in enter().
// This is because request it does is synchronous. // This is because the request it does is synchronous.
// Sadly this means no animation is possible right now. // Sadly this means no animation is possible right now.
// At least the fetch call still does yield() under the hood :) // At least the fetch call still does yield() under the hood :)
void StateFetching::enter() { void StateFetching::enter() {
@ -132,7 +136,7 @@ void StateFetching::enter() {
display.fillRect(STATUS_X, STATUS_Y, STATUS_WIDTH, STATUS_HEIGHT, COLOR_BG); display.fillRect(STATUS_X, STATUS_Y, STATUS_WIDTH, STATUS_HEIGHT, COLOR_BG);
display.setCursor(STATUS_X, STATUS_Y); display.setCursor(STATUS_X, STATUS_Y);
display.print(" fetching"); display.print(" fetching");
String departuresRaw = fetchDepartures(); String departuresRaw = fetchDepartures();