将事件管理函数进行了拆分,测试没有问题的程序。
This commit is contained in:
parent
2be5520593
commit
b82ade17b0
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -34,6 +34,7 @@
|
|||||||
"main.h": "cpp",
|
"main.h": "cpp",
|
||||||
"fluxdisplayport.h": "c",
|
"fluxdisplayport.h": "c",
|
||||||
"esp_lcd_panel_vendor.h": "c",
|
"esp_lcd_panel_vendor.h": "c",
|
||||||
"float.h": "c"
|
"float.h": "c",
|
||||||
|
"esp_log.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,8 @@ 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
|
||||||
|
ui_event_wifi.c
|
||||||
|
ui_event_debug.c
|
||||||
)
|
)
|
||||||
|
|
||||||
idf_component_register(SRCS ${SOURCES}
|
idf_component_register(SRCS ${SOURCES}
|
||||||
|
|||||||
51
components/FluxUI/ui_event_debug.c
Normal file
51
components/FluxUI/ui_event_debug.c
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*此文件中专门实现Debug过程中的事件的处理*/
|
||||||
|
|
||||||
|
// This file was generated by SquareLine Studio
|
||||||
|
// SquareLine Studio version: SquareLine Studio 1.5.1
|
||||||
|
// LVGL version: 8.3.6
|
||||||
|
// Project name: ESP32S3_UI
|
||||||
|
|
||||||
|
#include "ui.h"
|
||||||
|
#include "driver/ledc.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include "FluxWifi.h"
|
||||||
|
#include "FluxUart.h"
|
||||||
|
#include "FluxSD.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "FluxProtocol.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*选择是否使能Debug页面的操作*/
|
||||||
|
#define MODE_TEST 0
|
||||||
|
|
||||||
|
/*流量计当前示数回传函数——Debug模式*/
|
||||||
|
void on_buttonFluxRead_clicked(lv_event_t * e)
|
||||||
|
{
|
||||||
|
/*选择是否使用Debug中的操作*/
|
||||||
|
#if MODE_TEST
|
||||||
|
flux_frame.DATA[1] = (unsigned char)lv_spinbox_get_value(ui_pageDebug_spinboxAddr);
|
||||||
|
flux_frame.DATA[3] = (unsigned char)lv_spinbox_get_value(ui_pageDebug_spinboxNum);
|
||||||
|
|
||||||
|
/*测试模式可手动设置功能码*/
|
||||||
|
if (lv_dropdown_get_selected(ui_pageDebug_dropdownFunctionCode) == 0)
|
||||||
|
{
|
||||||
|
flux_frame.FUNC = FLUX_FUNC_READ;
|
||||||
|
}else{
|
||||||
|
flux_frame.FUNC = FLUX_FUNC_SET;
|
||||||
|
}
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*流量计当前示数显示——Debug模式*/
|
||||||
|
void on_buttonClearTextarea_clicked(lv_event_t * e)
|
||||||
|
{
|
||||||
|
#if MODE_TEST
|
||||||
|
lv_textarea_set_text(ui_pageDebug_textAreaContent, "");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
100
components/FluxUI/ui_event_wifi.c
Normal file
100
components/FluxUI/ui_event_wifi.c
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
|
||||||
|
/*此文件中专门实现WIFI事件的处理*/
|
||||||
|
|
||||||
|
// This file was generated by SquareLine Studio
|
||||||
|
// SquareLine Studio version: SquareLine Studio 1.5.1
|
||||||
|
// LVGL version: 8.3.6
|
||||||
|
// Project name: ESP32S3_UI
|
||||||
|
|
||||||
|
#include "ui.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#include "FluxWifi.h"
|
||||||
|
#include "FluxUart.h"
|
||||||
|
#include "FluxSD.h"
|
||||||
|
|
||||||
|
|
||||||
|
/************************************ WIFI调节函数 ******************************************* */
|
||||||
|
|
||||||
|
/*wifi搜索回调函数*/
|
||||||
|
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
||||||
|
{
|
||||||
|
wifi_scan();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*WiFi连接选项修改回调函数*/
|
||||||
|
void on_dropDownWifiName_valueChanged(lv_event_t * e)
|
||||||
|
{
|
||||||
|
// Your code here
|
||||||
|
int currentIndex=0;
|
||||||
|
|
||||||
|
currentIndex = lv_dropdown_get_selected(e->target);
|
||||||
|
|
||||||
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelRssi, "RSSI:%d dBm ", ap_info[currentIndex].rssi);
|
||||||
|
lv_label_set_text_fmt(ui_pageWifiConnect_labelConnectWifi,"connect to %s",ap_info[currentIndex].ssid);
|
||||||
|
|
||||||
|
if (strcmp((char*)ap_info[currentIndex].ssid,"yuwell")==0)
|
||||||
|
{
|
||||||
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "yuwell123456");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*WIFI连接按键按下回调函数*/
|
||||||
|
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
||||||
|
{
|
||||||
|
if(strcmp(lv_label_get_text(ui_pageWifiConnect_labelConnectWifi),"disconnect") == 0 )
|
||||||
|
{
|
||||||
|
esp_wifi_disconnect();
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_stop());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentIndex=0;
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_stop());
|
||||||
|
currentIndex = lv_dropdown_get_selected(ui_pageWifiConnect_dropdownWifiName);
|
||||||
|
|
||||||
|
|
||||||
|
// Your code here
|
||||||
|
wifi_config_t wifi_config = {
|
||||||
|
.sta = {
|
||||||
|
.ssid = "yuwell",
|
||||||
|
.password = "yuwell123456",
|
||||||
|
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8).
|
||||||
|
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
||||||
|
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
||||||
|
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
||||||
|
*/
|
||||||
|
.threshold = {
|
||||||
|
.authmode = ap_info[currentIndex].authmode,
|
||||||
|
},
|
||||||
|
.sae_pwe_h2e = WPA3_SAE_PWE_BOTH,
|
||||||
|
.sae_h2e_identifier = "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
lv_dropdown_get_selected_str(ui_pageWifiConnect_dropdownWifiName,(char*)wifi_config.sta.ssid,32);
|
||||||
|
|
||||||
|
strncpy((char*)wifi_config.sta.password,lv_textarea_get_text(ui_pageWifiConnect_textAreaWifiPassword),64);
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||||
|
ESP_LOGI("TAG", "wifi_init_sta finished.");
|
||||||
|
|
||||||
|
esp_wifi_connect();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*WIFI密码清空按键按下回调函数*/
|
||||||
|
void on_buttonClearPassword_clicked(lv_event_t * e)
|
||||||
|
{
|
||||||
|
// Your code here
|
||||||
|
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "");
|
||||||
|
}
|
||||||
@ -18,29 +18,22 @@
|
|||||||
|
|
||||||
#include "FluxProtocol.h"
|
#include "FluxProtocol.h"
|
||||||
|
|
||||||
/*选择是否使能Debug页面的操作*/
|
|
||||||
#define MODE_TEST 0
|
|
||||||
|
|
||||||
#define LOWERST_LIGHT_LEVEL (7222)
|
#define LOWERST_LIGHT_LEVEL (7222)
|
||||||
|
|
||||||
#define RESULT_RIGHT lv_obj_set_style_bg_color(ui_pageHome_panelTestResult,lv_color_hex(0x00FF00),LV_PART_MAIN);\
|
|
||||||
lv_label_set_text(ui_pageHome_labelTestResult,"V");
|
|
||||||
|
|
||||||
#define RESULT_FAULT lv_obj_set_style_bg_color(ui_pageHome_panelTestResult,lv_color_hex(0xFF0000),LV_PART_MAIN);\
|
|
||||||
lv_label_set_text(ui_pageHome_labelTestResult,"X");
|
|
||||||
|
|
||||||
/*更新当前测试标准*/
|
/*更新当前测试标准*/
|
||||||
static void standardVolumeRefresh(void);
|
static void standardVolumeRefresh(void);
|
||||||
/*根据呼吸频率调整积分时间*/
|
/*根据呼吸频率调整积分时间*/
|
||||||
void comulateTimeSend(void);
|
static void comulateTimeSend(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*亮度调节回调函数*/
|
/*亮度调节回调函数*/
|
||||||
void on_sliderLight_valueChanged(lv_event_t * e)
|
void on_sliderLight_valueChanged(lv_event_t * e)
|
||||||
{
|
{
|
||||||
// Your code here
|
|
||||||
// Your code here
|
|
||||||
uint32_t value = 8192-lv_slider_get_value(e->target);
|
uint32_t value = 8192-lv_slider_get_value(e->target);
|
||||||
//ESP_LOGI("lightSliderCallback", "value = %u", value);
|
|
||||||
if (value>LOWERST_LIGHT_LEVEL)
|
if (value>LOWERST_LIGHT_LEVEL)
|
||||||
{
|
{
|
||||||
value = LOWERST_LIGHT_LEVEL;
|
value = LOWERST_LIGHT_LEVEL;
|
||||||
@ -89,87 +82,6 @@ void on_buttonReadSDCard_clicked(lv_event_t * e)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************ WIFI调节函数 ******************************************* */
|
|
||||||
/*wifi搜索回调函数*/
|
|
||||||
void on_buttonSearchWifi_clicked(lv_event_t * e)
|
|
||||||
{
|
|
||||||
wifi_scan();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*WiFi连接选项修改回调函数*/
|
|
||||||
void on_dropDownWifiName_valueChanged(lv_event_t * e)
|
|
||||||
{
|
|
||||||
// Your code here
|
|
||||||
int currentIndex=0;
|
|
||||||
|
|
||||||
currentIndex = lv_dropdown_get_selected(e->target);
|
|
||||||
|
|
||||||
lv_label_set_text_fmt(ui_pageWifiConnect_labelRssi, "RSSI:%d dBm ", ap_info[currentIndex].rssi);
|
|
||||||
lv_label_set_text_fmt(ui_pageWifiConnect_labelConnectWifi,"connect to %s",ap_info[currentIndex].ssid);
|
|
||||||
|
|
||||||
if (strcmp((char*)ap_info[currentIndex].ssid,"yuwell")==0)
|
|
||||||
{
|
|
||||||
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "yuwell123456");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*WIFI连接按键按下回调函数*/
|
|
||||||
void on_buttonConnectWifi_clicked(lv_event_t * e)
|
|
||||||
{
|
|
||||||
if(strcmp(lv_label_get_text(ui_pageWifiConnect_labelConnectWifi),"disconnect") == 0 )
|
|
||||||
{
|
|
||||||
esp_wifi_disconnect();
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_stop());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentIndex=0;
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_stop());
|
|
||||||
currentIndex = lv_dropdown_get_selected(ui_pageWifiConnect_dropdownWifiName);
|
|
||||||
|
|
||||||
|
|
||||||
// Your code here
|
|
||||||
wifi_config_t wifi_config = {
|
|
||||||
.sta = {
|
|
||||||
.ssid = "yuwell",
|
|
||||||
.password = "yuwell123456",
|
|
||||||
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (password len => 8).
|
|
||||||
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
|
||||||
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
|
||||||
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
|
||||||
*/
|
|
||||||
.threshold = {
|
|
||||||
.authmode = ap_info[currentIndex].authmode,
|
|
||||||
},
|
|
||||||
.sae_pwe_h2e = WPA3_SAE_PWE_BOTH,
|
|
||||||
.sae_h2e_identifier = "",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
lv_dropdown_get_selected_str(ui_pageWifiConnect_dropdownWifiName,(char*)wifi_config.sta.ssid,32);
|
|
||||||
|
|
||||||
strncpy((char*)wifi_config.sta.password,lv_textarea_get_text(ui_pageWifiConnect_textAreaWifiPassword),64);
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_start() );
|
|
||||||
ESP_LOGI("TAG", "wifi_init_sta finished.");
|
|
||||||
|
|
||||||
esp_wifi_connect();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*WIFI密码清空按键按下回调函数*/
|
|
||||||
void on_buttonClearPassword_clicked(lv_event_t * e)
|
|
||||||
{
|
|
||||||
// Your code here
|
|
||||||
lv_textarea_set_text(ui_pageWifiConnect_textAreaWifiPassword, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/************************************ 测试流程函数 ******************************************* */
|
/************************************ 测试流程函数 ******************************************* */
|
||||||
/*pageHome 开始测试按键按下回调函数*/
|
/*pageHome 开始测试按键按下回调函数*/
|
||||||
@ -178,8 +90,8 @@ void on_buttonStartTest_clicked(lv_event_t * e)
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*下发积分时间*/
|
/*下发积分时间*/
|
||||||
comulateTimeSend();
|
//comulateTimeSend();
|
||||||
|
#if 0
|
||||||
/*使用0306报文格式*/
|
/*使用0306报文格式*/
|
||||||
uint8_t bytes[4];
|
uint8_t bytes[4];
|
||||||
float time = (float)lv_spinbox_get_value(ui_pageFluxRead_spinboxTime);
|
float time = (float)lv_spinbox_get_value(ui_pageFluxRead_spinboxTime);
|
||||||
@ -195,13 +107,13 @@ void on_buttonStartTest_clicked(lv_event_t * e)
|
|||||||
flux_frame.DATA[3] = bytes[2];
|
flux_frame.DATA[3] = bytes[2];
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
||||||
|
#endif
|
||||||
|
|
||||||
timeS = lv_spinbox_get_value(ui_pageFluxRead_spinboxTime);
|
timeS = lv_spinbox_get_value(ui_pageFluxRead_spinboxTime);
|
||||||
|
|
||||||
/*下发启动测试指令*/
|
/*下发启动测试指令*/
|
||||||
FLUX_TEST_START;
|
FLUX_TEST_START;
|
||||||
|
|
||||||
#if 1
|
|
||||||
lv_label_set_text(ui_pageHome_labelStartTest,"Testing...");
|
lv_label_set_text(ui_pageHome_labelStartTest,"Testing...");
|
||||||
|
|
||||||
vTaskDelay(timeS*1000/portTICK_PERIOD_MS);
|
vTaskDelay(timeS*1000/portTICK_PERIOD_MS);
|
||||||
@ -209,37 +121,6 @@ void on_buttonStartTest_clicked(lv_event_t * e)
|
|||||||
lv_event_send(ui_pageFluxRead_buttonReadFlux,LV_EVENT_CLICKED,NULL);
|
lv_event_send(ui_pageFluxRead_buttonReadFlux,LV_EVENT_CLICKED,NULL);
|
||||||
|
|
||||||
lv_label_set_text(ui_pageHome_labelStartTest,"Test Complete!");
|
lv_label_set_text(ui_pageHome_labelStartTest,"Test Complete!");
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*流量计当前示数回传函数——Debug模式*/
|
|
||||||
void on_buttonFluxRead_clicked(lv_event_t * e)
|
|
||||||
{
|
|
||||||
/*选择是否使用Debug中的操作*/
|
|
||||||
#if MODE_TEST
|
|
||||||
flux_frame.DATA[1] = (unsigned char)lv_spinbox_get_value(ui_pageDebug_spinboxAddr);
|
|
||||||
flux_frame.DATA[3] = (unsigned char)lv_spinbox_get_value(ui_pageDebug_spinboxNum);
|
|
||||||
|
|
||||||
/*测试模式可手动设置功能码*/
|
|
||||||
if (lv_dropdown_get_selected(ui_pageDebug_dropdownFunctionCode) == 0)
|
|
||||||
{
|
|
||||||
flux_frame.FUNC = FLUX_FUNC_READ;
|
|
||||||
}else{
|
|
||||||
flux_frame.FUNC = FLUX_FUNC_SET;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*流量计当前示数显示—Debug模式*/
|
|
||||||
void on_buttonClearTextarea_clicked(lv_event_t * e)
|
|
||||||
{
|
|
||||||
#if MODE_TEST
|
|
||||||
lv_textarea_set_text(ui_pageDebug_textAreaContent, "");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -270,12 +151,11 @@ void on_spinboxStage_valueChanged(lv_event_t * e)
|
|||||||
|
|
||||||
|
|
||||||
/*pageHome 频率值改变*/
|
/*pageHome 频率值改变*/
|
||||||
int32_t Ratevalue = 0;
|
|
||||||
void on_spinboxRate_valueChanged(lv_event_t * e)
|
void on_spinboxRate_valueChanged(lv_event_t * e)
|
||||||
{
|
{
|
||||||
/*更改下方测试结果部分的频率信息*/
|
/*更改下方测试结果部分的频率信息*/
|
||||||
Ratevalue = lv_spinbox_get_value(e->target);
|
FluxMachineData.breathRate = lv_spinbox_get_value(e->target);
|
||||||
lv_label_set_text_fmt(ui_pageHome_labelResultRate,"%ld",Ratevalue);
|
lv_label_set_text_fmt(ui_pageHome_labelResultRate,"%ld",FluxMachineData.breathRate);
|
||||||
|
|
||||||
/*刷新标准体积数据*/
|
/*刷新标准体积数据*/
|
||||||
standardVolumeRefresh();
|
standardVolumeRefresh();
|
||||||
@ -411,31 +291,18 @@ void on_spinboxTime_valueChanged(lv_event_t * e)
|
|||||||
/*启动流量计*/
|
/*启动流量计*/
|
||||||
void on_buttonFluxStart_clicked(lv_event_t * e)
|
void on_buttonFluxStart_clicked(lv_event_t * e)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
/*下发启动命令*/
|
|
||||||
flux_frame.ADDR = FLUX_ADDR;
|
|
||||||
flux_frame.FUNC = FLUX_FUNC_SET_SINGLE;
|
|
||||||
|
|
||||||
flux_frame.DATA[0] = 0x00;
|
|
||||||
flux_frame.DATA[1] = 0x01;
|
|
||||||
flux_frame.DATA[2] = 0x00;
|
|
||||||
flux_frame.DATA[3] = 0x01;
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
|
||||||
#elif 1
|
|
||||||
FLUX_TEST_START;
|
FLUX_TEST_START;
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*根据spinbox中的值下发积分时间*/
|
/*根据spinbox中的值下发积分时间*/
|
||||||
void comulateTimeSend(void)
|
/*注意:此处修改了spinboxTime 的值,不可以在spinboxTime_valueChanged中调用!!*/
|
||||||
|
static void comulateTimeSend(void)
|
||||||
{
|
{
|
||||||
/*获取当前呼吸频率*/
|
/*获取当前呼吸频率*/
|
||||||
Ratevalue = lv_spinbox_get_value(ui_pageHome_spinboxRate);
|
FluxMachineData.breathRate = lv_spinbox_get_value(ui_pageHome_spinboxRate);
|
||||||
|
|
||||||
switch (Ratevalue)
|
switch (FluxMachineData.breathRate)
|
||||||
{
|
{
|
||||||
case 15:
|
case 15:
|
||||||
/*呼吸频率为15BPM时,积分时间设定为40秒*/
|
/*呼吸频率为15BPM时,积分时间设定为40秒*/
|
||||||
@ -466,21 +333,4 @@ void comulateTimeSend(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*使用0306报文格式*/
|
|
||||||
uint8_t bytes[4];
|
|
||||||
float time = (float)lv_spinbox_get_value(ui_pageFluxRead_spinboxTime);
|
|
||||||
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];
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@ -16,6 +16,12 @@ struct ModbusRTU_Frame flux_frame_start;
|
|||||||
struct ModbusRTU_Frame2Reg flux_frame2Reg;
|
struct ModbusRTU_Frame2Reg flux_frame2Reg;
|
||||||
|
|
||||||
|
|
||||||
|
#define RESULT_RIGHT lv_obj_set_style_bg_color(ui_pageHome_panelTestResult,lv_color_hex(0x00FF00),LV_PART_MAIN);\
|
||||||
|
lv_label_set_text(ui_pageHome_labelTestResult,"V");
|
||||||
|
|
||||||
|
#define RESULT_FAULT lv_obj_set_style_bg_color(ui_pageHome_panelTestResult,lv_color_hex(0xFF0000),LV_PART_MAIN);\
|
||||||
|
lv_label_set_text(ui_pageHome_labelTestResult,"X");
|
||||||
|
|
||||||
const unsigned char chCRCHTalbe[] =
|
const unsigned char chCRCHTalbe[] =
|
||||||
{
|
{
|
||||||
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
|
||||||
@ -134,7 +140,6 @@ void uart1_echoTask(void* arg)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
|
||||||
// Read data from the UART
|
// Read data from the UART
|
||||||
@ -146,8 +151,7 @@ void uart1_echoTask(void* arg)
|
|||||||
if (len)
|
if (len)
|
||||||
{
|
{
|
||||||
data[len] = '\0';
|
data[len] = '\0';
|
||||||
|
|
||||||
//ESP_LOGI(TAG, "Recv str: %s", (char *) data);
|
|
||||||
for(int i=0;i<len;i++)
|
for(int i=0;i<len;i++)
|
||||||
ESP_LOGI(TAG, "data[%d]:%02X", i, data[i]);
|
ESP_LOGI(TAG, "data[%d]:%02X", i, data[i]);
|
||||||
|
|
||||||
@ -156,33 +160,6 @@ void uart1_echoTask(void* arg)
|
|||||||
{
|
{
|
||||||
/*测试已完成*/
|
/*测试已完成*/
|
||||||
lv_obj_add_state(ui_pageFluxRead_checkboxUnfinished,LV_STATE_CHECKED);
|
lv_obj_add_state(ui_pageFluxRead_checkboxUnfinished,LV_STATE_CHECKED);
|
||||||
/* 解析数据*/
|
|
||||||
#if 0
|
|
||||||
/*获取当前工作模式*/
|
|
||||||
FluxMachineData.workMode = (enum FluxMachineWorkMode)data[4];
|
|
||||||
switch (FluxMachineData.workMode)
|
|
||||||
{
|
|
||||||
case FLUX_MODE_NORMAL:
|
|
||||||
lv_label_set_text(ui_pageFluxRead_labelWorkMode,"Normal");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLUX_MODE_TIMER:
|
|
||||||
lv_label_set_text(ui_pageFluxRead_labelWorkMode,"Timer");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLUX_MODE_VOLUME:
|
|
||||||
lv_label_set_text(ui_pageFluxRead_labelWorkMode,"Volume");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLUX_MODE_REV:
|
|
||||||
lv_label_set_text(ui_pageFluxRead_labelWorkMode,"Rev");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
lv_label_set_text(ui_pageFluxRead_labelWorkMode,"Error");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*获取定时模式的时间*/
|
/*获取定时模式的时间*/
|
||||||
bytes[0] = data[10];
|
bytes[0] = data[10];
|
||||||
@ -281,11 +258,13 @@ esp_err_t ModbusRTU_Send_0306(uart_port_t uart_num, struct ModbusRTU_Frame *fram
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
sprintf(text,"%02X %02X %02X %02X %02X %02X %02X %02X \n",frame->ADDR,frame->FUNC,frame->DATA[0],frame->DATA[1],frame->DATA[2],frame->DATA[3],frame->CRC[0],frame->CRC[1]);
|
sprintf(text,"%02X %02X %02X %02X %02X %02X %02X %02X \n",frame->ADDR,frame->FUNC,frame->DATA[0],frame->DATA[1],frame->DATA[2],frame->DATA[3],frame->CRC[0],frame->CRC[1]);
|
||||||
|
|
||||||
lv_textarea_add_char(ui_pageDebug_textAreaContent,'\n');
|
lv_textarea_add_char(ui_pageDebug_textAreaContent,'\n');
|
||||||
lv_textarea_add_text(ui_pageDebug_textAreaContent,"Send:");
|
lv_textarea_add_text(ui_pageDebug_textAreaContent,"Send:");
|
||||||
lv_textarea_add_text(ui_pageDebug_textAreaContent,(char*)text);
|
lv_textarea_add_text(ui_pageDebug_textAreaContent,(char*)text);
|
||||||
|
#endif
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@ -331,11 +310,17 @@ esp_err_t RefreshResult(void)
|
|||||||
/*根据测试结果判断是否合格*/
|
/*根据测试结果判断是否合格*/
|
||||||
if (breathVolume > testVolumeUpper || breathVolume < testVolumeLower)
|
if (breathVolume > testVolumeUpper || breathVolume < testVolumeLower)
|
||||||
{
|
{
|
||||||
lv_label_set_text(ui_pageHome_labelTestResult,"X");
|
RESULT_FAULT;
|
||||||
lv_obj_set_style_bg_color(ui_pageHome_panelTestResult, lv_color_hex(0xFF0000), LV_PART_MAIN);
|
if (breathVolume > testVolumeUpper )
|
||||||
|
{
|
||||||
|
lv_label_set_text(ui_pageHome_labelResultCompare,"High");
|
||||||
|
}else if (breathVolume < testVolumeLower)
|
||||||
|
{
|
||||||
|
lv_label_set_text(ui_pageHome_labelResultCompare,"Low");
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
lv_label_set_text(ui_pageHome_labelTestResult,"V");
|
RESULT_RIGHT;
|
||||||
lv_obj_set_style_bg_color(ui_pageHome_panelTestResult, lv_color_hex(0x00FF00), LV_PART_MAIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|||||||
@ -43,7 +43,15 @@ extern "C" {
|
|||||||
#define FLUX_FUNC_SET_SINGLE 0x06
|
#define FLUX_FUNC_SET_SINGLE 0x06
|
||||||
|
|
||||||
|
|
||||||
#define FLUX_TEST_START ESP_ERROR_CHECK(ModbusRTU_Send_0306(ECHO_UART_PORT_NUM1,&flux_frame_start));
|
#define FLUX_TEST_START 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));\
|
||||||
|
ESP_LOGI("FLUX_TEST_START","send start");
|
||||||
|
|
||||||
/* Modbus-RTU frame format */
|
/* Modbus-RTU frame format */
|
||||||
/* All data from the wet flow meter are two bytes long */
|
/* All data from the wet flow meter are two bytes long */
|
||||||
@ -81,7 +89,7 @@ struct ModbusRTU_Frame2Reg
|
|||||||
extern struct ModbusRTU_Frame2Reg flux_frame2Reg;
|
extern struct ModbusRTU_Frame2Reg flux_frame2Reg;
|
||||||
|
|
||||||
/*定义工作模式*/
|
/*定义工作模式*/
|
||||||
typedef enum FluxMachineWorkMode{
|
enum FluxMachineWorkMode{
|
||||||
FLUX_MODE_NORMAL,
|
FLUX_MODE_NORMAL,
|
||||||
FLUX_MODE_TIMER,
|
FLUX_MODE_TIMER,
|
||||||
FLUX_MODE_VOLUME,
|
FLUX_MODE_VOLUME,
|
||||||
@ -96,6 +104,7 @@ struct FluxMachineData
|
|||||||
float rev;
|
float rev;
|
||||||
|
|
||||||
float breathTimes;
|
float breathTimes;
|
||||||
|
int32_t breathRate;
|
||||||
|
|
||||||
unsigned short finishFlag;
|
unsigned short finishFlag;
|
||||||
float liquidTemperature;
|
float liquidTemperature;
|
||||||
|
|||||||
@ -81,12 +81,10 @@ extern "C" void app_main(void)
|
|||||||
/*初始上电后需要自动触发的一些小事件来更新界面界面元素*/
|
/*初始上电后需要自动触发的一些小事件来更新界面界面元素*/
|
||||||
lv_textarea_set_text(ui_pageDebug_textAreaContent,"");
|
lv_textarea_set_text(ui_pageDebug_textAreaContent,"");
|
||||||
|
|
||||||
#if 1
|
|
||||||
lv_event_send(ui_pageSetting_dropdownDeviceType,LV_EVENT_VALUE_CHANGED,NULL);
|
lv_event_send(ui_pageSetting_dropdownDeviceType,LV_EVENT_VALUE_CHANGED,NULL);
|
||||||
|
|
||||||
lv_event_send(ui_pageHome_spinboxStage,LV_EVENT_VALUE_CHANGED,NULL);
|
lv_event_send(ui_pageHome_spinboxStage,LV_EVENT_VALUE_CHANGED,NULL);
|
||||||
lv_event_send(ui_pageHome_spinboxRate,LV_EVENT_VALUE_CHANGED,NULL);
|
lv_event_send(ui_pageHome_spinboxRate,LV_EVENT_VALUE_CHANGED,NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
lv_label_set_text(ui_pageHome_labelResultCompare,"");
|
lv_label_set_text(ui_pageHome_labelResultCompare,"");
|
||||||
lv_label_set_text(ui_pageHome_labelTestResult,"-");
|
lv_label_set_text(ui_pageHome_labelTestResult,"-");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user