Merge branch 'main' of Vergil_Wong/lib_rgb into main

This commit is contained in:
2023-11-27 09:48:07 +08:00
committed by Gogs
42 changed files with 732 additions and 136 deletions

View File

@@ -1,58 +1,75 @@
# RGB灯条驱动库
![_453de8b7-7edc-4efc-94c3-809a46000e66](https://img.pawpaw.cn:4430/assets/1699707514504RmN8t1mh.jpeg)
<img src="https://img.pawpaw.cn:4430/assets/1699707514504RmN8t1mh.jpeg" alt="_453de8b7-7edc-4efc-94c3-809a46000e66" style="zoom:50%;" />
## 简介
`lib_rgb` 是一个用于控制RGB灯条的C语言库提供了一系列功能比如颜色渐变、呼吸灯效果和色调循环等。它支持通过RGB和HSV颜色空间来控制灯条的颜色输出。
## 功能
- **颜色渐变**通过逐步调整RGB值来模拟呼吸灯效果。
- **色调循环**在HSV颜色空间中循环改变色调以实现颜色渐变。
### 组件
- **颜色转换**将HSV颜色值转换为RGB颜色值。
| 功能 | 示例 | 备注 |
| ------------ | ------------------------------------ | ------------------------------------------------------------ |
| **颜色渐变** | `app_rgb_cycle_breathing_example` | 通过逐步调整RGB值来模拟呼吸灯效果。 |
| **色调循环** | `app_hsv_cycle_example` | 在HSV颜色空间中循环改变色调以实现颜色渐变。 |
| **颜色转换** | `app_test_HSV_to_RGB` | 将HSV颜色值转换为RGB颜色值。 |
| **颜色填充** | `app_test_fill_gradient_with_groups` | 将单一颜色填充到整个RGB条中也可以将RGB条分组同时输出不同的颜色或响应。 |
| **幻彩渐变** | `app_hsv_cycle_per_rgb_example` | 每个灯珠独立的HSV渐变以获得颜色流动的效果。 |
- **颜色填充**将单一颜色填充到整个RGB条中也可以将RGB条分组同时输出不同的颜色或响应
### 高级应用
- **音量响应**:根据响度值(-xdB~0dB),获取音量等级,以实现响度可视化
- **RGB灯条驱动**启动一个永久循环持续更新RGB灯条的颜色。
- **HSV颜色循环驱动**驱动HSV颜色空间中的颜色循环以实现连续的颜色渐变效果。
| 功能 | 示例 | 备注 |
| -------------------------- | --------------------------------------- | ----------------------------------------------------- |
| **响度可视化** | 待补充 | 通过检测音频样本中的响度实现RGB跟随音量大小跳动 |
| **色调循环&音量响应** | `app_cycleHSV_vol_level_example` | 根据响度值(-xdB~0dB),获取音量等级。 |
| **平滑&音量响应** | `app_vol_level_smooth_example` | 一种过渡效果当响度下降时逐级熄灭RGB而不是突变。 |
| **平滑&色调循环&音量响应** | `app_cycleHSV_vol_level_smooth_example` | 结合了HSV颜色渐变平滑过渡以及音量响应 |
## 使用方法
### 包含头文件
在你的项目中包含`rgb_effect.h`文件。
在你的项目中包含`rgb_effect.h`文件它是较高等级的灯效头文件用于实现各种灯效以及向RGB输出灯效
```c
#include "rgb_effect.h"
```
或者直接包含`visualize_volume.h`它是最高等级的应用头文件用于实现可视化的响度。你需要为它创建一个线程并向它的缓存中写入音频样本以驱动RGB。
```c
#include "visualize_volume.h"
```
//TODO: 后续我们会创建一个例程,帮助你快速构建一个线程安全的应用。
### 快速开始
如果你想要一个开箱即用的持续的颜色渐变效果,可以使用`cycleRGB_driver``cycleHSV_driver`函数
如果你想要尝试开箱即用的持续的颜色渐变效果,可以使用`examples/app_hsv_cycle_example/src/hsv_cycle_example.c`中的`hsv_cycle_example`函数,具体的用法可以参考该示例
注意当前用于驱动LED组的默认的IO定义在`Tile[1]``4A3`端口上因此你需要添加对tile的声明。
```c
par
{
// 启动RGB颜色渐变驱动
on tile[1]: cycleRGB_driver();
}
```
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
或者:
```c
par
extern "C"
{
// 启动HSV颜色循环驱动
on tile[1]: cycleHSV_driver();
void hsv_cycle_example();
}
int main() // 定义主函数
{
par
{
on tile[1]:
{
hsv_cycle_example();
}
}
return 0; // 返回0表示程序正常结束
}
```
### 初始化颜色和方向
@@ -93,17 +110,16 @@ output_rgb_array(rgb_array, 3);
## 路线图
- [ ] 当RGB_MAX等值超限时raise error
- [ ] 为绘制RGB的函数添加可合并选项以减少资源占用
- [ ] 添加更多应用光效
- [x] 为绘制RGB的函数添加可合并选项以减少资源占用
- [x] 添加更多应用光效
- [x] RGB渐变
- [x] HSV渐变
- [ ] 每个灯珠独立的HSV渐变
- [x] 每个灯珠独立的HSV渐变
- [x] 音频响度响应
- [ ] 使用fp/s32以增加`HSV_to_RGB`的计算效率
- [ ] 提供音频响度响应的例程与说明
## 贡献
如果你有任何改进意见或者发现了bug请通过issues或pull requests来提交。
如果你有任何改进意见或者发现了bug请通过issues或pull requests来提交或贡献
感谢使用`lib_rgb`

View File

@@ -1,10 +1,7 @@
# This variable should contain a space separated list of all
# the directories containing buildable applications (usually
# prefixed with the app_ prefix)
BUILD_SUBDIRS = ./app_rgb_cycle_breathing_example \
./app_hsv_cycle_example \
./app_test_cycleHSV_with_vol_level_example \
./app_test_fill_gradient_with_groups \
BUILD_SUBDIRS := $(wildcard ./app_*)
# This variable should contain a space separated list of all
# the directories containing buildable plugins (usually

View File

@@ -8,7 +8,7 @@ TARGET = XCORE-AI-EXPLORER
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb

View File

@@ -4,7 +4,7 @@
#include "samples_to_levels.h"
#include "rgb_effect.h"
#include "timer.h"
void test_cycleHSV_with_vol_level_example()
void cycleHSV_vol_level_example()
{
uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区大小由NUM_RGBS宏确定
uint32_t current_hue = 0; // 从红色开始的当前色相值

View File

@@ -13,7 +13,7 @@
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"{
void test_cycleHSV_with_vol_level_example();
void cycleHSV_vol_level_example();
}
int main() // 定义主函数
@@ -22,7 +22,7 @@ int main() // 定义主函数
{
on tile[1]:
{
test_cycleHSV_with_vol_level_example();
cycleHSV_vol_level_example();
}
}
return 0; // 返回0表示程序正常结束

View File

@@ -0,0 +1,24 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = XCORE-AI-EXPLORER
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb
XCC_FLAGS = $(BUILD_FLAGS)
XMOS_MODULE_PATH = ../../..
XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
#=============================================================================
# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,56 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h> // 包含基本的输入输出函数
#include "rgb_effect.h"
#include "timer.h"
#define DELAY_DECREASE 40 // 降低亮度时的额外延迟
// 该函数用于平滑过渡HSV颜色和音量级别
void cycleHSV_vol_level_smooth_example()
{
uint32_t buf[NUM_RGBS]; // 存储RGB值的缓冲区
uint32_t current_hue = 0; // 当前色调
uint32_t current_color[NUM_RGB_GROUPS] = {0x000000, 0x000000}; // 当前颜色数组
size_t random_levels[NUM_RGB_GROUPS]; // 随机音量级别数组
size_t previous_levels[NUM_RGB_GROUPS] = {0}; // 存储先前的音量级别
srand(1); // 设置随机数种子
while (1) // 无限循环
{
for (size_t i = 0; i < NUM_RGB_GROUPS; i++) // 遍历RGB组
{
// 获取新的随机音量级别
random_levels[i] = get_volume_level(rand() % 101 - 100);
// 如果新的级别低于之前的级别,逐渐降低
while (previous_levels[i] > random_levels[i])
{
previous_levels[i]--; // 降低当前级别
// 用当前颜色和级别填充渐变
fill_gradient_with_groups(buf, current_color, previous_levels);
delay_milliseconds(DELAY_DECREASE); // 延迟
// 更新每一步的RGB颜色
for (size_t j = 0; j < NUM_RGB_GROUPS; j++)
{
current_color[j] = cycleHSV(&current_hue);
}
}
}
// 用随机颜色和级别填充渐变
fill_gradient_with_groups(buf, current_color, random_levels);
delay_milliseconds(DELAY_TIME_RGB); // 延迟
// 更新当前颜色
for (size_t i = 0; i < NUM_RGB_GROUPS; i++)
{
current_color[i] = cycleHSV(&current_hue);
}
// 更新先前的音量级别
for (size_t i = 0; i < NUM_RGB_GROUPS; i++)
{
previous_levels[i] = random_levels[i];
}
}
}

View File

@@ -0,0 +1,24 @@
/** @brief 平滑过渡&HSV循环&模拟音量响应
* @author Vergil Wong
* @date 2023-11-25
* @param
* @return
*/
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"{
void cycleHSV_vol_level_smooth_example();
}
int main() // 定义主函数
{
par
{
on tile[1]:
{
cycleHSV_vol_level_smooth_example();
}
}
return 0; // 返回0表示程序正常结束
}

