From 25b8f6a19146e977590c4fbbbb3dbe0652b348dd Mon Sep 17 00:00:00 2001 From: ipason Date: Mon, 28 Apr 2025 17:49:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FluxDisplayPort/FluxDisplayPort.c | 20 ++++++++++++++------ components/FluxDisplayPort/FluxDisplayPort.h | 2 +- components/FluxSD/FluxSD.c | 8 ++++++-- components/FluxUI/ui_event_homePage.c | 10 ++++++++-- components/FluxUI/ui_event_light.c | 4 ++++ components/FluxUI/ui_event_wifi.c | 5 +++++ components/FluxUart/FluxUart.c | 4 ++-- main/main.cpp | 8 ++++---- sdkconfig | 11 ++++++++++- 9 files changed, 54 insertions(+), 18 deletions(-) diff --git a/components/FluxDisplayPort/FluxDisplayPort.c b/components/FluxDisplayPort/FluxDisplayPort.c index d17eb4b..f94af07 100644 --- a/components/FluxDisplayPort/FluxDisplayPort.c +++ b/components/FluxDisplayPort/FluxDisplayPort.c @@ -16,6 +16,10 @@ static esp_lcd_touch_handle_t tp = NULL; static SemaphoreHandle_t lvgl_mux = NULL; static const char *TAG = "LCD_Init"; +/* 用于初始化配置的全局变量 */ +static lv_disp_draw_buf_t disp_buf; // Contains internal graphic buffer(s) called draw buffer(s) +static lv_disp_drv_t disp_drv; // Contains callback functions + /** * @brief 通知LVGL库,屏幕已经更新 * @@ -166,6 +170,8 @@ static void example_lvgl_port_task(void *arg) static void example_init_i80_bus(esp_lcd_panel_io_handle_t *io_handle, void *user_ctx) { ESP_LOGI(TAG, "Initialize Intel 8080 bus"); + + /* 创建i80总线控制句柄 */ esp_lcd_i80_bus_handle_t i80_bus = NULL; esp_lcd_i80_bus_config_t bus_config = { .clk_src = LCD_CLK_SRC_DEFAULT, @@ -185,8 +191,10 @@ static void example_init_i80_bus(esp_lcd_panel_io_handle_t *io_handle, void *use .max_transfer_bytes = EXAMPLE_LCD_H_RES * 100 * sizeof(uint16_t), .dma_burst_size = EXAMPLE_DMA_BURST_SIZE, }; + /* 根据配置创建 i80总线控制句柄 */ ESP_ERROR_CHECK(esp_lcd_new_i80_bus(&bus_config, &i80_bus)); + /* 配置i80总线IO引脚 */ esp_lcd_panel_io_i80_config_t io_config = { .cs_gpio_num = EXAMPLE_PIN_NUM_CS, .pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ, @@ -289,10 +297,8 @@ static void example_init_touch_panel(void) */ void initialize_display_and_touch(void) { - static lv_disp_draw_buf_t disp_buf; // Contains internal graphic buffer(s) called draw buffer(s) - static lv_disp_drv_t disp_drv; // Contains callback functions -/* Check if the backlight pin is valid */ +/* 确定背光是否可用 */ #if EXAMPLE_PIN_NUM_BK_LIGHT >= 0 ESP_LOGI(TAG, "Turn off LCD backlight"); gpio_config_t bk_gpio_config = { @@ -300,13 +306,15 @@ void initialize_display_and_touch(void) .pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT }; ESP_ERROR_CHECK(gpio_config(&bk_gpio_config)); + /* 关闭LCD背光 */ gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL); #endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - /* Initialize i80 bus */ + /* 初始化i80总线 */ esp_lcd_panel_io_handle_t io_handle = NULL; example_init_i80_bus(&io_handle, &disp_drv); - /* Initialize lcd control panel */ + + /* 初始化LCD控制panel */ esp_lcd_panel_handle_t panel_handle = NULL; example_init_lcd_panel(io_handle, &panel_handle); @@ -322,7 +330,7 @@ void initialize_display_and_touch(void) //gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL); #endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - /* Place the initialization of the touch screen driver here */ + /* 初始化触摸屏 */ example_init_touch_panel(); ESP_LOGI(TAG, "Initialize LVGL library"); diff --git a/components/FluxDisplayPort/FluxDisplayPort.h b/components/FluxDisplayPort/FluxDisplayPort.h index 4f99d7f..6d0b02e 100644 --- a/components/FluxDisplayPort/FluxDisplayPort.h +++ b/components/FluxDisplayPort/FluxDisplayPort.h @@ -75,7 +75,7 @@ extern "C" { #define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500 #define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 1 #define EXAMPLE_LVGL_TASK_STACK_SIZE (16 * 1024) -#define EXAMPLE_LVGL_TASK_PRIORITY 2 +#define EXAMPLE_LVGL_TASK_PRIORITY 3 #define EXAMPLE_DMA_BURST_SIZE (64) diff --git a/components/FluxSD/FluxSD.c b/components/FluxSD/FluxSD.c index e9a7c2d..bea5149 100644 --- a/components/FluxSD/FluxSD.c +++ b/components/FluxSD/FluxSD.c @@ -127,11 +127,15 @@ static esp_err_t s_example_write_file(const char *path, char *data) * 向已定路径写入一段字符串 * * @param[in] data 要写入的数据 + * @param[in] file_name 文件名 + * @param[in] functionName 函数名 + * @param[in] taskName 任务名 + * @param[in] line_num 行号 + * @param[in] freeStack 空闲栈大小 + * @return 返回值说明 0:成功,其他:失败 */ esp_err_t example_write_log(char *data,char *file_name,char *functionName,char *taskName,uint16_t line_num,int32_t freeStack) { - ESP_LOGI(SD_TAG, "Opening file %s", sdData.log_file_dir); - FILE *f = fopen(sdData.log_file_dir, "a+"); if (f == NULL) { ESP_LOGE(SD_TAG, "Failed to open file for writing"); diff --git a/components/FluxUI/ui_event_homePage.c b/components/FluxUI/ui_event_homePage.c index 616fa7a..12988d4 100644 --- a/components/FluxUI/ui_event_homePage.c +++ b/components/FluxUI/ui_event_homePage.c @@ -120,6 +120,9 @@ void on_spinboxRate_valueChanged(lv_event_t * e) /* 更新SD卡中需要存储的频率数据 */ sdData.flux_test_result.current_rate = FluxMachineData.breathRate; +#if LOG_RECORD_ENABLE + WRITE_LOG_TO_SD("正常情况下呼吸频率更改切换"); +#endif } /** @@ -296,6 +299,9 @@ void on_spinboxStage_valueChanged(lv_event_t * e) /* 更新当前挡位数据 */ sdData.flux_test_result.current_stage = value; +#if LOG_RECORD_ENABLE + WRITE_LOG_TO_SD("正常情况下的挡位切换"); +#endif } /** @@ -571,10 +577,10 @@ void on_dropdown_deviceTypeBS_valueChanged(lv_event_t * e) /* 更新挡位显示范围 */ if (index == Spirit3) { - lv_spinbox_set_range(ui_pageHome_spinboxStage,1,4); + //lv_spinbox_set_range(ui_pageHome_spinboxStage,1,4); lv_spinbox_set_range(ui_pageHome_spinboxStageBS,1,4); }else{ - lv_spinbox_set_range(ui_pageHome_spinboxStage,1,6); + //lv_spinbox_set_range(ui_pageHome_spinboxStage,1,6); lv_spinbox_set_range(ui_pageHome_spinboxStageBS,1,6); } diff --git a/components/FluxUI/ui_event_light.c b/components/FluxUI/ui_event_light.c index 3e50ecd..a71a37d 100644 --- a/components/FluxUI/ui_event_light.c +++ b/components/FluxUI/ui_event_light.c @@ -31,4 +31,8 @@ void on_sliderLight_valueChanged(lv_event_t * e) // Update duty to apply the new value ESP_ERROR_CHECK(ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0)); + +#if LOG_RECORD_ENABLE + WRITE_LOG_TO_SD("修改亮度"); +#endif } diff --git a/components/FluxUI/ui_event_wifi.c b/components/FluxUI/ui_event_wifi.c index 8d56715..df04ca0 100644 --- a/components/FluxUI/ui_event_wifi.c +++ b/components/FluxUI/ui_event_wifi.c @@ -109,6 +109,11 @@ void on_buttonConnectWifi_clicked(lv_event_t * e) ESP_LOGI("TAG", "wifi_init_sta finished."); esp_wifi_connect(); + +#if LOG_RECORD_ENABLE + WRITE_LOG_TO_SD("进行Wifi连接"); +#endif + #endif } diff --git a/components/FluxUart/FluxUart.c b/components/FluxUart/FluxUart.c index b348471..75c5a23 100644 --- a/components/FluxUart/FluxUart.c +++ b/components/FluxUart/FluxUart.c @@ -357,7 +357,7 @@ void uart2_echoTask(void* arg) uint8_t *data = (uint8_t *) malloc(BUF_SIZE); - ESP_LOGI("uart2_echoTask", "UART2 ECHO TEST: start test"); + //ESP_LOGI("uart2_echoTask", "UART2 ECHO TEST: start test"); #if LOG_RECORD_ENABLE WRITE_LOG_TO_SD("呼吸模拟器消息处理任务初始化完毕") @@ -373,7 +373,7 @@ void uart2_echoTask(void* arg) // Write data back to the UART uart_write_bytes(ECHO_UART_PORT_NUM2, (const char *) data, len); - ESP_LOGI("uart2_echoTask", "Read %d bytes: '%s'", len, data); + //ESP_LOGI("uart2_echoTask", "Read %d bytes: '%s'", len, data); } } diff --git a/main/main.cpp b/main/main.cpp index 9ae6e93..8ad55e0 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -112,7 +112,7 @@ extern "C" void app_main(void) vTaskDelay(PROGRESS_DELAY_TIME/portTICK_PERIOD_MS); /*初始化电源管理系统*/ - xTaskCreate(power_management_task, "powerTask", 4 * 1024, NULL, 2, NULL); + xTaskCreate(power_management_task, "powerTask", 4 * 1024, NULL, 1, NULL); lv_bar_set_value(ui_pageWelCome_barStartProgress,50,LV_ANIM_ON); lv_label_set_text(ui_pageWelCome_labelStartInfo,"power management system 50%"); vTaskDelay(PROGRESS_DELAY_TIME/portTICK_PERIOD_MS); @@ -123,13 +123,13 @@ extern "C" void app_main(void) /*创建串口任务*/ /*创建UART1响应任务*/ - xTaskCreate(uart1_echoTask, "uart1_echo_task", 8*1024, NULL, 10, NULL); + xTaskCreate(uart1_echoTask, "uart1_echo_task", 8*1024, NULL, 2, NULL); lv_bar_set_value(ui_pageWelCome_barStartProgress,90,LV_ANIM_ON); lv_label_set_text(ui_pageWelCome_labelStartInfo,"serial port task 90%"); vTaskDelay(PROGRESS_DELAY_TIME/portTICK_PERIOD_MS); /*创建本地时间同步任务*/ - xTaskCreate(time_synic_task, "time_synic_task", 8*1024, NULL, 10, NULL); + xTaskCreate(time_synic_task, "time_synic_task", 8*1024, NULL, 2, NULL); /* 创建BS测试LED闪烁任务,同时挂起 */ xTaskCreate(bs_test_led_task, "bs_test_led_task", 4 * 1024, NULL, 2, &bs_stateLED_task_handle); @@ -141,7 +141,7 @@ extern "C" void app_main(void) #if 1/* 支持呼吸模拟器 */ /* 创建UART2响应任务 */ - xTaskCreate(uart2_echoTask, "uart2_echo_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); + xTaskCreate(uart2_echoTask, "uart2_echo_task", ECHO_TASK_STACK_SIZE, NULL, 2, NULL); lv_bar_set_value(ui_pageWelCome_barStartProgress,100,LV_ANIM_ON); lv_label_set_text(ui_pageWelCome_labelStartInfo,"serial port task 100%"); vTaskDelay(PROGRESS_DELAY_TIME/portTICK_PERIOD_MS); diff --git a/sdkconfig b/sdkconfig index f10b0c1..4f41a9e 100644 --- a/sdkconfig +++ b/sdkconfig @@ -2155,7 +2155,16 @@ CONFIG_LV_ASSERT_HANDLER_INCLUDE="assert.h" # # Others # -# CONFIG_LV_USE_PERF_MONITOR is not set +CONFIG_LV_USE_PERF_MONITOR=y +# CONFIG_LV_PERF_MONITOR_ALIGN_TOP_LEFT is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_TOP_MID is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_TOP_RIGHT is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_LEFT is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_MID is not set +CONFIG_LV_PERF_MONITOR_ALIGN_BOTTOM_RIGHT=y +# CONFIG_LV_PERF_MONITOR_ALIGN_LEFT_MID is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_RIGHT_MID is not set +# CONFIG_LV_PERF_MONITOR_ALIGN_CENTER is not set # CONFIG_LV_USE_REFR_DEBUG is not set # CONFIG_LV_SPRINTF_CUSTOM is not set CONFIG_LV_SPRINTF_USE_FLOAT=y