Public Access
Fix dense images on the Nano and the off image in slow mode
- Nano: B data is drawn fast enough for the serial line. A hex digit arrives every 87 us; with a division and four drawPixel() calls per digit a lit digit took about 105 us, so dense frames (all yellow, the panda bitmap) overflowed the 64 byte receive buffer: frames not shown or wrong, "Line too long", frame check repairs that failed the same way. Now the parser counts columns and rows and BROSE9323::drawDots() sets the 4 dots (about 20 us). - ESP32: Power off and the start of the night draw the off image also when slow mode had the power off already (it powers on for it, once) - Tests: drawDots() against drawPixel(), off image in slow mode - Version 2.19.3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41af2944bc
commit
7a28e34380
13 files changed
+130
-17
No files matched your search
@@ -27,6 +27,14 @@ public:
|
||||
void begin() { log("begin"); }
|
||||
void display(bool force = false, bool instant = false) { log("display", force, instant); }
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color) { log(direct ? "directPixel" : "pixel", x, y, color); }
|
||||
// Recorded as the pixel calls it stands for (the real one is tested in test_driver)
|
||||
void drawDots(int16_t x, int16_t y, uint8_t bits, bool color)
|
||||
{
|
||||
log("dots", x, y, bits);
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (bits & (8 >> i))
|
||||
drawPixel(x + i, y, color);
|
||||
}
|
||||
void fillScreen(uint16_t color) { log("fill", color); }
|
||||
void setDirect(bool d) { direct = d; }
|
||||
void setTiming(uint16_t t) { log("timing", t); }
|
||||
|
||||
@@ -226,6 +226,38 @@ void test_crc_of_equal_images_is_equal()
|
||||
delete b;
|
||||
}
|
||||
|
||||
// The fast path for B data must give the same image as drawPixel(), also at the right edge
|
||||
// (B widths are rounded up to 4, so x + 3 can be past it) and below the last row
|
||||
void test_draw_dots_is_like_draw_pixel()
|
||||
{
|
||||
BROSE9323 *a = make(), *b = make();
|
||||
a->fillScreen(1);
|
||||
b->fillScreen(1);
|
||||
for (int y = 0; y <= H; y++)
|
||||
for (int x = 0; x < W; x += 4)
|
||||
{
|
||||
uint8_t bits = (x * 5 + y * 3) & 0xF;
|
||||
bool color = (x / 4 + y) % 3 == 0;
|
||||
a->drawDots(x + 2, y, bits, color);
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (bits & (8 >> i))
|
||||
b->drawPixel(x + 2 + i, y, color);
|
||||
}
|
||||
TEST_ASSERT_EQUAL_HEX16(b->crc(), a->crc());
|
||||
for (int x = 0; x < W; x++)
|
||||
for (int y = 0; y < H; y++)
|
||||
{
|
||||
a->drawPixel(x, y, 0);
|
||||
b->drawPixel(x, y, 0);
|
||||
}
|
||||
a->drawDots(-2, 0, 0xF, 1); // dots 0 and 1 of the first row
|
||||
b->drawPixel(0, 0, 1);
|
||||
b->drawPixel(1, 0, 1);
|
||||
TEST_ASSERT_EQUAL_HEX16(b->crc(), a->crc());
|
||||
delete a;
|
||||
delete b;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
@@ -237,5 +269,6 @@ int main()
|
||||
RUN_TEST(test_refresh_waits_for_a_running_effect);
|
||||
RUN_TEST(test_interrupted_first_frame_still_reaches_every_dot);
|
||||
RUN_TEST(test_crc_of_equal_images_is_equal);
|
||||
RUN_TEST(test_draw_dots_is_like_draw_pixel);
|
||||
return UNITY_END();
|
||||
}
|
||||
@@ -583,6 +583,38 @@ void test_power_switch_off_keeps_display_off_during_the_day()
|
||||
TEST_ASSERT_EQUAL(0, power.on_count);
|
||||
}
|
||||
|
||||
// Slow mode had the power off already: the dots still show the clock, so the power goes on
|
||||
// for the off image, once
|
||||
void test_power_switch_off_in_slow_mode_draws_the_off_image()
|
||||
{
|
||||
slowMode(true);
|
||||
run(12, 0, POWER_OFF_DELAY + 200);
|
||||
TEST_ASSERT_FALSE(power.is_on);
|
||||
controller->setPowerEnabled(false);
|
||||
run(12, 1);
|
||||
TEST_ASSERT_TRUE(power.is_on);
|
||||
TEST_ASSERT_EQUAL_STRING("off", frames.last().c_str());
|
||||
run(12, 1, CLEAR_BEFORE_OFF_TIME + 200);
|
||||
TEST_ASSERT_FALSE(power.is_on);
|
||||
run(12, 2, 60000);
|
||||
TEST_ASSERT_EQUAL(2, power.on_count);
|
||||
TEST_ASSERT_EQUAL(2, (int)frames.shown.size());
|
||||
}
|
||||
|
||||
void test_night_in_slow_mode_draws_the_off_image()
|
||||
{
|
||||
slowMode(true);
|
||||
run(23, 15, POWER_OFF_DELAY + 200);
|
||||
TEST_ASSERT_FALSE(power.is_on);
|
||||
run(23, 31);
|
||||
TEST_ASSERT_TRUE(power.is_on);
|
||||
TEST_ASSERT_EQUAL_STRING("off", frames.last().c_str());
|
||||
run(23, 31, POWER_OFF_DELAY + 200);
|
||||
TEST_ASSERT_FALSE(power.is_on);
|
||||
run(3, 0, 60000);
|
||||
TEST_ASSERT_EQUAL(2, power.on_count);
|
||||
}
|
||||
|
||||
void test_power_switch_on_again_shows_clock()
|
||||
{
|
||||
run(12, 0);
|
||||
@@ -3270,6 +3302,8 @@ int main()
|
||||
RUN_TEST(test_power_switch_off_clears_and_powers_off_quickly);
|
||||
RUN_TEST(test_power_switch_off_waits_for_the_refresh_effect);
|
||||
RUN_TEST(test_power_switch_off_keeps_display_off_during_the_day);
|
||||
RUN_TEST(test_power_switch_off_in_slow_mode_draws_the_off_image);
|
||||
RUN_TEST(test_night_in_slow_mode_draws_the_off_image);
|
||||
RUN_TEST(test_power_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);
|
||||
|
||||
Reference in new issue
Block a user