View File

@@ -8,7 +8,7 @@ TARGET = XCORE-AI-EXPLORER
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb lib_xcore_math

View File

@@ -12,7 +12,7 @@ void hsv_cycle_example()
while (1)
{
// 用当前渐变颜色填充RGB数组然后发送给rgb阵列
fill_gradient(buf, NUM_RGBS, current_color);
fill_gradient(buf, current_color, NUM_RGBS);
// 延迟以控制显示持续时间
delay_milliseconds(DELAY_TIME_RGB);

View File

@@ -0,0 +1,24 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = XCORE-AI-EXPLORER
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -report -fxscope -D_XUA_CONF_H_EXISTS_
USED_MODULES = lib_rgb lib_xcore_math
XCC_FLAGS = $(BUILD_FLAGS)
XMOS_MODULE_PATH = ../../..
XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
#=============================================================================
# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,26 @@
/**
* @file xua_conf.h
* @brief Defines relating to device configuration and customisation.
* For PXUA-XU316-MC-MAX
*/
#ifndef _XUA_CONF_H_
#define _XUA_CONF_H_
/* Defines relating to feature placement regarding tiles */
#ifndef RGB_TILE
#define RGB_TILE (1)
#endif
#ifndef DELAY_TIME_RGB
#define DELAY_TIME_RGB (60)
#endif
#ifndef RGB_MAX
#define RGB_MAX (20)
#endif
#ifndef HUE_STEP
#define HUE_STEP (10)
#endif
#endif

View File

@@ -0,0 +1,45 @@
#include <stdint.h>
#include <stddef.h>
#include <stdio.h> // 包含基本的输入输出函数
#include "rgb_effect.h"
#include "timer.h"
#include "xmath/xmath.h"
#include <string.h>
void init_colors(uint32_t *current_colors, uint32_t *previous_colors, uint32_t current_hue){
for (size_t i = 0; i < NUM_RGBS; i++)
{
*(current_colors + i) = cycleHSV(&current_hue);
}
// TODO: 当使用xs3_memcpy时复制的后几个数据看起来是随机的
memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t));
}
void hsv_cycle_per_rgb_example()
{
uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区大小由NUM_RGBS宏确定
uint32_t current_hue = 0; // 从红色开始的当前色相值
uint32_t WORD_ALIGNED current_colors[NUM_RGBS]; //用于存储当前颜色值的数组。
uint32_t WORD_ALIGNED previous_colors[NUM_RGBS];//用于存储上一组颜色值的数组
size_t levels[NUM_RGB_GROUPS]; //指定每个RGB组亮灯的个数
init_colors(current_colors, previous_colors, current_hue); //初始化颜色
while (1)
{
for (size_t i = 0; i < NUM_RGB_GROUPS; i++)
{
*(levels + i) = (NUM_RGBS / NUM_RGB_GROUPS)-1;
}
// 用当前渐变颜色填充RGB数组然后发送给rgb阵列
fill_gradient_with_groups_colorful(buf, current_colors, levels);
// 延迟以控制显示持续时间
delay_milliseconds(DELAY_TIME_RGB);
// 更改下一组颜色其中每个灯继承上一个灯的颜色第一个灯通过cycleHSV计算出新的颜色
memcpy(current_colors+1, previous_colors, (NUM_RGBS-1) * sizeof(uint32_t));
current_colors[0] = cycleHSV(&current_hue);
// 保留本轮颜色的记录
memcpy(previous_colors, current_colors, NUM_RGBS * sizeof(uint32_t));
}
}

