Public Access
Matrix refresh effect, and Random really picks from all effects
Yellow streaks fall down the columns that changed, at random moments, and leave the new image behind them. The start ticks come from a hash, so the only new RAM is one bit per column. Only a dot's final flip gets all pulses. Random took micros() % 8, but micros() only gives multiples of 4 on the Nano, so it could only pick sparkle or diagonal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35e678d78d
commit
8fcb17c395
13 files changed
+345
-19
No files matched your search
@@ -124,6 +124,147 @@ void test_effects_end_with_the_right_image()
|
||||
}
|
||||
}
|
||||
|
||||
// Stricter than assertPanelShows(): shownPixel() would also agree with a leftover streak
|
||||
static void assertPanelHasPattern(int seed)
|
||||
{
|
||||
for (int x = 0; x < W; x++)
|
||||
for (int y = 0; y < H; y++)
|
||||
if (panel.dot[x][y] != (((x * 7 + y * 3 + seed) % 5) == 0))
|
||||
{
|
||||
char msg[64];
|
||||
snprintf(msg, sizeof(msg), "dot %d,%d is wrong", x, y);
|
||||
TEST_FAIL_MESSAGE(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void test_matrix_ends_with_the_right_image_and_reaches_every_dot_after_boot()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
d->setEffect(EFFECT_MATRIX, 500);
|
||||
drawPattern(*d, 0);
|
||||
d->display();
|
||||
finish(*d);
|
||||
TEST_ASSERT_EQUAL(W * H, dotsFlippedAtLeast(1));
|
||||
assertPanelHasPattern(0);
|
||||
drawPattern(*d, 2);
|
||||
d->display();
|
||||
finish(*d);
|
||||
assertPanelHasPattern(2);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void test_matrix_flips_only_changed_columns_with_the_right_pulses()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
d->setEffect(EFFECT_MATRIX, 500);
|
||||
d->fillScreen(0);
|
||||
d->drawPixel(40, 3, 1); // stays yellow
|
||||
d->drawPixel(40, 9, 1); // yellow to black
|
||||
d->display();
|
||||
finish(*d);
|
||||
panel.clearCounts();
|
||||
|
||||
d->drawPixel(40, 9, 0);
|
||||
d->drawPixel(40, 12, 1); // black to yellow
|
||||
d->display();
|
||||
finish(*d);
|
||||
for (int x = 0; x < W; x++)
|
||||
for (int y = 0; y < H; y++)
|
||||
{
|
||||
int expected = x != 40 ? 0 : y == 3 ? 0 : y == 9 ? 3 : y == 12 ? 3 : 1 + 3;
|
||||
if (panel.flips[x][y] != expected)
|
||||
{
|
||||
char msg[64];
|
||||
snprintf(msg, sizeof(msg), "dot %d,%d: %d pulses, not %d", x, y, panel.flips[x][y], expected);
|
||||
TEST_FAIL_MESSAGE(msg);
|
||||
}
|
||||
}
|
||||
TEST_ASSERT_TRUE(panel.dot[40][3]);
|
||||
TEST_ASSERT_FALSE(panel.dot[40][9]);
|
||||
TEST_ASSERT_TRUE(panel.dot[40][12]);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void test_matrix_streak_falls_from_the_top_and_takes_the_effect_time()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
d->setEffect(EFFECT_MATRIX, 1000);
|
||||
d->fillScreen(0);
|
||||
d->display();
|
||||
finish(*d);
|
||||
|
||||
d->drawPixel(40, 18, 1);
|
||||
uint32_t start = fake_micros;
|
||||
d->display();
|
||||
int highest = -1, longest = 0;
|
||||
while (d->busy())
|
||||
{
|
||||
d->update();
|
||||
int lit = 0, bottom = -1;
|
||||
for (int y = 0; y < H; y++)
|
||||
if (panel.dot[40][y])
|
||||
{
|
||||
lit++;
|
||||
bottom = y;
|
||||
}
|
||||
TEST_ASSERT_LESS_OR_EQUAL(highest + 1, bottom); // one row at a time, never upwards
|
||||
if (bottom > highest)
|
||||
highest = bottom;
|
||||
if (lit > longest)
|
||||
longest = lit;
|
||||
}
|
||||
TEST_ASSERT_EQUAL(H - 1, highest);
|
||||
TEST_ASSERT_EQUAL(MATRIX_STREAK + 1, longest); // the tail goes after the head moved
|
||||
uint32_t took = fake_micros - start;
|
||||
TEST_ASSERT_UINT32_WITHIN(100000, 1000000, took);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void test_matrix_full_screen_change_never_blocks_and_finishes_soon_enough()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
d->setEffect(EFFECT_MATRIX, 1500);
|
||||
drawPattern(*d, 0);
|
||||
d->display();
|
||||
finish(*d);
|
||||
drawPattern(*d, 1);
|
||||
uint32_t start = fake_micros;
|
||||
d->display();
|
||||
finish(*d);
|
||||
assertPanelHasPattern(1);
|
||||
uint32_t took = fake_micros - start;
|
||||
// DRIVE_MATRIX_EXTRA_TIME on the ESP32 keeps the power on for this much longer
|
||||
TEST_ASSERT_LESS_THAN(1500000 + 5000000, took);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void test_matrix_interrupted_by_a_new_frame_leaves_no_streaks()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
d->setEffect(EFFECT_MATRIX, 1000);
|
||||
drawPattern(*d, 0);
|
||||
d->display();
|
||||
finish(*d);
|
||||
drawPattern(*d, 1);
|
||||
d->display();
|
||||
// Until streaks are visible: dots yellow that are in neither image
|
||||
int streak_dots = 0;
|
||||
while (d->busy() && streak_dots < 10)
|
||||
{
|
||||
d->update();
|
||||
streak_dots = 0;
|
||||
for (int x = 0; x < W; x++)
|
||||
for (int y = 0; y < H; y++)
|
||||
streak_dots += panel.dot[x][y] && ((x * 7 + y * 3) % 5) != 0 && ((x * 7 + y * 3 + 1) % 5) != 0;
|
||||
}
|
||||
TEST_ASSERT_TRUE(d->busy());
|
||||
drawPattern(*d, 2);
|
||||
d->display(false, true); // a moving page: instant
|
||||
finish(*d);
|
||||
assertPanelHasPattern(2);
|
||||
delete d;
|
||||
}
|
||||
|
||||
void test_refresh_flips_every_dot_once_without_blocking()
|
||||
{
|
||||
BROSE9323 *d = make();
|
||||
@@ -264,6 +405,11 @@ int main()
|
||||
RUN_TEST(test_first_frame_flips_every_dot_without_blocking);
|
||||
RUN_TEST(test_instant_frame_flips_only_the_changed_dots_with_all_pulses);
|
||||
RUN_TEST(test_effects_end_with_the_right_image);
|
||||
RUN_TEST(test_matrix_ends_with_the_right_image_and_reaches_every_dot_after_boot);
|
||||
RUN_TEST(test_matrix_flips_only_changed_columns_with_the_right_pulses);
|
||||
RUN_TEST(test_matrix_streak_falls_from_the_top_and_takes_the_effect_time);
|
||||
RUN_TEST(test_matrix_full_screen_change_never_blocks_and_finishes_soon_enough);
|
||||
RUN_TEST(test_matrix_interrupted_by_a_new_frame_leaves_no_streaks);
|
||||
RUN_TEST(test_refresh_flips_every_dot_once_without_blocking);
|
||||
RUN_TEST(test_refresh_pauses_while_a_frame_arrives_and_then_finishes);
|
||||
RUN_TEST(test_refresh_waits_for_a_running_effect);
|
||||
|
||||
Reference in new issue
Block a user