From: Caisking Date: Mon, 9 Mar 2026 08:41:52 +0000 (+0800) Subject: 优化电量判断,不筛选时间 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=218d8ca9ab1885489bc3556726b5e6a239b4eef0;p=mirrors%2FFD230.git 优化电量判断,不筛选时间 --- diff --git a/code/sdk/zhihui/services/battery/service/battery_driver.cpp b/code/sdk/zhihui/services/battery/service/battery_driver.cpp index 2432bd002..c0c201dd4 100644 --- a/code/sdk/zhihui/services/battery/service/battery_driver.cpp +++ b/code/sdk/zhihui/services/battery/service/battery_driver.cpp @@ -544,15 +544,16 @@ void battery_restore_vol(void) uapi_get_file_data("/user/userdata/battery.bin",(uint8_t *)&bat_vol,&len); - uapi_get_timestampe_ss(&time); + /* 不再用时间戳判断是否过期,仅依赖电压接近度决定是否采用历史电量,避免 RTC 异常时误弃用有效数据 */ + // uapi_get_timestampe_ss(&time); - printf("time:%d,l_time:%d\n",time,bat_vol.time ); - if(time - bat_vol.time >= 24 * 60 * 60) - { - memset_s(&bat_vol,sizeof(BAT_VOL_T),0,sizeof(BAT_VOL_T)); - bat_vol.right = -1; - return; - } + // printf("time:%d,l_time:%d\n",time,bat_vol.time ); + // if(time - bat_vol.time >= 24 * 60 * 60) + // { + // memset_s(&bat_vol,sizeof(BAT_VOL_T),0,sizeof(BAT_VOL_T)); + // bat_vol.right = -1; + // return; + // } if(bat_vol.vol_num < 0 || bat_vol.vol_num > AVG_VOLTAGE_COUNT || bat_vol.right < -1 || bat_vol.right >= AVG_VOLTAGE_COUNT ||