View File

@@ -0,0 +1,32 @@
/** @brief RGB灯条HSV循环渐变
*
* 此函数使用初始色相值初始化两个颜色数组current_colors和preview_colors。
* 它通过调用'cycleHSV'函数为每个颜色位置生成一个基于当前色相的颜色值。
* 然后,它在一个无限循环中,使用'fill_gradient_with_groups_colorful'函数
* 将颜色渐变填充到一个RGB缓冲区并通过'output_rgb_array'函数输出。
* 在每次循环的末尾,颜色数组会更新,为下一次迭代准备新的颜色。
*
* @author Vergil Wong
* @date 2023-11-26
* @param
* @return
*/
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"
{
void hsv_cycle_per_rgb_example();
}
int main() // 定义主函数
{
par
{
on tile[1]:
{
hsv_cycle_per_rgb_example();
}
}
return 0; // 返回0表示程序正常结束
}

View File

@@ -8,7 +8,7 @@ TARGET = XCORE-AI-EXPLORER
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb

View File

@@ -11,7 +11,7 @@ void rgb_cycle_breathing_example()
while (1)
{
// 用当前渐变颜色填充RGB数组
fill_gradient(buf, NUM_RGBS, current_color);
fill_gradient(buf, current_color, NUM_RGBS);
// 延迟以控制显示持续时间
delay_milliseconds(DELAY_TIME_RGB);
// 更改下一个渐变的基色

View File

@@ -8,7 +8,7 @@ TARGET = XCORE-AI-EXPLORER
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb

View File

@@ -1,4 +1,5 @@
#include <stdint.h>
#include <stdio.h>
#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);
}

