新建测试任务待完善

This commit is contained in:
ipason 2025-04-23 08:58:26 +08:00
parent 0816204ee9
commit 8621bb3f16
9 changed files with 171 additions and 16 deletions

View File

@ -47,6 +47,7 @@
"random": "c", "random": "c",
"time.h": "c", "time.h": "c",
"types.h": "c", "types.h": "c",
"timespec.h": "c" "timespec.h": "c",
"fluxprotocol.h": "c"
} }
} }

View File

@ -12,11 +12,71 @@
#include <stdio.h> #include <stdio.h>
#include "FluxProtocol.h" #include "FluxProtocol.h"
#include "esp_log.h"
/*记录spirits3的没分钟输出的体积*/ /*记录spirits3的没分钟输出的体积*/
float Spirit3_Volume[4] = { 210,420,630,750}; 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};
/*
* @brief
* 1. Time setting sent successfully
* 2. start testing
* 3. Waiting for the end of the test
* 4. The current frequency test has ended
* 5. All frequency tests have been completed, please record.
* 6. Device started successfully, please start testing.
*/
char *test_info[] = {"Time setting sent successfully!!",\
"start testing....",\
"Waiting for the end of the test...",\
"The current frequency test has ended!!",\
"All frequency tests have been completed!!",\
"Device started successfully!!!!"
};
/* 导出协议数据结构体 */
struct FluxProtocol fluxProtocol; struct FluxProtocol fluxProtocol;
/**
* @brief BS测试的任务函数
*
* @param[in] arg not used
*
*/
void bs_test_task(void* arg)
{
while(1)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGI("bs_test_task", "bs_test_task");
vTaskDelay(4000 / portTICK_PERIOD_MS);
ESP_LOGI("bs_test_task", "bs_test_task end?");
ESP_LOGI("bs_test_timer_func","hahahahhahah............");
/* 显示测试成功 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[3]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[4]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[5]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[1]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[2]);
ESP_LOGI("bs_test_timer_func","bs_test_timer_func end right");
vTaskDelete(NULL);
}
}

View File

@ -36,6 +36,9 @@ extern float Spirit3_Volume[4];
extern float Spirit6_Volume[6]; extern float Spirit6_Volume[6];
extern float YULite8_Volume[6]; extern float YULite8_Volume[6];
/* 导出消息数据*/
extern char *test_info[];
/* 声明设备类型 */ /* 声明设备类型 */
typedef enum DeviceType{ typedef enum DeviceType{
Spirit3, Spirit3,
@ -85,6 +88,14 @@ typedef struct FluxCommand
uint32_t PLC_ADDR; uint32_t PLC_ADDR;
}; };
/**
* @brief BS测试的任务函数
*
* @param[in] arg not used
*
*/
void bs_test_task(void* arg);
#ifdef __cplusplus #ifdef __cplusplus
} /*extern "C"*/ } /*extern "C"*/
#endif #endif

View File

@ -35,11 +35,11 @@ fonts/ui_font_homeText_1.c
fonts/ui_font_LenovoHTC.c fonts/ui_font_LenovoHTC.c
fonts/ui_font_MiSansB40.c fonts/ui_font_MiSansB40.c
fonts/ui_font_MiSansM.c fonts/ui_font_MiSansM.c
fonts/ui_font_MisansM10.c
fonts/ui_font_MiSansN.c fonts/ui_font_MiSansN.c
fonts/ui_font_MiSansN14.c fonts/ui_font_MiSansN14.c
fonts/ui_font_symbols16.c fonts/ui_font_symbols16.c
fonts/ui_font_symbolsalibaba.c fonts/ui_font_symbolsalibaba.c
fonts/ui_font_MisansM10.c
ui_event_wifi.c ui_event_wifi.c
ui_event_debug.c ui_event_debug.c
ui_event_light.c ui_event_light.c

View File

@ -35,8 +35,8 @@ fonts/ui_font_homeText_1.c
fonts/ui_font_LenovoHTC.c fonts/ui_font_LenovoHTC.c
fonts/ui_font_MiSansB40.c fonts/ui_font_MiSansB40.c
fonts/ui_font_MiSansM.c fonts/ui_font_MiSansM.c
fonts/ui_font_MisansM10.c
fonts/ui_font_MiSansN.c fonts/ui_font_MiSansN.c
fonts/ui_font_MiSansN14.c fonts/ui_font_MiSansN14.c
fonts/ui_font_symbols16.c fonts/ui_font_symbols16.c
fonts/ui_font_symbolsalibaba.c fonts/ui_font_symbolsalibaba.c
fonts/ui_font_MisansM10.c

View File

