diff --git a/components/FluxProtocol/FluxProtocol.c b/components/FluxProtocol/FluxProtocol.c index f8ae6f7..c57ebaa 100644 --- a/components/FluxProtocol/FluxProtocol.c +++ b/components/FluxProtocol/FluxProtocol.c @@ -19,6 +19,9 @@ float Spirit3_Volume[4] = { 210,420,630,750}; float Spirit6_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 拼接测试过程中用于展示的字符串 * 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"); + /* 任务测试完毕 删除任务 */ + lv_label_set_text(ui_pageHome_labelStartTest1,"Start Test BS"); + is_bs_test_ing = false; 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?"); + } +} \ No newline at end of file diff --git a/components/FluxProtocol/FluxProtocol.h b/components/FluxProtocol/FluxProtocol.h index 3dbafa2..64bee99 100644 --- a/components/FluxProtocol/FluxProtocol.h +++ b/components/FluxProtocol/FluxProtocol.h @@ -88,6 +88,14 @@ typedef struct FluxCommand 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测试的任务函数 * @@ -96,6 +104,16 @@ typedef struct FluxCommand */ void bs_test_task(void* arg); +/** + * @brief 测试状态显示线程 + * + * 设置一个LED小灯,测试的时候bling bling 闪 + * + * @param[in] arg not used + * + */ +void bs_test_led_task(void* arg); + #ifdef __cplusplus } /*extern "C"*/ #endif diff --git a/components/FluxUI/ui_event_homePage.c b/components/FluxUI/ui_event_homePage.c index af567fd..a1e20a7 100644 --- a/components/FluxUI/ui_event_homePage.c +++ b/components/FluxUI/ui_event_homePage.c @@ -16,6 +16,11 @@ #include "FluxSD.h" +/* 创建用于表征当前是否进行BS测试的全局变量 */ +bool is_bs_test_ing = false; +/* 创建任务控制句柄 */ +TaskHandle_t bs_test_task_handle; + /* 声明需要调用的静态函数 */ 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) { + /* 判断是否正在测试 */ + 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测试时间 */ uint8_t bytes[4]; 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]); -#if 0 + /* 创建定时器 */ 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]); -#else - - /* 不创建定时器,而是创建任务函数 ,使用任务函数进行依次测试 */ - xTaskCreate(bs_test_task, "bs_test_task", 1024*4, NULL, 5, NULL); - - #endif - ESP_LOGI("on_buttonStartTestBS_clicked","on_buttonStartTestBS_clicked end"); + }