View File

@@ -0,0 +1,25 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = PXUA-316-MC-MAX.xn
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
# _XUA_CONF_H_EXISTS_: 提示编译器编译部分文件时包含xua_conf.h
BUILD_FLAGS = -O2 -g -report -fxscope -D_XUA_CONF_H_EXISTS_
USED_MODULES = lib_rgb
XCC_FLAGS = $(BUILD_FLAGS)
XMOS_MODULE_PATH = ../../..
XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
#=============================================================================
# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmos.com http://www.xmos.com" ManuallySpecifiedRouting="true">
<Type>Board</Type>
<Name>PXUA-316-MC-MAX</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS3-UnA-1024-FB265">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" referencefrequency="100MHz">
<Boot>
<Source Location="bootFlash"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/> <!-- QSPI_CS_N, 0:Flash 1:PSRAM -->
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
<!-- Audio Ports :PXUA-316-MC-MAX -->
<Port Location="XS1_PORT_1A" Name="PORT_MCLK_IN"/> <!-- MCLK(connected to PLL_OUT) -->
<Port Location="XS1_PORT_1L" Name="PORT_I2S_BCLK"/> <!-- I2S_BCLK_IN -->
<Port Location="XS1_PORT_1D" Name="PORT_I2S_LRCLK"/> <!-- I2S_LRCLK_IN -->
<Port Location="XS1_PORT_1M" Name="PORT_I2S_DAC0"/> <!-- I2S_DAC0/TDM_DAC0 -->
<Port Location="XS1_PORT_1N" Name="PORT_I2S_DAC1"/> <!-- I2S_DAC1/TDM_DAC1 -->
<Port Location="XS1_PORT_1O" Name="PORT_I2S_DAC2"/> <!-- I2S_DAC2/TDM_DAC2 -->
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC3"/> <!-- I2S_DAC3/TDM_DAC3 or SPDIF_OUT-->
<Port Location="XS1_PORT_1A" Name="PORT_DSD_CLK"/> <!-- DSD CLK -->
<Port Location="XS1_PORT_1D" Name="PORT_DSD_DAC0"/> <!-- DSD_L -->
<port Location="XS1_PORT_1M" Name="PORT_DSD_DAC1"/> <!-- DSD_R -->
<Port Location="XS1_PORT_1P" Name="PORT_SPDIF_OUT"/> <!-- SPDIF_OUT -->
<!-- Ctrl Ports :PXUA-316-MC-MAX -->
<port Location="XS1_PORT_4E" Name="PORT_I2C"/> <!-- 4E2:I2C_CLK, 4E3:I2C_SDA -->
<port Location="XS1_PORT_4F" Name="PORT_MCLK_SELECT"/> <!-- 4F1:CODEC_RST, 4F2:USB_STATE_LED, 4F3:Crystal Selection Mode(1:45.1584MHz 0:49.152MHz) -->
<port Location="XS1_PORT_8D" Name="PORT_BUTTON"/> <!-- The default is 3.3V. Press 0.
8D4:HID_BUTTON0/VOLUME_UP, 8D5:HID_BUTTON1/VOLUME_DOWN.
8D6:HID_BUTTON2/PLAY/PAUSE, 8D7:CUSTOM_BUTTOM/MUTE. -->
<Port Location="XS1_PORT_1C" Name="PORT_PLL_REF"/>
</Tile>
<Tile Number="1" Reference="tile[1]">
<!-- Audio Ports :PXUA-316-MC-MAX -->
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/> <!-- I2S_MCLK_OUT(PLL Out) -->
<Port Location="XS1_PORT_1G" Name="PORT_EXTRA_I2S_BCLK"/> <!-- EXTRA_I2S_BCLK_OUT -->
<Port Location="XS1_PORT_1C" Name="PORT_EXTRA_I2S_LRCLK"/> <!-- EXTRA_I2S_LRCLK_OUT -->
<Port Location="XS1_PORT_1A" Name="PORT_EXTRA_I2S_ADC0"/> <!-- EXTRA_I2S_ADC0/TDM_ADC0 -->
<Port Location="XS1_PORT_1B" Name="PORT_EXTRA_I2S_ADC1"/> <!-- EXTRA_I2S_ADC1/TDM_ADC1 or SPDIF_IN -->
<Port Location="XS1_PORT_1F" Name="PORT_EXTRA_I2S_ADC2"/> <!-- EXTRA_I2S_ADC2/TDM_ADC2 -->
<Port Location="XS1_PORT_1K" Name="PORT_EXTRA_I2S_ADC3"/> <!-- EXTRA_I2S_ADC3/TDM_ADC3 -->
<Port Location="XS1_PORT_1B" Name="PORT_SPDIF_IN"/> <!-- SPDIF_IN -->
<!-- Ctrl Ports :PXUA-316-MC-MAX -->
<Port Location="XS1_PORT_4A" Name="PORT_RGB_DAISY_CHAIN"/> <!-- 4A3: PORT_RGB_DAISY_CHAIN -->
<Port Location="XS1_PORT_1K" Name="PORT_UART_TX_PP"/> <!-- 1K: UART_TX -->
<Port Location="XS1_PORT_1F" Name="PORT_UART_RX_PP"/> <!-- 1F: UART_RX -->
<!-- Extensions Feature: MIDI_v1.0 -->
<!-- <Port Location="XS1_PORT_1K" Name="PORT_MIDI_OUT"/> -->
<!-- <Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/> -->
</Tile>
</Node>
</Nodes>
</Package>
</Packages>
<Nodes>
<Node Id="2" Type="device:" RoutingId="0x8000">
<Service Id="0" Proto="xscope_host_data(chanend c);">
<Chanend Identifier="c" end="3"/>
</Service>
</Node>
</Nodes>
<Links>
<Link Encoding="2wire" Delays="4,4" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="XL0"/>
<LinkEndpoint NodeId="2" Chanend="1"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K" PageSize="256" SectorSize="4096" NumPages="8192">
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
<Attribute Name="QE_REGISTER" Value="flash_qe_location_status_reg_1"/>
<Attribute Name="QE_BIT" Value="flash_qe_bit_1"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>
</Network>

