mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
更换串口为USB
This commit is contained in:
@@ -62,8 +62,7 @@ static void _flush_timer_cb(void) {
|
||||
char buf[5];
|
||||
float voltage = 0.0;
|
||||
float current = 0.0;
|
||||
current = ui_get_current(); // uA
|
||||
voltage = ui_get_voltage(); // V
|
||||
ui_get_vol_cur(&voltage, ¤t);
|
||||
sprintf(buf, "%.2f", voltage);
|
||||
lv_label_set_text(ui_LabelPPSVol, buf);
|
||||
sprintf(buf, "%.2f", current/1000000.0); // 转换为 A
|
||||
|
||||
@@ -130,8 +130,7 @@ static void _flush_timer_cb()
|
||||
{
|
||||
float voltage = 0.0;
|
||||
float current = 0.0;
|
||||
current = ui_get_current();
|
||||
voltage = ui_get_voltage();
|
||||
ui_get_vol_cur(&voltage, ¤t);
|
||||
set_val_cur_label(voltage, current);
|
||||
}
|
||||
|
||||
@@ -250,7 +249,7 @@ void ui_main_screen_init(void)
|
||||
lv_obj_set_style_text_font(ui_LabelTime, &ui_font_HeiTi48, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||
_flush_timer_cb(NULL);
|
||||
// flush timer
|
||||
_flush_timer = lv_timer_create(_flush_timer_cb, 500, NULL);
|
||||
_flush_timer = lv_timer_create(_flush_timer_cb, 250, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ static void main_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
// 1s 刷新一次全屏,防止有时候不知什么原因的LCD刷新错误(需要后续找到问题从根本解决不知是不是屏幕本身问题)
|
||||
ui_full_screen_refresh(lv_screen_active());
|
||||
ui_GetElapsedTime_HMS(NULL, NULL, NULL); // 更新经过时间计数器
|
||||
}
|
||||
|
||||
////////////////////////// Animation //////////////////////
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "BL24C02.h" // system settings
|
||||
#include "tim.h" // elapsed time
|
||||
#include "data_queue.h" // bsp/data_queue.h for voltage/current queues
|
||||
#include "adc.h" // for voltage/current minitor
|
||||
#include "user_PDUFPTask.h" // comunicate with PD UFP Task
|
||||
|
||||
#include "./ui_helpers.h"
|
||||
@@ -27,10 +27,7 @@ uint64_t ui_GetElaspseMicroseconds(void) {
|
||||
|
||||
// 获取经过的时间, 单位为时分秒, 必须定时运行以更新32位计数器溢出
|
||||
void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds) {
|
||||
// 1. 更新64位计数器
|
||||
UpdateMicrosecondCounter();
|
||||
|
||||
// 2. 基于更新后的64位计数值进行计算
|
||||
uint64_t total_us = GetMicrosecondCounter();
|
||||
uint32_t total_seconds = total_us / 1000000;
|
||||
|
||||
@@ -61,12 +58,9 @@ 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);
|
||||
// 获取当前电压, 单位 V; 当前电流, 单位 uA
|
||||
void ui_get_vol_cur(float *voltage, float *current) {
|
||||
Data_Monitor_Get_Values(voltage, current);
|
||||
}
|
||||
|
||||
//////////////// set functions ///////////////
|
||||
@@ -91,6 +85,10 @@ void ui_set_display_rotation(uint16_t rotation) {
|
||||
Sys_Set_Rotation(rotation);
|
||||
}
|
||||
|
||||
void ui_clear_data_monitor(void) {
|
||||
Data_Monitor_Clear();
|
||||
}
|
||||
|
||||
//////////////// sys save functions ///////////////
|
||||
void ui_system_settings_save(void) {
|
||||
EEPROM_SysSetting_Save();
|
||||
|
||||
@@ -19,14 +19,13 @@ void ui_full_screen_refresh(lv_obj_t * screen);
|
||||
|
||||
// get functions
|
||||
|
||||
uint64_t ui_GetElapsedMicroseconds(void);
|
||||
uint64_t ui_GetElaspseMicroseconds(void);
|
||||
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);
|
||||
uint8_t ui_get_language_select(void);
|
||||
uint16_t ui_get_display_rotation(void);
|
||||
float ui_get_voltage(void);
|
||||
float ui_get_current(void);
|
||||
void ui_get_vol_cur(float *voltage, float *current);
|
||||
|
||||
// set functions
|
||||
|
||||
@@ -35,6 +34,7 @@ void ui_set_back_light_level(uint8_t level);
|
||||
void ui_set_key_sound_enable(bool enable);
|
||||
void ui_set_language_select(uint8_t lang);
|
||||
void ui_set_display_rotation(uint16_t rotation);
|
||||
void ui_clear_data_monitor(void);
|
||||
|
||||
// sys save function
|
||||
void ui_system_settings_save(void);
|
||||
|
||||
Reference in New Issue
Block a user