forked from PAWPAW/lib_rgb
修复:使用xs3_memcpy以增加数组复制速度
- 注意,需要使用最新的xmath版本
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user