解耦test,example,重构effect为C(解决 #4 #6)

This commit is contained in:
2023-11-25 16:36:04 +08:00
parent 5024b92298
commit 1d8c7663f1
20 changed files with 242 additions and 217 deletions

View File

@@ -0,0 +1,25 @@
#include <stdint.h>
#include <stdio.h> // 包含基本的输入输出函数
#include "rgb_effect.h"
#include "timer.h"
void hsv_cycle_example()
{
uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区大小由NUM_RGBS宏确定
uint32_t current_hue = 0; // 从红色开始的当前色相值
uint32_t current_sat = 100; // 当前饱和度值,初始化为满饱和度
uint32_t current_val = 100; // 当前亮度值,初始化为最大亮度
uint32_t current_color = HSV_to_RGB(&current_hue, &current_sat, &current_val);
while (1)
{
// 用当前渐变颜色填充RGB数组然后发送给rgb阵列
fill_gradient(buf, NUM_RGBS, current_color);
// 延迟以控制显示持续时间
delay_milliseconds(DELAY_TIME_RGB);
// 更改下一个颜色
current_color = cycleHSV(&current_hue);
// 打印出当前的GRB颜色值
// printf("GRB color is: 0x%06X\n", current_color);
}
}

View File

@@ -1,14 +1,24 @@
/** @brief RGB循环呼吸
*
* 驱动HSV颜色空间中的颜色循环以实现连续的颜色渐变效果。
*
* 此函数初始化颜色值并进入一个无限循环不断地计算新的颜色值并更新LED阵列。
* 使用并发执行关键字 'par' 来实现循环内部的并行处理。这个函数假定运行环境支持并行关键字 'par'。
*
* 在此循环中,它首先使用当前颜色填充一个预定义大小的缓冲区,然后调用 `cycleHSV` 函数
* 来更新当前色相值并获取新的颜色。最后它打印出当前的GRB颜色值。
* @author Vergil Wong
* @date 2023-11-11
* @date 2023-11-25
* @param
* @return
*/
#include "stdint.h"
#include <stdio.h> // 包含基本的输入输出函数
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
#include "rgb_effect.h"
extern "C"
{
void hsv_cycle_example();
}
int main() // 定义主函数
{
@@ -16,7 +26,7 @@ int main() // 定义主函数
{
on tile[1]:
{
cycleHSV_driver();
hsv_cycle_example();
}
}
return 0; // 返回0表示程序正常结束