mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
加入快充诱骗调压逻辑
This commit is contained in:
100
Power_Pico/User/GUI/ui_helpers.c
Normal file
100
Power_Pico/User/GUI/ui_helpers.c
Normal file
@@ -0,0 +1,100 @@
|
||||
// LVGL version: 9.2
|
||||
// Project name: PowerPico
|
||||
|
||||
#include "BL24C02.h" // system settings
|
||||
#include "rtc.h" // elapsed time
|
||||
#include "data_queue.h" // bsp/data_queue.h for voltage/current queues
|
||||
#include "user_PDUFPTask.h" // comunicate with PD UFP Task
|
||||
|
||||
#include "./ui_helpers.h"
|
||||
|
||||
///////////////////// ui help funtions ////////////////////
|
||||
|
||||
void ui_full_screen_refresh(lv_obj_t * screen) {
|
||||
// 标记整个屏幕为脏区域
|
||||
lv_obj_invalidate(screen);
|
||||
// 或者立即刷新整个屏幕
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
|
||||
//////////// interface for system hw settings ///////////
|
||||
|
||||
// get functions
|
||||
|
||||
void ui_GetElapsedTime_HMS(uint8_t *hours, uint8_t *minutes, uint8_t *seconds) {
|
||||
GetElapsedTime_HMS(hours, minutes, seconds);
|
||||
}
|
||||
|
||||
uint8_t ui_get_back_light_level(void) {
|
||||
return Sys_Get_BacklightLevel();
|
||||
}
|
||||
|
||||
bool ui_get_key_sound_enable(void) {
|
||||
return Sys_Get_KeySoundEnable();
|
||||
}
|
||||
|
||||
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) {
|
||||
Sys_Set_BacklightLevel(level);
|
||||
}
|
||||
|
||||
void ui_set_key_sound_enable(bool enable) {
|
||||
Sys_Set_KeySoundEnable(enable);
|
||||
}
|
||||
|
||||
void ui_set_display_rotation(uint16_t rotation) {
|
||||
Sys_Set_Rotation(rotation);
|
||||
}
|
||||
|
||||
// sys save function
|
||||
void ui_system_settings_save(void) {
|
||||
EEPROM_SysSetting_Save();
|
||||
}
|
||||
|
||||
///////////// interface for com with PD UFP Task //////////////
|
||||
|
||||
void ui_send_pps_start_msg(void) {
|
||||
PD_command_msg_t pd_ui_msg;
|
||||
pd_ui_msg.event = PD_CMD_START;
|
||||
osMessageQueuePut(PD_cmd_MessageQueue, &pd_ui_msg, 0, 1);
|
||||
}
|
||||
|
||||
void ui_send_pps_stop_msg(void) {
|
||||
PD_command_msg_t pd_ui_msg;
|
||||
pd_ui_msg.event = PD_CMD_STOP;
|
||||
osMessageQueuePut(PD_cmd_MessageQueue, &pd_ui_msg, 0, 1);
|
||||
}
|
||||
|
||||
void ui_send_pps_set_msg(float voltage, float current) {
|
||||
PD_command_msg_t pd_ui_msg;
|
||||
pd_ui_msg.event = PD_CMD_SET_PPS;
|
||||
pd_ui_msg.set_voltage = voltage;
|
||||
pd_ui_msg.set_current = current;
|
||||
osMessageQueuePut(PD_cmd_MessageQueue, &pd_ui_msg, 0, 1);
|
||||
}
|
||||
|
||||
// 非阻塞获取消息队列, 查看是否ready
|
||||
int8_t MsgQueueGet_PPS_ready(void) {
|
||||
PD_handle_event_t pd_handle_event;
|
||||
if(osMessageQueueGet(PD_handle_event_MsgQueue, &pd_handle_event, NULL, 0)==osOK) {
|
||||
if(pd_handle_event == PD_EVT_PPS_READY) {
|
||||
return 1;
|
||||
} else if(pd_handle_event == PD_EVT_PPS_FAILED) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user