forked from PAWPAW/lib_rgb
整合测试框架
- 整合了原有的功能用例与接口测试
This commit is contained in:
24
testcases/test_function/app_hsv_cycle_example/Makefile
Normal file
24
testcases/test_function/app_hsv_cycle_example/Makefile
Normal 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 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
|
||||
@@ -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(¤t_hue, ¤t_sat, ¤t_val);
|
||||
while (1)
|
||||
{
|
||||
// 用当前渐变颜色填充RGB数组,然后发送给rgb阵列
|
||||
fill_gradient(buf, current_color, NUM_RGBS);
|
||||
|
||||
// 延迟以控制显示持续时间
|
||||
delay_milliseconds(DELAY_TIME_RGB);
|
||||
// 更改下一个颜色
|
||||
current_color = cycleHSV(¤t_hue);
|
||||
|
||||
// 打印出当前的GRB颜色值
|
||||
// printf("GRB color is: 0x%06X\n", current_color);
|
||||
}
|
||||
}
|
||||
33
testcases/test_function/app_hsv_cycle_example/src/main.xc
Normal file
33
testcases/test_function/app_hsv_cycle_example/src/main.xc
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @brief RGB循环呼吸
|
||||
*
|
||||
* 驱动HSV颜色空间中的颜色循环,以实现连续的颜色渐变效果。
|
||||
*
|
||||
* 此函数初始化颜色值,并进入一个无限循环,不断地计算新的颜色值并更新LED阵列。
|
||||
* 使用并发执行关键字 'par' 来实现循环内部的并行处理。这个函数假定运行环境支持并行关键字 'par'。
|
||||
*
|
||||
* 在此循环中,它首先使用当前颜色填充一个预定义大小的缓冲区,然后调用 `cycleHSV` 函数
|
||||
* 来更新当前色相值并获取新的颜色。最后,它打印出当前的GRB颜色值。
|
||||
* @author Vergil Wong
|
||||
* @date 2023-11-25
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
|
||||
#include <platform.h> // 包含对封装的定义,引用以使用 on tile[] 语法
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void hsv_cycle_example();
|
||||
}
|
||||
|
||||
int main() // 定义主函数
|
||||
{
|
||||
par
|
||||
{
|
||||
on tile[1]:
|
||||
{
|
||||
hsv_cycle_example();
|
||||
}
|
||||
}
|
||||
return 0; // 返回0,表示程序正常结束
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import os
|
||||
from commons.pyxrun import XMakeRun
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("get_logger_check")
|
||||
class TestClass:
|
||||
def test_app_hsv_cycle_example(self, capfd, request, function):
|
||||
if not function:
|
||||
self.logger.info("Skipping test because it's functional testing.")
|
||||
pytest.skip("Skipping test because it's functional testing.")
|
||||
|
||||
file_path = Path(request.fspath).parent
|
||||
xmakerun = XMakeRun(self.logger, file_path)
|
||||
# xmake的命令
|
||||
xmake_cmd = 'xmake -j'
|
||||
# 执行xmake命令
|
||||
xmakerun.xmake_cmd(xmake_cmd)
|
||||
|
||||
# app_cycleHSV_vol_level_example
|
||||
xe_basename = os.path.basename(file_path)
|
||||
|
||||
# app_cycleHSV_vol_level_example.xe
|
||||
xe_name = "{}.xe".format(xe_basename)
|
||||
|
||||
# bin/app_cycleHSV_vol_level_example.xe
|
||||
xrun_file_path = "bin/{}".format(xe_name)
|
||||
|
||||
xrun_cmd = f'xrun {xrun_file_path}'
|
||||
xmakerun.xrun_cmd(xrun_cmd)
|
||||
|
||||
out, _ = capfd.readouterr()
|
||||
|
||||
expect = "xrun successful!"
|
||||
self.check.check_equal(out, expect)
|
||||
|
||||
Reference in New Issue
Block a user