HUE的步进值现在是一个可调整的参数

This commit is contained in:
2023-11-26 15:09:17 +08:00
parent 35c884be29
commit 47a202691b
2 changed files with 35 additions and 1 deletions

View File

@@ -53,6 +53,10 @@
#define DELAY_TIME_RGB (1000 / RGB_MAX)
#endif
// 控制cycleHSV中HUE递增的步进值该步进值应能整除360且不超过它
#ifndef HUE_STEP
#define HUE_STEP (1)
#endif
/**
* 定义渐变方向的枚举类型。
*
@@ -161,4 +165,5 @@ void fill_gradient(uint32_t *buf, uint32_t color, size_t num_filled_rgb);
*/
void fill_gradient_with_groups(uint32_t *buf, uint32_t *colors, size_t *num_filled_rgb);
void fill_gradient_with_groups_colorful(uint32_t *buf, uint32_t *colors, size_t *num_filled_rgb);
#endif //RGB_EFFECT_H

View File

@@ -133,7 +133,7 @@ uint32_t cycleHSV(uint32_t *hue)
uint32_t value = 100;
if (*hue < 359)
{
(*hue) += 1;
(*hue) += HUE_STEP;
// printf("hue is: 0x%06X\n", *hue);
}
else
@@ -195,3 +195,32 @@ void fill_gradient_with_groups(uint32_t *buf, uint32_t *colors, size_t *num_fill
output_rgb_array(buf, NUM_RGBS);
}
// 将多种颜色按RGB的数量分组填充到RGB条中
void fill_gradient_with_groups_colorful(uint32_t *buf, uint32_t *colors, size_t *num_filled_rgb)
{
size_t max_leds_per_group = NUM_RGBS / NUM_RGB_GROUPS;
for (size_t group = 0; group < NUM_RGB_GROUPS; group++)
{
// 填充每个组的RGB其中每个RGB的颜色是独立赋值的
uint32_t *group_buf = buf + group * max_leds_per_group;
for (size_t i = 0; i < num_filled_rgb[group]; i++)
{
*(group_buf + i) = colors[i + group * max_leds_per_group];
}
// 熄灭该组剩余的RGB
for (size_t i = num_filled_rgb[group]; i < max_leds_per_group; i++)
{
*(group_buf + i) = 0x000000;
}
// 如果组号为奇数翻转该组对应的buffer元素
if (group % 2 != 0)
{
reverse_buf(group_buf, max_leds_per_group);
}
}
// 将缓冲区输出到RGB条
output_rgb_array(buf, NUM_RGBS);
}