View File

@@ -0,0 +1,14 @@
/**
* @file xua_conf.h
* @brief Defines relating to device configuration and customisation.
* For PXUA-XU316-MC-MAX
*/
#ifndef _XUA_CONF_H_
#define _XUA_CONF_H_
/* Defines relating to feature placement regarding tiles */
#ifndef RGB_TILE
#define RGB_TILE (1)
#endif
#endif

View File

@@ -0,0 +1,26 @@
/** @brief 测试output_rgb_array
*
* @author Vergil Wong
* @date 2023-11-25
* @param
* @return
*/
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"
{
void test_output_rgb_array_example();
}
int main() // 定义主函数
{
par
{
on tile[1]:
{
test_output_rgb_array_example();
}
}
return 0; // 返回0表示程序正常结束
}

View File

@@ -0,0 +1,16 @@
#include <stdint.h>
#include <stdlib.h>
#include "rgb_effect.h"
void test_output_rgb_array_example()
{
uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区大小由NUM_RGBS宏确定
uint32_t num_rgbs = 12;
// Initialize the buffer with example RGB values
for (uint32_t i = 0; i < num_rgbs; ++i) {
buf[i] = (i << 16) | (i << 8) | i; // Just an example pattern for RGB values
}
// Call the function with the test buffer and number of RGBs
output_rgb_array(buf, num_rgbs);
}

View File

@@ -8,7 +8,7 @@ TARGET = XCORE-AI-EXPLORER
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -report -fxscope
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb

View File

@@ -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

View File

@@ -1,37 +1,14 @@
#include <stdint.h>
#include <stdio.h> // 包含基本的输入输出函数
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
#include "samples_to_levels.h"
#include "rgb_effect.h"
#include "timer.h"
void test_fill_gradient_with_groups()
{
uint32_t buffer[NUM_RGBS];
uint32_t colors[] = {0xFF0000, 0x00FF00}; // 红,绿
size_t num_filled_rgb[] = {2, 3}; // 每组填充数量
size_t num_groups = sizeof(colors) / sizeof(colors[0]);
int success = 1; // 使用int代替bool1代表true0代表false
uint32_t colors[] = {0x110000, 0x001100, 0x000011}; // 红,绿,蓝
size_t num_filled_rgb[] = {4, 4, 4}; // 每组填充数量
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_groups);
size_t group_led_start = group * (NUM_RGBS / num_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");
}
}

View File

@@ -0,0 +1,24 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = XCORE-AI-EXPLORER
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb
XCC_FLAGS = $(BUILD_FLAGS)
XMOS_MODULE_PATH = ../../..
XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
#=============================================================================
# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,22 @@
/** @brief 测试不同的响度值转化为音量等级
* @author Vergil Wong
* @date 2023-11-25
* @param
* @return
*/
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"
{
void test_vol_to_level();
}
int main() // 定义主函数
{
par
{
on tile[1]: test_vol_to_level();
}
return 0; // 返回0表示程序正常结束
}

View File

@@ -0,0 +1,15 @@
#include <stdint.h>
#include <stdio.h>
#include "rgb_effect.h"
void test_vol_to_level()
{
// 测试不同的响度值
uint32_t test_loudness_values[] = {1, 0, -2, -5, -8, -20, -30, -40, -60, -62, -70, };
int num_tests = sizeof(test_loudness_values) / sizeof(test_loudness_values[0]);
for (int i = 0; i < num_tests; ++i) {
printf("Loudness: %lu dB, Volume Level: %u\n",
test_loudness_values[i],
get_volume_level((int)test_loudness_values[i]));
}
}

