diff --git a/examples/app_test_fill_gradient_with_groups/src/test_fill_gradient_with_groups.c b/examples/app_test_fill_gradient_with_groups/src/test_fill_gradient_with_groups.c index 5e13859..7483f8c 100644 --- a/examples/app_test_fill_gradient_with_groups/src/test_fill_gradient_with_groups.c +++ b/examples/app_test_fill_gradient_with_groups/src/test_fill_gradient_with_groups.c @@ -2,15 +2,14 @@ #include // 包含基本的输入输出函数 #include // 包含对封装的定义,引用以使用 on tile[] 语法 #include "samples_to_levels.h" +#define NUM_RGB_GROUPS 3 #include "rgb_effect.h" #include "timer.h" - void test_fill_gradient_with_groups() { uint32_t buffer[NUM_RGBS]; - uint32_t colors[] = {0xFF0000, 0x00FF00}; // 红,绿 - size_t num_filled_rgb[] = {2, 3}; // 每组填充数量 - size_t num_groups = sizeof(colors) / sizeof(colors[0]); + uint32_t colors[] = {0xFF0000, 0x00FF00, 0x0000FF}; // 红,绿,蓝 + size_t num_filled_rgb[] = {4, 4, 4}; // 每组填充数量 int success = 1; // 使用int代替bool,1代表true,0代表false fill_gradient_with_groups(buffer, colors, num_filled_rgb); @@ -19,8 +18,8 @@ void test_fill_gradient_with_groups() // 验证 for (size_t i = 0; i < NUM_RGBS; i++) { - size_t group = i / (NUM_RGBS / num_groups); - size_t group_led_start = group * (NUM_RGBS / num_groups); + size_t group = i / (NUM_RGBS / NUM_RGB_GROUPS); + size_t group_led_start = group * (NUM_RGBS / NUM_RGB_GROUPS); uint32_t expected_color = (i < group_led_start + num_filled_rgb[group]) ? colors[group] : 0x000000; if (buffer[i] != expected_color) {