2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file ui_event_debug.c
|
|
|
|
|
|
* @brief 此文件中专门实现Debug过程中的事件的处理
|
|
|
|
|
|
*
|
|
|
|
|
|
* 仅仅Debug模式下运行
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author wang xiang en
|
|
|
|
|
|
* @date 2025-04-19
|
|
|
|
|
|
* @version 版本号
|
|
|
|
|
|
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
#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"
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/* 选择是否使能Debug页面的操作 */
|
2025-03-27 14:57:30 +08:00
|
|
|
|
#define MODE_TEST 0
|
2025-03-25 11:15:34 +08:00
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 流量读取按键按下事件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 流量计当前示数回传函数——Debug模式
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
void on_buttonFluxRead_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
/*选择是否使用Debug中的操作*/
|
|
|
|
|
|
#if MODE_TEST
|
2025-03-26 18:59:32 +08:00
|
|
|
|
flux_frame.DATA[1] = (unsigned char)lv_spinbox_get_value(ui_pageFluxDebug_spinboxAddr);
|
|
|
|
|
|
flux_frame.DATA[3] = (unsigned char)lv_spinbox_get_value(ui_pageFluxDebug_spinboxNum);
|
2025-03-25 11:15:34 +08:00
|
|
|
|
|
|
|
|
|
|
/*测试模式可手动设置功能码*/
|
2025-03-26 18:59:32 +08:00
|
|
|
|
if (lv_dropdown_get_selected(ui_pageFluxDebug_dropdownFunctionCode) == 0)
|
2025-03-25 11:15:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 清空文本域事件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 清空文本域
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-25 11:15:34 +08:00
|
|
|
|
void on_buttonClearTextarea_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
2025-03-27 14:57:30 +08:00
|
|
|
|
#if MODE_TEST
|
2025-03-26 18:59:32 +08:00
|
|
|
|
lv_textarea_set_text(ui_pageFluxDebug_textAreaContent, "");
|
2025-03-27 14:57:30 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-19 10:40:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 获取当前北京时间事件
|
|
|
|
|
|
*
|
|
|
|
|
|
* 获取当前北京时间
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] e not used
|
|
|
|
|
|
*/
|
2025-03-27 14:57:30 +08:00
|
|
|
|
void on_buttonGetTime_clicked(lv_event_t * e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#if MODE_TEST
|
|
|
|
|
|
/*获取当前北京时间*/
|
|
|
|
|
|
/*当WiFi开启时进行时间获取*/
|
|
|
|
|
|
|
|
|
|
|
|
char strftime_buf[64];
|
|
|
|
|
|
|
|
|
|
|
|
time_t now = 0;
|
|
|
|
|
|
struct tm timeinfo = {0};
|
|
|
|
|
|
|
|
|
|
|
|
int retry = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while(timeinfo.tm_year < (2022 - 1900)) {
|
|
|
|
|
|
ESP_LOGI("SNTP","Waiting for system time to be set... (%d)", ++retry);
|
|
|
|
|
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
|
|
|
|
time(&now);
|
|
|
|
|
|
localtime_r(&now, &timeinfo);
|
|
|
|
|
|
|
|
|
|
|
|
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
|
|
|
|
|
|
|
|
|
|
|
ESP_LOGI("SNTP","The current date/time in China is: %s", strftime_buf);
|
|
|
|
|
|
|
|
|
|
|
|
if (retry == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
|
|
|
|
|
|
|
|
|
|
|
ESP_LOGI("SNTP","The current date/time in China is: %s", strftime_buf);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2025-03-25 11:15:34 +08:00
|
|
|
|
}
|