zhyinch
2020-04-15 d1f86e2717e82d116a0329f33f57435e8f1d4a45
Src/OnChipDevices/ADC.c
@@ -13,15 +13,18 @@
uint8_t Get_Battary(void)
{static float last_value = 100;
static uint8_t first=1;
   HAL_GPIO_WritePin(GPIOB, BAT_MEAS_GND_Pin, GPIO_PIN_RESET);
   bat_volt = (float)Get_ADC_Value()/621;  //(value/4096*3.3*2-3.5)/0.7
   HAL_GPIO_WritePin(GPIOB, BAT_MEAS_GND_Pin, GPIO_PIN_SET);
   if(bat_volt>=3.5)
   {
      if(first)
      {
      first = 0;
         last_value =(bat_volt-3.5)*143;
            bat_volt = (float)Get_ADC_Value()/621;
         last_value =(bat_volt-3.5)*167;//(bat_volt-3.5)/0.6*100
      }
      last_value = 0.9*last_value + (bat_volt-3.5)*14.3;
      last_value = 0.9*last_value + (bat_volt-3.5)*16.7;
   if(last_value>100)
      last_value = 100;
   if(last_value<0)