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
@@ -53,6 +53,12 @@ public:
|
||||
snprintf(s, sizeof(s), "clock %02d:%02d", hour, minute);
|
||||
shown.push_back(s);
|
||||
}
|
||||
void noWifi(int hour, int minute) override
|
||||
{
|
||||
char s[16];
|
||||
snprintf(s, sizeof(s), "nowifi %02d:%02d", hour, minute);
|
||||
shown.push_back(s);
|
||||
}
|
||||
void logo() override { shown.push_back("logo"); }
|
||||
void blank() override { shown.push_back("blank"); }
|
||||
|
||||
@@ -63,6 +69,7 @@ static FakePower power;
|
||||
static FakeFrames frames;
|
||||
static DisplayController *controller;
|
||||
static uint32_t now;
|
||||
static bool wifi;
|
||||
|
||||
void setUp()
|
||||
{
|
||||
@@ -71,6 +78,7 @@ void setUp()
|
||||
delete controller;
|
||||
controller = new DisplayController(power, frames);
|
||||
now = 1000;
|
||||
wifi = true;
|
||||
}
|
||||
|
||||
void tearDown() {}
|
||||
@@ -81,7 +89,7 @@ static void run(int hour, int minute, uint32_t ms = 0)
|
||||
uint32_t end = now + ms;
|
||||
do
|
||||
{
|
||||
controller->update(now, true, hour, minute);
|
||||
controller->update(now, true, hour, minute, wifi);
|
||||
now += 100;
|
||||
} while ((int32_t)(end - now) >= 0);
|
||||
}
|
||||
@@ -285,7 +293,12 @@ void test_recovery_never_starts_missing_clock_firmware()
|
||||
void test_every_recovery_reason_has_a_text()
|
||||
{
|
||||
for (uint8_t r = 0; r <= (uint8_t)RecoveryReason::PowerCycle; r++)
|
||||
{
|
||||
TEST_ASSERT_TRUE(strlen(recoveryReasonText((RecoveryReason)r)) > 0);
|
||||
// fits on one line of the display
|
||||
TEST_ASSERT_TRUE(strlen(recoveryReasonShort((RecoveryReason)r)) > 0);
|
||||
TEST_ASSERT_TRUE(strlen(recoveryReasonShort((RecoveryReason)r)) <= 14);
|
||||
}
|
||||
TEST_ASSERT_TRUE(strcmp(recoveryReasonText(RecoveryReason::Wifi),
|
||||
recoveryReasonText(RecoveryReason::Crash)) != 0);
|
||||
}
|
||||
@@ -318,7 +331,7 @@ void test_led_blinks_slow_with_wifi_and_fast_without()
|
||||
void test_nothing_happens_until_time_is_synced()
|
||||
{
|
||||
power.is_on = true; // showing "Connecting..."
|
||||
controller->update(now, false, 0, 0);
|
||||
controller->update(now, false, 0, 0, true);
|
||||
TEST_ASSERT_EQUAL(0, power.off_count);
|
||||
TEST_ASSERT_EQUAL(0, (int)frames.shown.size());
|
||||
}
|
||||
@@ -452,6 +465,56 @@ void test_redraws_after_power_was_switched_off_elsewhere()
|
||||
TEST_ASSERT_EQUAL_STRING("clock 12:00", frames.last().c_str());
|
||||
}
|
||||
|
||||
void test_no_wifi_is_shown_after_a_minute_without_wifi()
|
||||
{
|
||||
run(12, 0);
|
||||
wifi = false;
|
||||
run(12, 0, NO_WIFI_SHOW_TIME - 200);
|
||||
TEST_ASSERT_EQUAL_STRING("clock 12:00", frames.last().c_str());
|
||||
run(12, 1, 300);
|
||||
TEST_ASSERT_EQUAL_STRING("nowifi 12:01", frames.last().c_str());
|
||||
TEST_ASSERT_TRUE(power.is_on);
|
||||
}
|
||||
|
||||
void test_no_wifi_screen_keeps_the_time_running()
|
||||
{
|
||||
wifi = false;
|
||||
run(12, 0, NO_WIFI_SHOW_TIME + 100);
|
||||
run(12, 1);
|
||||
TEST_ASSERT_EQUAL_STRING("nowifi 12:01", frames.last().c_str());
|
||||
int frames_before = (int)frames.shown.size();
|
||||
run(12, 1, 5000);
|
||||
TEST_ASSERT_EQUAL(frames_before, (int)frames.shown.size()); // only on change
|
||||
}
|
||||
|
||||
void test_clock_returns_when_wifi_is_back()
|
||||
{
|
||||
wifi = false;
|
||||
run(12, 0, NO_WIFI_SHOW_TIME + 100);
|
||||
wifi = true;
|
||||
run(12, 0);
|
||||
TEST_ASSERT_EQUAL_STRING("clock 12:00", frames.last().c_str());
|
||||
}
|
||||
|
||||
void test_short_wifi_drop_does_not_change_the_display()
|
||||
{
|
||||
run(12, 0);
|
||||
wifi = false;
|
||||
run(12, 0, 10000);
|
||||
wifi = true;
|
||||
run(12, 0, NO_WIFI_SHOW_TIME);
|
||||
TEST_ASSERT_EQUAL(1, (int)frames.shown.size());
|
||||
}
|
||||
|
||||
void test_night_without_wifi_still_powers_off()
|
||||
{
|
||||
run(23, 30);
|
||||
wifi = false;
|
||||
run(23, 31, POWER_OFF_DELAY + 200);
|
||||
TEST_ASSERT_FALSE(power.is_on);
|
||||
TEST_ASSERT_EQUAL_STRING("blank", frames.last().c_str());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
@@ -501,6 +564,11 @@ int main()
|
||||
RUN_TEST(test_clock_switch_off_never_powers_on);
|
||||
RUN_TEST(test_clock_switch_on_again_shows_clock);
|
||||
RUN_TEST(test_redraws_after_power_was_switched_off_elsewhere);
|
||||
RUN_TEST(test_no_wifi_is_shown_after_a_minute_without_wifi);
|
||||
RUN_TEST(test_no_wifi_screen_keeps_the_time_running);
|
||||
RUN_TEST(test_clock_returns_when_wifi_is_back);
|
||||
RUN_TEST(test_short_wifi_drop_does_not_change_the_display);
|
||||
RUN_TEST(test_night_without_wifi_still_powers_off);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Reference in new issue
Block a user