From 8736beb673823dec82431a781134f6a573d60cd1 Mon Sep 17 00:00:00 2001 From: Vergil_Wong Date: Sat, 25 Nov 2023 22:50:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=AE=9A=E4=B9=89=EF=BC=8C=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE=E6=9B=B4=E6=94=B9=E7=81=AF?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test_fill_gradient_with_groups.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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) {