From e449ed7ee39e4adfe5080b095ecdd0bca2468228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=90=83=E6=B2=B9=E7=82=B8=E9=B8=A1?= <1425962791@qq.com> Date: Fri, 5 Dec 2025 17:16:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=86=E5=B1=82API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Power_Pico/User/GUI/screens/ui_PPSPage.c | 5 ++--- Power_Pico/User/GUI/screens/ui_mainPage.c | 5 ++--- Power_Pico/User/GUI/ui.c | 10 ++++++++++ Power_Pico/User/GUI/ui.h | 2 ++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Power_Pico/User/GUI/screens/ui_PPSPage.c b/Power_Pico/User/GUI/screens/ui_PPSPage.c index e79ae44..bc06741 100644 --- a/Power_Pico/User/GUI/screens/ui_PPSPage.c +++ b/Power_Pico/User/GUI/screens/ui_PPSPage.c @@ -4,7 +4,6 @@ // Project name: PowerPico #include "../ui.h" -#include "data_queue.h" // bsp/data_queue.h for voltage/current queues lv_obj_t * ui_PPSPage = NULL; static lv_obj_t * ui_PanelPPSVol = NULL; @@ -56,8 +55,8 @@ static void _flush_timer_cb(void) { char buf[5]; float voltage = 0.0; float current = 0.0; - current = queue_average(global_current_queue); // uA - voltage = queue_average(global_voltage_queue); // V + current = ui_get_current(); // uA + voltage = ui_get_voltage(); // V sprintf(buf, "%.2f", voltage); lv_label_set_text(ui_LabelPPSVol, buf); sprintf(buf, "%.2f", current/1000000.0); // 转换为 A diff --git a/Power_Pico/User/GUI/screens/ui_mainPage.c b/Power_Pico/User/GUI/screens/ui_mainPage.c index 81d75e5..8f0282a 100644 --- a/Power_Pico/User/GUI/screens/ui_mainPage.c +++ b/Power_Pico/User/GUI/screens/ui_mainPage.c @@ -5,7 +5,6 @@ #include "../ui.h" #include "ui_mainPage.h" -#include "data_queue.h" // bsp/data_queue.h for voltage/current queues #include "math.h" lv_obj_t * ui_HomeScreen = NULL; @@ -138,8 +137,8 @@ static void _flush_timer_cb() } float voltage = 0.0; float current = 0.0; - current = queue_average(global_current_queue); - voltage = queue_average(global_voltage_queue); + current = ui_get_current(); + voltage = ui_get_voltage(); set_val_cur_label(voltage, current); } diff --git a/Power_Pico/User/GUI/ui.c b/Power_Pico/User/GUI/ui.c index 39969e4..c3efd11 100644 --- a/Power_Pico/User/GUI/ui.c +++ b/Power_Pico/User/GUI/ui.c @@ -3,6 +3,8 @@ #include "BL24C02.h" // system settings #include "rtc.h" // elapsed time +#include "data_queue.h" // bsp/data_queue.h for voltage/current queues + #include "./ui.h" #include "./screens/ui_StartPage.h" #include "./screens/ui_mainPage.h" @@ -30,6 +32,14 @@ uint16_t ui_get_display_rotation(void) { return Sys_Get_Rotation(); } +float ui_get_voltage(void) { + return queue_average(global_voltage_queue); +} + +float ui_get_current(void) { + return queue_average(global_current_queue); +} + // set functions void ui_set_back_light_level(uint8_t level) { diff --git a/Power_Pico/User/GUI/ui.h b/Power_Pico/User/GUI/ui.h index e0970da..bf3283b 100644 --- a/Power_Pico/User/GUI/ui.h +++ b/Power_Pico/User/GUI/ui.h @@ -29,6 +29,8 @@ void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds); uint8_t ui_get_back_light_level(void); bool ui_get_key_sound_enable(void); uint16_t ui_get_display_rotation(void); +float ui_get_voltage(void); +float ui_get_current(void); // set functions