新增测试中取消测试功能

This commit is contained in:
ipason 2025-04-23 09:36:19 +08:00
parent 8621bb3f16
commit 83ec64a363
3 changed files with 72 additions and 8 deletions

View File

@ -19,6 +19,9 @@ float Spirit3_Volume[4] = { 210,420,630,750};
float Spirit6_Volume[6] = { 210,420,630,840,1050,1200}; float Spirit6_Volume[6] = { 210,420,630,840,1050,1200};
float YULite8_Volume[6] = { 210,420,630,840,1050,1200}; float YULite8_Volume[6] = { 210,420,630,840,1050,1200};
/* 应用 event_homePage 中的测试状态显示变量 */
extern bool is_bs_test_ing;
/* /*
* @brief * @brief
* 1. Time setting sent successfully * 1. Time setting sent successfully
@ -75,8 +78,30 @@ void bs_test_task(void* arg)
ESP_LOGI("bs_test_timer_func","bs_test_timer_func end right"); ESP_LOGI("bs_test_timer_func","bs_test_timer_func end right");
/* 任务测试完毕 删除任务 */
lv_label_set_text(ui_pageHome_labelStartTest1,"Start Test BS");
is_bs_test_ing = false;
vTaskDelete(NULL); vTaskDelete(NULL);
} }
} }
/**
* @brief 线
*
* LED小灯bling bling
*
* @param[in] arg not used
*
*/
void bs_test_led_task(void* arg)
{
while(1)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGI("bs_test_led_task", "bs_test_led_task");
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGI("bs_test_led_task", "bs_test_led_task end?");
}
}

View File

@ -88,6 +88,14 @@ typedef struct FluxCommand
uint32_t PLC_ADDR; uint32_t PLC_ADDR;
}; };
#define BS_ALL_RESULT_CLEAR lv_label_set_text(ui_pageHome_LabelRate15Result, "0");\
lv_label_set_text(ui_pageHome_LabelRate20Result, "0");\
lv_label_set_text(ui_pageHome_LabelRate25Result, "0");\
lv_label_set_text(ui_pageHome_LabelRate30Result, "0");\
lv_label_set_text(ui_pageHome_LabelRate35Result, "0");\
lv_label_set_text(ui_pageHome_LabelRate40Result, "0");
/** /**
* @brief BS测试的任务函数 * @brief BS测试的任务函数
* *
@ -96,6 +104,16 @@ typedef struct FluxCommand
*/ */
void bs_test_task(void* arg); void bs_test_task(void* arg);
/**
* @brief 线
*
* LED小灯bling bling
*
* @param[in] arg not used
*
*/
void bs_test_led_task(void* arg);
#ifdef __cplusplus #ifdef __cplusplus
} /*extern "C"*/ } /*extern "C"*/
#endif #endif

View File

@ -16,6 +16,11 @@
#include "FluxSD.h" #include "FluxSD.h"
/* 创建用于表征当前是否进行BS测试的全局变量 */
bool is_bs_test_ing = false;
/* 创建任务控制句柄 */
TaskHandle_t bs_test_task_handle;
/* 声明需要调用的静态函数 */ /* 声明需要调用的静态函数 */
static void comulate_time_set(void); static void comulate_time_set(void);
@ -472,6 +477,28 @@ static void bs_test_timer_func(lv_timer_t * timer)
*/ */
void on_buttonStartTestBS_clicked(lv_event_t * e) void on_buttonStartTestBS_clicked(lv_event_t * e)
{ {
/* 判断是否正在测试 */
if(is_bs_test_ing)
{
/* 如果正在测试,按下后取消测试 */
vTaskDelete(bs_test_task_handle);
/* 等待开始测试 */
is_bs_test_ing = false;
/* 清空已完成的测试结果 */
BS_ALL_RESULT_CLEAR;
lv_label_set_text(ui_pageHome_labelStartTest1,"Start Test BS");
}else{
/* 如果没有测试,按下后开始测试 */
/* 创建BS测试任务 */
xTaskCreate(bs_test_task, "bs_test_task", 1024*4, NULL, 5, &bs_test_task_handle);
is_bs_test_ing = true;
lv_label_set_text(ui_pageHome_labelStartTest1,"Cancel Test BS");
}
#if 0
/* 设置15BPM测试时间 */ /* 设置15BPM测试时间 */
uint8_t bytes[4]; uint8_t bytes[4];
float time = 40.0; float time = 40.0;
@ -503,7 +530,7 @@ void on_buttonStartTestBS_clicked(lv_event_t * e)
/* 屏幕中显示下发成功 */ /* 屏幕中显示下发成功 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[1]); lv_label_set_text(ui_pageHome_labelBSInfo,test_info[1]);
#if 0
/* 创建定时器 */ /* 创建定时器 */
lv_timer_t * bsTestTimer; lv_timer_t * bsTestTimer;
/* 创建定时器调用函数 */ /* 创建定时器调用函数 */
@ -517,15 +544,9 @@ void on_buttonStartTestBS_clicked(lv_event_t * e)
/* 显示正在测试中 */ /* 显示正在测试中 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[2]); lv_label_set_text(ui_pageHome_labelBSInfo,test_info[2]);
#else
/* 不创建定时器,而是创建任务函数 ,使用任务函数进行依次测试 */
xTaskCreate(bs_test_task, "bs_test_task", 1024*4, NULL, 5, NULL);
#endif #endif
ESP_LOGI("on_buttonStartTestBS_clicked","on_buttonStartTestBS_clicked end");
} }