Public Access
Random refresh effect: choose which effects it picks from
The list is a new setting (hardware settings, also used by pages set to Random); an empty list is refused. The ESP32 picks an effect per frame and sends that, so the Nano needs no change. The power-on time after a frame now follows the slowest effect on the list. The settings record goes to version 8. Version 7 is a prefix of it, so it is still read, and becomes version 8 with the next save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8fcb17c395
commit
48e29096c0
12 files changed
+140
-21
No files matched your search
@@ -748,21 +748,75 @@ void test_settings_drive_ranges()
|
||||
void test_effect_time_is_zero_when_instant()
|
||||
{
|
||||
DriveSettings d;
|
||||
TEST_ASSERT_EQUAL(0, (int)effectTime(d)); // default: instant
|
||||
TEST_ASSERT_EQUAL(0, (int)effectTime(d, RANDOM_EFFECTS_ALL)); // default: instant
|
||||
d.effect = 1;
|
||||
d.effect_time = 2500;
|
||||
TEST_ASSERT_EQUAL(2500, (int)effectTime(d));
|
||||
TEST_ASSERT_EQUAL(2500, (int)effectTime(d, RANDOM_EFFECTS_ALL));
|
||||
d.effect = DRIVE_EFFECT_PUSH; // can take much longer
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_PUSH_EXTRA_TIME, (int)effectTime(d));
|
||||
d.effect = DRIVE_EFFECT_RANDOM; // can be a push
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_PUSH_EXTRA_TIME, (int)effectTime(d));
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_PUSH_EXTRA_TIME, (int)effectTime(d, 0x2));
|
||||
d.effect = DRIVE_EFFECT_MATRIX; // flips most dots of a changed column twice
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_MATRIX_EXTRA_TIME, (int)effectTime(d));
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_MATRIX_EXTRA_TIME, (int)effectTime(d, 0x2));
|
||||
Settings s;
|
||||
s.drive.effect = DRIVE_EFFECT_MATRIX;
|
||||
TEST_ASSERT_NULL(validateSettings(s));
|
||||
}
|
||||
|
||||
void test_effect_time_of_random_is_the_slowest_on_its_list()
|
||||
{
|
||||
DriveSettings d;
|
||||
d.effect = DRIVE_EFFECT_RANDOM;
|
||||
d.effect_time = 2500;
|
||||
const uint16_t push = 1 << DRIVE_EFFECT_PUSH, matrix = 1 << DRIVE_EFFECT_MATRIX, sparkle = 1 << 1;
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_PUSH_EXTRA_TIME, (int)effectTime(d, RANDOM_EFFECTS_ALL));
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_PUSH_EXTRA_TIME, (int)effectTime(d, push | sparkle));
|
||||
TEST_ASSERT_EQUAL(2500 + (int)DRIVE_MATRIX_EXTRA_TIME, (int)effectTime(d, matrix | sparkle));
|
||||
TEST_ASSERT_EQUAL(2500, (int)effectTime(d, sparkle));
|
||||
}
|
||||
|
||||
void test_random_effects_list_is_validated()
|
||||
{
|
||||
Settings s;
|
||||
TEST_ASSERT_EQUAL_HEX16(RANDOM_EFFECTS_ALL, s.random_effects); // default: everything
|
||||
TEST_ASSERT_NULL(validateSettings(s));
|
||||
s.random_effects = 1 << DRIVE_EFFECT_MATRIX;
|
||||
TEST_ASSERT_NULL(validateSettings(s));
|
||||
s.random_effects = 0; // nothing to pick from
|
||||
TEST_ASSERT_NOT_NULL(validateSettings(s));
|
||||
s.random_effects = 1 << DRIVE_EFFECT_INSTANT;
|
||||
TEST_ASSERT_NOT_NULL(validateSettings(s));
|
||||
s.random_effects = 1 << DRIVE_EFFECT_RANDOM; // would pick itself
|
||||
TEST_ASSERT_NOT_NULL(validateSettings(s));
|
||||
s.random_effects = 1 << DRIVE_EFFECT_COUNT;
|
||||
TEST_ASSERT_NOT_NULL(validateSettings(s));
|
||||
}
|
||||
|
||||
void test_random_picks_only_from_its_list_and_all_of_it()
|
||||
{
|
||||
// Each list of 2 or 3 of the effects, and the whole list
|
||||
const uint16_t lists[] = {RANDOM_EFFECTS_ALL, 1 << 3, (1 << 3) | (1 << DRIVE_EFFECT_MATRIX),
|
||||
(1 << 1) | (1 << 5) | (1 << DRIVE_EFFECT_PUSH)};
|
||||
for (uint16_t list : lists)
|
||||
{
|
||||
int seen[DRIVE_EFFECT_COUNT] = {};
|
||||
for (uint32_t r = 0; r < 990; r++)
|
||||
seen[pickRandomEffect(list, r * 2654435761u)]++;
|
||||
for (int effect = 0; effect < DRIVE_EFFECT_COUNT; effect++)
|
||||
{
|
||||
if (list & (1 << effect))
|
||||
{
|
||||
TEST_ASSERT_GREATER_THAN(50, seen[effect]);
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_ASSERT_EQUAL(0, seen[effect]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The first on the list: what the Nano stores
|
||||
TEST_ASSERT_EQUAL(DRIVE_EFFECT_MATRIX, pickRandomEffect(1 << DRIVE_EFFECT_MATRIX, 0));
|
||||
TEST_ASSERT_EQUAL(3, pickRandomEffect((1 << 3) | (1 << DRIVE_EFFECT_MATRIX), 0));
|
||||
}
|
||||
|
||||
void test_settings_off_page_blank_or_bitmap_name()
|
||||
{
|
||||
Settings s;
|
||||
@@ -3380,6 +3434,9 @@ int main()
|
||||
RUN_TEST(test_settings_slow_mode_interval);
|
||||
RUN_TEST(test_settings_drive_ranges);
|
||||
RUN_TEST(test_effect_time_is_zero_when_instant);
|
||||
RUN_TEST(test_effect_time_of_random_is_the_slowest_on_its_list);
|
||||
RUN_TEST(test_random_effects_list_is_validated);
|
||||
RUN_TEST(test_random_picks_only_from_its_list_and_all_of_it);
|
||||
RUN_TEST(test_settings_off_page_blank_or_bitmap_name);
|
||||
RUN_TEST(test_changed_off_image_is_redrawn_while_the_display_is_on);
|
||||
RUN_TEST(test_settings_flip_time_and_port_ranges);
|
||||
|
||||
Reference in new issue
Block a user