优化低电量报警
authorhcj <1224667075@qq.com>
Fri, 9 Aug 2024 09:13:38 +0000 (17:13 +0800)
committerhcj <1224667075@qq.com>
Fri, 9 Aug 2024 09:13:38 +0000 (17:13 +0800)
code/sdk/application/battery/service/battery_service.cpp

index 9d5e4fe..2729f00 100644 (file)
@@ -272,14 +272,14 @@ static void battery_check_chargement(void)
              * report alarm shutdown event at 5%
              * pay attention to : debounce 
             */
-            if (percent >0 && percent <= BATTERY_LOWPOWER_ALARM_POWERLEVEL && low_power_flag_1)
+            if (percent >0 && percent <= BATTERY_LOWPOWER_ALARM_POWERLEVEL)
             {
                 low_power_play_toUI(0);
-                low_power_flag_1=0;
-            }else if (percent <= BATTERY_LOWPOWER_ALARM_SHUTDOWNLEVEL && low_power_flag_2)
+                
+            }else if (percent <= BATTERY_LOWPOWER_ALARM_SHUTDOWNLEVEL )
             {
                 low_power_play_toUI(1);
-                low_power_flag_2=0;
+                
             }
         }
     #endif
@@ -438,6 +438,11 @@ errcode_t charger_plug_event_notify(uint8_t plugged)
 errcode_t Play_shutdown_animation_notify(uint8_t alarm_level)
 {
 
+    if(alarm_level==0 && low_power_flag_1)
+    low_power_flag_1=0;
+    else if(alarm_level==1 && low_power_flag_2)
+    low_power_flag_2=0;
+
     ChargerEventPublish(TOPIC_EVENT_LOWPOWER_ALARM,alarm_level);
    return 0;
 }
@@ -449,6 +454,7 @@ errcode_t low_power_play_toUI(uint8_t alarm_level)
 {
 
     /**通过UI事件发送Notify*/
+    
     GraphicService::GetInstance()->PostGraphicEvent(std::bind(Play_shutdown_animation_notify, alarm_level));
 
     return ERRCODE_SUCC;