Public Access
Show status messages on the display
- Clock firmware: 'Connecting to WiFi...' and 'Getting the time...' at boot, 'Crashed!' in the OTA-only modes, and 'No WiFi' with the time when WiFi is down for over a minute (new DisplayController screen) - Recovery app: shows its reason, the setup WiFi name, or its IP address, then powers the display off (flipdots keep the image) - StatusScreen and drawTextLines shared by both apps - Driver: ESP begin() no longer draws 'ESP Connected' - Tests: No WiFi screen, short reason texts (70 total) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4749f9e596
commit
c9e0800e36
19 files changed
+332
-48
No files matched your search
@@ -54,6 +54,24 @@ const char *recoveryReasonText(RecoveryReason reason)
|
||||
}
|
||||
}
|
||||
|
||||
const char *recoveryReasonShort(RecoveryReason reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case RecoveryReason::Wifi:
|
||||
return "no WiFi";
|
||||
case RecoveryReason::Crash:
|
||||
return "crashed";
|
||||
case RecoveryReason::Manual:
|
||||
return "requested";
|
||||
case RecoveryReason::PowerCycle:
|
||||
return "power cycled";
|
||||
case RecoveryReason::None:
|
||||
default:
|
||||
return "no firmware";
|
||||
}
|
||||
}
|
||||
|
||||
bool powerCyclesRequestRecovery(uint8_t power_on_count)
|
||||
{
|
||||
return power_on_count >= POWER_CYCLES_FOR_RECOVERY;
|
||||
|
||||
@@ -59,6 +59,8 @@ enum class RecoveryReason : uint8_t
|
||||
};
|
||||
|
||||
const char *recoveryReasonText(RecoveryReason reason);
|
||||
// At most 14 characters, for the flipdot display
|
||||
const char *recoveryReasonShort(RecoveryReason reason);
|
||||
|
||||
// Power-on count: each power on within POWER_CYCLE_WINDOW of the previous one counts.
|
||||
// True when the next start should be the recovery app.
|
||||
|
||||
@@ -27,8 +27,17 @@ bool DisplayController::powerEnabled() const
|
||||
return _power_enabled;
|
||||
}
|
||||
|
||||
void DisplayController::update(uint32_t now, bool time_valid, int hour, int minute)
|
||||
void DisplayController::update(uint32_t now, bool time_valid, int hour, int minute, bool wifi_connected)
|
||||
{
|
||||
if (wifi_connected)
|
||||
_wifi_lost = false;
|
||||
else if (!_wifi_lost)
|
||||
{
|
||||
_wifi_lost = true;
|
||||
_wifi_lost_since = now;
|
||||
}
|
||||
bool show_no_wifi = _wifi_lost && now - _wifi_lost_since >= NO_WIFI_SHOW_TIME;
|
||||
|
||||
// Switched off elsewhere (power timer, Nano flashing): the Nano lost its frame
|
||||
if (!_power.isOn())
|
||||
_screen = Screen::Unknown;
|
||||
@@ -81,7 +90,7 @@ void DisplayController::update(uint32_t now, bool time_valid, int hour, int minu
|
||||
_power.on();
|
||||
_screen = Screen::Unknown;
|
||||
}
|
||||
_showClock(hour, minute);
|
||||
_showClock(hour, minute, show_no_wifi);
|
||||
break;
|
||||
case ScheduleMode::Standby:
|
||||
// Flipdots keep their image without power, so the last time stays visible
|
||||
@@ -91,12 +100,16 @@ void DisplayController::update(uint32_t now, bool time_valid, int hour, int minu
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayController::_showClock(int hour, int minute)
|
||||
void DisplayController::_showClock(int hour, int minute, bool no_wifi)
|
||||
{
|
||||
if (_screen == Screen::Clock && _shown_hour == hour && _shown_minute == minute)
|
||||
Screen screen = no_wifi ? Screen::NoWifi : Screen::Clock;
|
||||
if (_screen == screen && _shown_hour == hour && _shown_minute == minute)
|
||||
return;
|
||||
_frames.clock(hour, minute);
|
||||
_screen = Screen::Clock;
|
||||
if (no_wifi)
|
||||
_frames.noWifi(hour, minute);
|
||||
else
|
||||
_frames.clock(hour, minute);
|
||||
_screen = screen;
|
||||
_shown_hour = hour;
|
||||
_shown_minute = minute;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ class Frames
|
||||
{
|
||||
public:
|
||||
virtual void clock(int hour, int minute) = 0;
|
||||
// Shown instead of the clock while WiFi is down (the time keeps running without it)
|
||||
virtual void noWifi(int hour, int minute) = 0;
|
||||
virtual void logo() = 0;
|
||||
virtual void blank() = 0;
|
||||
};
|
||||
@@ -40,13 +42,15 @@ public:
|
||||
bool powerEnabled() const;
|
||||
|
||||
// Call often (every loop). time_valid is false until the time is synced over NTP.
|
||||
void update(uint32_t now, bool time_valid, int hour, int minute);
|
||||
// While WiFi is down for NO_WIFI_SHOW_TIME, "No WiFi" is shown instead of the clock.
|
||||
void update(uint32_t now, bool time_valid, int hour, int minute, bool wifi_connected);
|
||||
|
||||
private:
|
||||
enum class Screen
|
||||
{
|
||||
Unknown, // nothing sent since the last power on
|
||||
Clock,
|
||||
NoWifi,
|
||||
Logo,
|
||||
Blank,
|
||||
};
|
||||
@@ -62,7 +66,10 @@ private:
|
||||
int _shown_hour = -1;
|
||||
int _shown_minute = -1;
|
||||
|
||||
void _showClock(int hour, int minute);
|
||||
bool _wifi_lost = false;
|
||||
uint32_t _wifi_lost_since = 0;
|
||||
|
||||
void _showClock(int hour, int minute, bool no_wifi);
|
||||
void _showLogo();
|
||||
void _showBlank();
|
||||
};
|
||||
Reference in new issue
Block a user