forked from PAWPAW/lib_rgb
增加了测试用例,优化了示例的Makefile
This commit is contained in:
22
examples/app_test_vol_to_level/src/main.xc
Normal file
22
examples/app_test_vol_to_level/src/main.xc
Normal 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,表示程序正常结束
|
||||
}
|
||||
15
examples/app_test_vol_to_level/src/test_vol_to_level.c
Normal file
15
examples/app_test_vol_to_level/src/test_vol_to_level.c
Normal 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]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user