增加了测试用例,优化了示例的Makefile

This commit is contained in:
2023-11-25 23:02:11 +08:00
parent c1c3864c0f
commit efeed1c18c
4 changed files with 62 additions and 4 deletions

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

@@ -0,0 +1,24 @@
# `TARGET` 变量决定了应用程序编译的目标系统。它可以引用源目录中的一个 XN 文件,或者是在编译时作为 `--target` 选项的一个有效参数。
TARGET = XCORE-AI-EXPLORER
# 编译选项
# 构建应用程序时传递给 xcc 的参数
# O2: xcc编译器优化等级2
# report: 打开编译报告
# g: 生成调试信息
# fxscope: 使用 xSCOPE对代码进行跟踪默认使用xlink
BUILD_FLAGS = -O2 -g -DDEBUG_PRINT_ENABLE=1 -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]));
}
}