View File

@@ -0,0 +1,24 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = XCORE-AI-EXPLORER
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -report -fxscope
USED_MODULES = lib_rgb
XCC_FLAGS = $(BUILD_FLAGS)
XMOS_MODULE_PATH = ../../..
XCOMMON_DISABLE_AUTO_MODULE_SEARCH = 1
#=============================================================================
# 下面部分的 Makefile 包含了用于编译 XMOS 应用程序的公共构建基础设施。你无需编辑此处以下的内容。
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,28 @@
/** @brief 音量响应&平滑过渡
*
* 每个颜色组都会根据音量水平的随机值来更新其亮度。每次循环后,将当前颜色
* 应用到RGB条的相应组中。此函数旨在模拟实时音乐响应的灯光效果并实现平滑过渡下降
* 与app_cy
* @author Vergil Wong
* @date 2023-11-25
* @param
* @return
*/
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
extern "C"{
void vol_level_smooth_example();
}
int main() // 定义主函数
{
par
{
on tile[1]:
{
vol_level_smooth_example();
}
}
return 0; // 返回0表示程序正常结束
}

View File

@@ -0,0 +1,42 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h> // 包含基本的输入输出函数
#include "rgb_effect.h"
#include "timer.h"
#define DELAY_DECREASE 40 // 降低亮度时的额外延迟
void vol_level_smooth_example()
{
uint32_t buf[NUM_RGBS]; // 定义一个用于存储RGB值的缓冲区大小由NUM_RGBS宏确定
uint32_t current_color[NUM_RGB_GROUPS] = {0xFF0000, 0xFF0000};
srand(1); // 初始化随机数种子
size_t random_levels[NUM_RGB_GROUPS];
size_t previous_levels[NUM_RGB_GROUPS] = {0}; // 存储先前的音量级别
while (1)
{
for (size_t i = 0; i < NUM_RGB_GROUPS; i++)
{
*(random_levels + i) = get_volume_level(rand() % 101 - 100);
// 如果新的级别低于之前的级别,逐渐降低
while (previous_levels[i] > random_levels[i])
{
previous_levels[i]--; // 降低当前级别
// 用当前颜色和级别填充渐变
fill_gradient_with_groups(buf, current_color, previous_levels);
delay_milliseconds(DELAY_DECREASE); // 延迟
}
}
// 用当前渐变颜色填充RGB数组然后发送给rgb阵列
fill_gradient_with_groups(buf, current_color, random_levels);
// 延迟以控制显示持续时间
delay_milliseconds(DELAY_TIME_RGB);
// 更新先前的音量级别
for (size_t i = 0; i < NUM_RGB_GROUPS; i++)
{
previous_levels[i] = random_levels[i];
}
}
}

View File

@@ -1,5 +1,5 @@
#ifndef _MISC_UTILS_H
#define _MISC_UTILS_H
#ifndef MISC_UTILS_H
#define MISC_UTILS_H
#include <stdint.h>
#include <stddef.h>
@@ -15,4 +15,4 @@
* 直到到达中心点,完成反转过程。
*/
void reverse_buf(uint32_t *start, size_t count);
#endif // _MISC_UTILS_H
#endif // MISC_UTILS_H

View File

@@ -1,7 +1,22 @@
#ifndef _RGB_DRIVER_H
#define _RGB_DRIVER_H
#ifndef RGB_DRIVER_H
#define RGB_DRIVER_H
#include <stdint.h>
#include <xs1.h>
#include "misc_utils.h"
//TODO: 在XUA工程环境中测试
// 在Makefile中定义编译选项以使用xua配置项覆盖定义
#ifdef _XUA_CONF_H_EXISTS_
#include "xua_conf.h"
#endif
#ifndef RGB_TILE
#define RGB_TILE (1)
#endif
#ifndef PORT_RGB_DAISY_CHAIN
#define PORT_RGB_DAISY_CHAIN XS1_PORT_4A
#endif
/** 串行输出24位值。
*
@@ -29,4 +44,4 @@ void output_24bit_value_serially(uint32_t value);
*/
void output_rgb_array(uint32_t buf[], uint32_t num_rgbs);
#endif // _RGB_DRIVER_H
#endif // RGB_DRIVER_H

View File

