fix(pwr): show the charge page, then blank it after 10s below 6.8V
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
8bf68e256d
commit
3220602f89
|
|
@ -22,7 +22,7 @@ extern bool pick_hold_up;
|
|||
extern bool usb_charging_state;
|
||||
extern bool usb_charging_laststate;
|
||||
extern uint8_t percentage;
|
||||
/* 关机充电页:仅当已采到的包电压高于 6.8V 时为 1。未采样或低于等于 6.8V 为 0。 */
|
||||
/* 1 = 包电压已高于 6.8V,充电页保持亮。0 = 未采样或低于等于 6.8V,充电页亮 10s 后关屏。 */
|
||||
uint8_t app_adc_charge_ui_allowed(void);
|
||||
void app_adc_scan_all(void);
|
||||
void app_adc_in1_scan_part(uint8_t channel);
|
||||
|
|
|
|||
|
|
@ -292,13 +292,35 @@ void System_RequestAudioBringUp(void)
|
|||
s_audio_bringup_req = 1;
|
||||
}
|
||||
|
||||
#define CHARGE_BL_HOLD_MS 3000u
|
||||
/* 低于等于 6.8V:充电画面亮 10s 后关屏,充电继续 */
|
||||
#define CHARGE_BL_LOW_MS 10000u
|
||||
static uint32_t s_charge_bl_off_at = 0;
|
||||
static uint8_t s_charge_bl_latched_off = 0;
|
||||
|
||||
void Power_ChargeBacklightHold(void)
|
||||
/* 高于 6.8V:充电画面一直亮着 */
|
||||
void Power_ChargeBacklightSteady(void)
|
||||
{
|
||||
s_charge_bl_latched_off = 0;
|
||||
s_charge_bl_off_at = 0;
|
||||
LCD_WR_REG(0x29);
|
||||
LCD_BLK_Set();
|
||||
s_charge_bl_off_at = rt_tick_get() + (CHARGE_BL_HOLD_MS * RT_TICK_PER_SECOND / 1000u);
|
||||
}
|
||||
|
||||
/* 未高于 6.8V:只开始一次 10s 倒计时,电量刷新不能把它清掉或重新点亮 */
|
||||
void Power_ChargeBacklightLowHold(void)
|
||||
{
|
||||
if (s_charge_bl_latched_off || s_charge_bl_off_at != 0u)
|
||||
return;
|
||||
LCD_WR_REG(0x29);
|
||||
LCD_BLK_Set();
|
||||
s_charge_bl_off_at = rt_tick_get() + (CHARGE_BL_LOW_MS * RT_TICK_PER_SECOND / 1000u);
|
||||
LOG_I("PWR", "charge lcd on, off in %ums (pack <=6.8V)", (unsigned)CHARGE_BL_LOW_MS);
|
||||
}
|
||||
|
||||
void Power_ChargeBacklightSessionReset(void)
|
||||
{
|
||||
s_charge_bl_off_at = 0;
|
||||
s_charge_bl_latched_off = 0;
|
||||
}
|
||||
|
||||
void Power_ChargeIdle_LogPoll(void)
|
||||
|
|
@ -309,14 +331,17 @@ void Power_ChargeIdle_LogPoll(void)
|
|||
if (powon)
|
||||
{
|
||||
s_charge_bl_off_at = 0;
|
||||
s_charge_bl_latched_off = 0;
|
||||
return;
|
||||
}
|
||||
now = rt_tick_get();
|
||||
if (s_charge_bl_off_at != 0u && (int32_t)(now - s_charge_bl_off_at) >= 0)
|
||||
{
|
||||
LCD_BLK_Clr();
|
||||
LCD_WR_REG(0x28); /* Display OFF,充电不中断 */
|
||||
s_charge_bl_off_at = 0;
|
||||
LOG_I("PWR", "charge backlight off");
|
||||
s_charge_bl_latched_off = 1;
|
||||
LOG_I("PWR", "charge lcd off after 10s, still charging");
|
||||
}
|
||||
if (s_last != 0u && (now - s_last) < (5u * RT_TICK_PER_SECOND))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -184,8 +184,10 @@ void System_PowerOn(void);
|
|||
void System_RequestAudioBringUp(void);
|
||||
void System_AudioBringUp_Poll(void);
|
||||
void Power_ChargeIdle_LogPoll(void);
|
||||
/* 充电页点亮背光数秒后关掉,避免屏幕把电池耗下去 */
|
||||
void Power_ChargeBacklightHold(void);
|
||||
/* 高于 6.8V:充电页背光保持;低于等于 6.8V:亮 10s 后关屏。拔电时复位倒计时。 */
|
||||
void Power_ChargeBacklightSteady(void);
|
||||
void Power_ChargeBacklightLowHold(void);
|
||||
void Power_ChargeBacklightSessionReset(void);
|
||||
/* 读回各路电源输出电平:main/dream/v12/bt 为 1=开;chg 为 1=充电使能(低有效) */
|
||||
void Power_LogRails(const char *where);
|
||||
void System_RequestPowerOff(void);
|
||||
|
|
|
|||
20
UI/UI_Idle.c
20
UI/UI_Idle.c
|
|
@ -257,18 +257,6 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
/* 已开机:忽略滞后的关机充电消息,勿覆盖模式选择页或切断主电 */
|
||||
if (powon)
|
||||
break;
|
||||
if (usb_charging_state && !app_adc_charge_ui_allowed())
|
||||
{
|
||||
/* Type-C 充电且包电压未高于 6.8V:不点亮、不画充电页 */
|
||||
LCD_BLK_Clr();
|
||||
LCD_WR_REG(0x28);
|
||||
if (s_charge_ui_drawn)
|
||||
LCD_FillByColor(0, 0, 240, 320, BLACK);
|
||||
s_charge_ui_drawn = false;
|
||||
BSP_MainPowerEnable(0);
|
||||
LOG_I("UI", "type-c charge <=6.8V, lcd off");
|
||||
break;
|
||||
}
|
||||
if(!s_charge_ui_drawn)
|
||||
{
|
||||
uint8_t peek[4];
|
||||
|
|
@ -292,7 +280,6 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
LOG_W("UI", "charge flash empty @0x%08lX — flash ui0902",
|
||||
(unsigned long)UI0902_CHARGE_SCREEN_ADDR);
|
||||
}
|
||||
Power_ChargeBacklightHold();
|
||||
s_charge_ui_drawn = true;
|
||||
Power_LogRails("charge-ui");
|
||||
}
|
||||
|
|
@ -319,11 +306,16 @@ void IdleProcess(DisplayTaskMessage_Type msg)
|
|||
}
|
||||
LCD_WR_PIC_Trans(x, y, g_ChargePctPercent.w, g_ChargePctPercent.h,
|
||||
g_ChargePctPercent.data, BLACK);
|
||||
Power_ChargeBacklightHold();
|
||||
/* 插入后先显示充电画面。高于 6.8V 一直亮;否则 10s 后关屏,充电继续 */
|
||||
if (app_adc_charge_ui_allowed())
|
||||
Power_ChargeBacklightSteady();
|
||||
else
|
||||
Power_ChargeBacklightLowHold();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 关机充电中拔掉:熄屏,允许下次再进充电页 */
|
||||
Power_ChargeBacklightSessionReset();
|
||||
LCD_BLK_Clr();
|
||||
LCD_FillByColor(0, 0, 240, 320, BLACK);
|
||||
BSP_MainPowerEnable(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue