From 7b33d5a45e0f5f75412b13799593ecb39c917dd2 Mon Sep 17 00:00:00 2001 From: Vergil_Wong Date: Sun, 26 Nov 2023 00:25:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app_test_HSV_to_RGB/src/test_hsv_to_rgb.c | 3 ++- .../src/main.xc | 4 +-- .../src/test_fill_gradient_with_groups.c | 26 ++----------------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/examples/app_test_HSV_to_RGB/src/test_hsv_to_rgb.c b/examples/app_test_HSV_to_RGB/src/test_hsv_to_rgb.c index d997cac..e0d9349 100644 --- a/examples/app_test_HSV_to_RGB/src/test_hsv_to_rgb.c +++ b/examples/app_test_HSV_to_RGB/src/test_hsv_to_rgb.c @@ -1,4 +1,5 @@ #include +#include #include "rgb_effect.h" void test_hsv_to_rgb() { @@ -12,5 +13,5 @@ void test_hsv_to_rgb() color = HSV_to_RGB(&hue, &sat, &value); - printf("GRB color is: 0x%06X\n", color); + printf("GRB color is: 0x%06lX\n", color); } \ No newline at end of file diff --git a/examples/app_test_fill_gradient_with_groups/src/main.xc b/examples/app_test_fill_gradient_with_groups/src/main.xc index d9d76bf..7312d9a 100644 --- a/examples/app_test_fill_gradient_with_groups/src/main.xc +++ b/examples/app_test_fill_gradient_with_groups/src/main.xc @@ -1,8 +1,6 @@ /** @brief 测试 fill_gradient_with_groups 函数 * 此测试函数创建一个缓冲区,并定义两种颜色和每组的填充数量,然后调用 - * fill_gradient_with_groups 函数来填充缓冲区。之后,它会验证缓冲区中的颜色 - * 是否符合预期:每组的前N个LED应该是指定的颜色,剩余的LED应该是关闭的(黑色)。 - * 如果所有LED的颜色都正确,测试通过;否则,输出错误信息并标记测试失败。 + * fill_gradient_with_groups 函数来填充缓冲区,并渲染RGB。 * @author Vergil Wong * @date 2023-11-25 * @param 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 7483f8c..506ec16 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 @@ -1,36 +1,14 @@ #include #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, 0x0000FF}; // 红,绿,蓝 + uint32_t colors[] = {0x110000, 0x001100, 0x000011}; // 红,绿,蓝 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); - // 延迟以控制显示持续时间 - delay_milliseconds(DELAY_TIME_RGB); - // 验证 - for (size_t i = 0; i < NUM_RGBS; i++) - { - 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) - { - success = 0; // 设置为false - printf("Test failed at LED %zu: expected 0x%06lX, got 0x%06lX\n", i, expected_color, buffer[i]); - break; - } - } - - if (success) - { - printf("Test passed: All LEDs are correctly set.\n"); - } } \ No newline at end of file