From 4ccd40bab974b39ee3e0590a535c10b7f2aaa8da Mon Sep 17 00:00:00 2001 From: Vergil Wong Date: Thu, 30 Nov 2023 11:26:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E4=BD=BF=E7=94=A8xs?= =?UTF-8?q?3=5Fmemcpy=E4=BB=A5=E5=A2=9E=E5=8A=A0=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注意,需要使用最新的xmath版本 --- .../src/hsv_cycle_per_rgb_example.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/app_hsv_cycle_per_rgb_example/src/hsv_cycle_per_rgb_example.c b/examples/app_hsv_cycle_per_rgb_example/src/hsv_cycle_per_rgb_example.c index 33d9bc3..4647318 100644 --- a/examples/app_hsv_cycle_per_rgb_example/src/hsv_cycle_per_rgb_example.c +++ b/examples/app_hsv_cycle_per_rgb_example/src/hsv_cycle_per_rgb_example.c @@ -11,8 +11,7 @@ void init_colors(uint32_t *current_colors, uint32_t *previous_colors, uint32_t c { *(current_colors + i) = cycleHSV(¤t_hue); } - // TODO: 当使用xs3_memcpy时,复制的后几个数据看起来是随机的 - memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t)); + xs3_memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t)); } void hsv_cycle_per_rgb_example() @@ -28,7 +27,7 @@ void hsv_cycle_per_rgb_example() for (size_t i = 0; i < NUM_RGB_GROUPS; i++) { - *(levels + i) = (NUM_RGBS / NUM_RGB_GROUPS)-1; + *(levels + i) = (NUM_RGBS / NUM_RGB_GROUPS); } // 用当前渐变颜色填充RGB数组,然后发送给rgb阵列 fill_gradient_with_groups_colorful(buf, current_colors, levels); @@ -36,10 +35,10 @@ void hsv_cycle_per_rgb_example() // 延迟以控制显示持续时间 delay_milliseconds(DELAY_TIME_RGB); // 更改下一组颜色,其中每个灯继承上一个灯的颜色,第一个灯通过cycleHSV计算出新的颜色 - memcpy(current_colors+1, previous_colors, (NUM_RGBS-1) * sizeof(uint32_t)); + xs3_memcpy(current_colors+1, previous_colors, (NUM_RGBS-1) * sizeof(uint32_t)); current_colors[0] = cycleHSV(¤t_hue); // 保留本轮颜色的记录 - memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t)); + xs3_memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t)); } } \ No newline at end of file