@@ -1,12 +1,16 @@
#ifndef RGB_EFFECT_H
#define RGB_EFFECT_H
#include <stdint.h>
#include <stddef.h>
#include "rgb_driver.h"
#include "samples_to_levels.h"
#include "misc_utils.h"
// 在Makefile中定义编译选项以使用xua配置项覆盖定义
#ifdef _XUA_CONF_H_EXISTS_
#include "xua_conf.h"
#endif
// RGB灯的数量
#ifndef NUM_RGBS
#define NUM_RGBS (12)
@@ -49,6 +53,10 @@
#define DELAY_TIME_RGB (1000 / RGB_MAX)
#endif
// 控制cycleHSV中HUE递增的步进值该步进值应能整除360且不超过它
#ifndef HUE_STEP
#define HUE_STEP (1)
#endif
/**
* 定义渐变方向的枚举类型。
*
@@ -141,7 +149,7 @@ uint32_t HSV_to_RGB(uint32_t *hue, uint32_t *sat, uint32_t *value);
* \param buf 指向存储RGB值的缓冲区的指针每个元素代表RGB条中一个颜色单元的颜色值。
* \param color 要填充的统一颜色值。
*/
void fill_gradient(uint32_t *buf, size_t num_filled_rgb, uint32_t color);
void fill_gradient(uint32_t *buf, uint32_t color, size_t num_filled_rgb);
/**
* 将多种颜色分组填充到RGB条中并控制显示颜色的时间长度。
@@ -157,4 +165,5 @@ void fill_gradient(uint32_t *buf, size_t num_filled_rgb, uint32_t color);
*/
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

@@ -31,14 +31,6 @@
*/
size_t get_volume_level(int loudness_value);
/**
* 测试不同响度值对应的音量等级。
*
* 此函数定义了一系列响度值,并使用 get_volume_level 函数
* 来获取每个响度值对应的音量等级,然后打印出来。
*/
void volume_level_test();
/**
* 将音频样本转换为音量级别。
*

View File

@@ -1,7 +1,6 @@
#ifndef CACHE_OPERATIONS_H
#define CACHE_OPERATIONS_H
#include <stdint.h>
#include "samples_to_levels.h"
#include "rgb_effect.h"
/**
* \brief 初始化缓存缓冲区。
@@ -40,5 +39,4 @@ void write_to_inactive_cache(int address, int16_t data);
* current_hue作为当前色调值用于生成下一个颜色。
*/
void visualize_loudness_driver();
#endif // CACHE_OPERATIONS_H
// TODO: Refact this shit
#endif // CACHE_OPERATIONS_H

View File

@@ -1,8 +1,8 @@
VERSION = 0.0.4
VERSION = 0.1.0
DEPENDENT_MODULES = lib_xcore_math(>=2.1.0) \
MODULE_XCC_FLAGS = $(XCC_FLAGS) -g -O3 -Wall
MODULE_XCC_FLAGS = $(XCC_FLAGS) -g -O3 -Wall -Wextra -Werror
EXPORT_INCLUDE_DIRS = api

View File