@ -673,7 +673,7 @@ void ui_pageHome_screen_init(void)
lv_obj_set_y(ui_pageHome_labelBSInfo, 62); lv_obj_set_y(ui_pageHome_labelBSInfo, 62);
lv_obj_set_align(ui_pageHome_labelBSInfo, LV_ALIGN_CENTER); lv_obj_set_align(ui_pageHome_labelBSInfo, LV_ALIGN_CENTER);
lv_label_set_text(ui_pageHome_labelBSInfo, "Start testing at 15BPM"); lv_label_set_text(ui_pageHome_labelBSInfo, "Start testing at 15BPM");
lv_obj_set_style_text_font(ui_pageHome_labelBSInfo, &ui_font_MisansM10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_font(ui_pageHome_labelBSInfo, &lv_font_montserrat_12, LV_PART_MAIN | LV_STATE_DEFAULT);
ui_pageHome_labelstr23 = lv_label_create(ui_pageHome_panelResult1); ui_pageHome_labelstr23 = lv_label_create(ui_pageHome_panelResult1);
lv_obj_set_width(ui_pageHome_labelstr23, LV_SIZE_CONTENT); /// 1 lv_obj_set_width(ui_pageHome_labelstr23, LV_SIZE_CONTENT); /// 1

View File

@ -458,11 +458,11 @@ LV_FONT_DECLARE(ui_font_homeText_1);
LV_FONT_DECLARE(ui_font_LenovoHTC); LV_FONT_DECLARE(ui_font_LenovoHTC);
LV_FONT_DECLARE(ui_font_MiSansB40); LV_FONT_DECLARE(ui_font_MiSansB40);
LV_FONT_DECLARE(ui_font_MiSansM); LV_FONT_DECLARE(ui_font_MiSansM);
LV_FONT_DECLARE(ui_font_MisansM10);
LV_FONT_DECLARE(ui_font_MiSansN); LV_FONT_DECLARE(ui_font_MiSansN);
LV_FONT_DECLARE(ui_font_MiSansN14); LV_FONT_DECLARE(ui_font_MiSansN14);
LV_FONT_DECLARE(ui_font_symbols16); LV_FONT_DECLARE(ui_font_symbols16);
LV_FONT_DECLARE(ui_font_symbolsalibaba); LV_FONT_DECLARE(ui_font_symbolsalibaba);
LV_FONT_DECLARE(ui_font_MisansM10);
// UI INIT // UI INIT
void ui_init(void); void ui_init(void);

View File

@ -430,26 +430,109 @@ static void comulate_result_read(lv_timer_t * timer)
} }
/** /**
* @brief BS界面设备类型选择响应函 * @brief
* *
* *
* 1.Home界面显示设备类型 *
* 2.
* *
* 3. * @param[in] timer not used
* 4.
*
* @param[in] e not used
*/ */
void on_buttonStartTestBS_clicked(lv_event_t * e) static void bs_test_timer_func(lv_timer_t * timer)
{ {
ESP_LOGI("bs_test_timer_func","bs_test_timer_func");
/* 显示测试成功 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[3]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[4]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[5]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[1]);
vTaskDelay(4000/portTICK_PERIOD_MS);
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[2]);
ESP_LOGI("bs_test_timer_func","bs_test_timer_func end");
} }
/** /**
* @brief BS界面 BS测试 * @brief BS界面 BS测试
* *
* *
* 1.15BPM测试时间
* 2.
* 3.
* 4.
*
* @param[in] e not used
*/
void on_buttonStartTestBS_clicked(lv_event_t * e)
{
/* 设置15BPM测试时间 */
uint8_t bytes[4];
float time = 40.0;
memcpy(bytes, &time, 4);
/* 下发命令 */
flux_frame.ADDR = FLUX_ADDR;
flux_frame.FUNC = FLUX_FUNC_SET_SINGLE;
flux_frame.DATA[0] = 0x00;
flux_frame.DATA[1] = 0x02;
flux_frame.DATA[2] = bytes[3];
flux_frame.DATA[3] = bytes[2];
/* 下发15BPM测试时间指令*/
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
/* 屏幕中显示下发成功 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[0]);
/* 下发启动测试指令 */
flux_frame_start.ADDR = FLUX_ADDR;
flux_frame_start.FUNC = FLUX_FUNC_SET_SINGLE;
flux_frame_start.DATA[0] = 0x00;
flux_frame_start.DATA[1] = 0x01;
flux_frame_start.DATA[2] = 0x00;
flux_frame_start.DATA[3] = 0x01;
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame_start));
/* 屏幕中显示下发成功 */
lv_label_set_text(ui_pageHome_labelBSInfo,test_info[1]);
#if 0
/* 创建定时器 */
lv_timer_t * bsTestTimer;
/* 创建定时器调用函数 */
bsTestTimer = lv_timer_create(bs_test_timer_func, 4*1000, NULL);
lv_timer_set_period(bsTestTimer, 4*1000);
lv_timer_set_repeat_count(bsTestTimer, 1);
/* 开启定时器 */
lv_timer_enable(bsTestTimer);
/* 显示正在测试中 */
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");
}
/**
* @brief BS界面设备类型选择响应函数
*
*
* 1.Home界面显示设备类型 * 1.Home界面显示设备类型
* 2. * 2.
* 3. * 3.