Przeglądaj źródła

battery changer

Chenyingjia 2 lat temu
rodzic
commit
11c8b3c754
1 zmienionych plików z 18 dodań i 4 usunięć
  1. 18 4
      hal/hal_battery/hal_battery_NoPowerEnPin.c

+ 18 - 4
hal/hal_battery/hal_battery_NoPowerEnPin.c

@@ -92,7 +92,7 @@ void cb_init(void)
 //返回5V信号,有5V的话返回1,没有的话返回0
 static char charge_in(void)
 {
-	if ((app_chargepin_pairline() == CHARGE))
+	if (nrf_gpio_pin_read(PIN_CHARGING))
 	{
 		return 1;
 	}
@@ -283,6 +283,13 @@ static float Power_management(float mV_Battery, float mV_Charge)
 		{
 			battercb->P1 = Voltage2power(mV_Battery);
 			battercb->sta = 1; //放电过程
+			
+			if ( ( interp1(mV_Battery/10.0f) - battercb->P1 > 15.0f ) || ( interp1(mV_Battery/10.0f) - battercb->P1 < -15.0f ) )
+			{
+					battercb->P1 = interp1(mV_Battery/10.0f);
+					SEGGER_RTT_printf(0,"battercb->P1 > celibration \r\n");
+			}
+			
 		}
 		break;
 	case 1://放电
@@ -295,14 +302,21 @@ static float Power_management(float mV_Battery, float mV_Charge)
 		else
 		{
 			battercb->P2 = Voltage2power(mV_Battery);
-			if (battercb->P1 > battercb->P2) //过滤刚拔掉充电线时候的虚高
+			if ( ( battercb->P2 - battercb->P1 > 15.0f ) || ( battercb->P2 - battercb->P1 < -15.0f ) )
 			{
-				battercb->P1 = battercb->P2;
+					battercb->P1 = battercb->P2;
+					SEGGER_RTT_printf(0,"battercb->P1 > celibration \r\n");
+			}
+			else
+			{
+					if ( battercb->P1 > battercb->P2 )
+					{
+							battercb->P1 = battercb->P2;
+					}
 			}
 			//解决充满电后充电器不拔出来的情况显示不到100%的情况
 			if (battercb->P1 > 95.0f)
 			{
-				DEBUG_LOG( "battercb->P1 > 95.0f\r\n");
 				if (charge_in())
 				{
 					battercb->P1 = 100.0f;