优化电量判断,不筛选时间
authorCaisking <Casiking@zhihuishixun.com>
Mon, 9 Mar 2026 08:41:52 +0000 (16:41 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Mon, 9 Mar 2026 08:41:52 +0000 (16:41 +0800)
code/sdk/zhihui/services/battery/service/battery_driver.cpp

index 2432bd0..c0c201d 100644 (file)
@@ -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 ||