@@ -4,17 +4,18 @@
#include <timer.h>
#include "xclib.h"
#include <stdint.h>
#include "rgb_driver.h"
// 如果灯的显示没有出现问题,不要修改这些宏
#define MICROSECONDS 100
#define RT23_RST_DELAY (MICROSECONDS * 200000) // 200 ms 当前没有使用,因为引脚通常自动拉低
#define T0H_DELAY (33) // 0.3 μs, assuming MICROSECONDS is 100 times the actual microsecond count
#define RT23_RST_DELAY (MICRO_SECOND * 200000) // 200 ms 当前没有使用,因为引脚通常自动拉低
#define T0H_DELAY (33) // 0.3 μs, assuming MICRO_SECOND is 100 times the actual microsecond count
#define T1H_DELAY (63) // 0.6 μs
#define T0L_DELAY (93) // 0.9 μs
#define T1L_DELAY (63) // 0.6 μs
// RGB_TILE 通常为0/1PORT_RGB_DAISY_CHAIN为4bit port
on tile[RGB_TILE]: out port p_rgb_4bit = PORT_RGB_DAISY_CHAIN;
on tile[1] : out port p_rgb_rgb = XS1_PORT_4A; // 注意当前代码仅适用于4bit端口
timer tmr;
// 向4A3写时序点亮RT23
@@ -22,19 +23,19 @@ uint32_t output_bit_on_4th_pin(uint32_t bit, uint32_t fall_time)
{
if (bit == 1)
{
p_rgb_rgb<:0xff; // 输出到4位端口
p_rgb_4bit<:0xff; // 输出到4位端口
tmr when timerafter(fall_time + T1H_DELAY):> fall_time; // 等待T1H时长
// printf("[x]fall_time: %u\n", fall_time);
p_rgb_rgb<:0x00; // 将第4位设置为低电平
p_rgb_4bit<:0x00; // 将第4位设置为低电平
tmr when timerafter(fall_time + T1L_DELAY):> fall_time; // 等待T1L时长
// printf("[x]fall_time: %u\n", fall_time);
}
else if (bit == 0)
{
p_rgb_rgb<:0xff; // 输出到4位端口
p_rgb_4bit<:0xff; // 输出到4位端口
tmr when timerafter(fall_time + T0H_DELAY):> fall_time; // 等待T0H时长
// printf("[x]fall_time: %u\n", fall_time);
p_rgb_rgb<:0x00; // 将第4位设置为低电平
p_rgb_4bit<:0x00; // 将第4位设置为低电平
tmr when timerafter(fall_time + T0L_DELAY):> fall_time; // 等待T0L时长
// printf("[x]fall_time: %u\n", fall_time);
}
@@ -52,7 +53,7 @@ void output_24bit_value_serially(uint32_t value)
uint32_t fall_time = 0;
tmr:> fall_time;
// // 重置 RT23由于引脚默认为低此处不做重置
// p_rgb_rgb <: 0x000000;
// p_rgb_4bit <: 0x000000;
// tmr when timerafter(fall_time + RT23_RST_DELAY):> fall_time;
value = value << 8;

View File

@@ -5,7 +5,7 @@
#include "rgb_driver.h"
#include "samples_to_levels.h"
#include "misc_utils.h"
#include "rgb_effect.h"
#include "rgb_effect.h"
// 检查HSV值是否在有效范围内如果溢出则将值设为最大值并打印报错
void is_HSV_valid(uint32_t *hue, uint32_t *sat, uint32_t *value)
@@ -33,9 +33,9 @@ uint32_t HSV_to_RGB(uint32_t *hue, uint32_t *sat, uint32_t *value)
{
#ifdef HSV_VALID_CHECK
#if HSV_VALID_CHECK == 0
(is_HSV_valid(hue, sat, value));
#endif
#if HSV_VALID_CHECK == 0
(is_HSV_valid(hue, sat, value));
#endif
#endif
uint32_t g; // 现在G是最高8位
@@ -89,7 +89,6 @@ uint32_t HSV_to_RGB(uint32_t *hue, uint32_t *sat, uint32_t *value)
return (g << 16) | (r << 8) | b;
}
// 逐步遍历RGB颜色空间实现呼吸灯效果
uint32_t cycleRGB(uint32_t color, GradientDirection *direction)
{
@@ -134,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
@@ -142,11 +141,11 @@ uint32_t cycleHSV(uint32_t *hue)
(*hue) = 0;
// printf("--------hue is: 0x%06X----------\n", *hue);
}
return(HSV_to_RGB(hue, &sat, &value));
return (HSV_to_RGB(hue, &sat, &value));
}
// 将单一颜色填充到整个RGB条中并控制显示颜色的时间长度
void fill_gradient(uint32_t *buf, size_t num_filled_rgb, uint32_t color)
void fill_gradient(uint32_t *buf, uint32_t color, size_t num_filled_rgb)
{
// 遍历缓冲区的每个元素,将其设置为提供的颜色值
for (size_t i = 0; i < num_filled_rgb; i++)
@@ -165,30 +164,63 @@ void fill_gradient(uint32_t *buf, size_t num_filled_rgb, uint32_t color)
delay_milliseconds(DELAY_TIME_RGB);
}
// 将多种颜色分组填充到RGB条中,并控制显示颜色的时间长度。
// 将多种颜色分组填充到RGB条中
void fill_gradient_with_groups(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++) {
// 填充每个组的LED
for (size_t group = 0; group < NUM_RGB_GROUPS; group++)
{
// 填充每个组的RGB
uint32_t *group_buf = buf + group * max_leds_per_group;
for (size_t i = 0; i < num_filled_rgb[group]; i++) {
for (size_t i = 0; i < num_filled_rgb[group]; i++)
{
*(group_buf + i) = colors[group];
}
// 熄灭该组剩余的LED
for (size_t i = num_filled_rgb[group]; i < max_leds_per_group; i++) {
// 熄灭该组剩余的RGB
for (size_t i = num_filled_rgb[group]; i < max_leds_per_group; i++)
{
*(group_buf + i) = 0x000000;
}
// 如果组号为奇数翻转该组对应的buffer元素
if (group % 2 != 0) {
if (group % 2 != 0)
{
reverse_buf(group_buf, max_leds_per_group);
}
}
// 将缓冲区输出到RGB条
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);
}

View File

@@ -101,17 +101,4 @@ void samples_to_levels(int16_t sample_in[], size_t levels[])
levels[i] = get_volume_level(rms);
// printf("rms[%d]: %d \n", i, rms);
}
}
// 测试不同响度值对应的音量等级是否符合预期
void volume_level_test() {
// 测试不同的响度值
uint32_t test_loudness_values[] = {1, 0, -2, -5, -8, -20, -30, -40, -60, -62, -70, };
int num_tests = sizeof(test_loudness_values) / sizeof(test_loudness_values[0]);
for (int i = 0; i < num_tests; ++i) {
printf("Loudness: %lu dB, Volume Level: %u\n",
test_loudness_values[i],
get_volume_level((size_t)test_loudness_values[i]));
}
}

View File

@@ -45,7 +45,7 @@ uint32_t current_hue = 0; // 从红色开始的当前色相值
uint32_t current_color[NUM_RGB_GROUPS] = {0x000000, 0x000000};
// 根据音频的响度点亮不同数量的rgb灯
// 根据音频的响度点亮不同数量的rgb灯,实现响度可视化
void visualize_loudness_driver()
{
// 响度对应的RGB灯等级