| | |
| | | void PowerLedTask(void) |
| | | { |
| | | static u8 powerled_state=0; |
| | | if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | { |
| | | chongman_time=0; |
| | | only_one_flag=0; |
| | | if(!power_state&&!chargedbg_flag) |
| | | { |
| | | CloseRTK4G(); |
| | | DBG_SetMode(DBG_MODE_CHARGE); |
| | | power_state = 1; |
| | | } |
| | | while(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)&&DBG_GetMode() == DBG_MODE_CHARGE) |
| | | { |
| | | if(HIDO_TimerGetTick()-adctick>6000) //6s采样一次 电量 |
| | | { |
| | | adctick = HIDO_TimerGetTick(); |
| | | chongman_time=chongman_time+6; |
| | | #ifdef BATTARY_DEBUG |
| | | //printf("电压: %f V,电量 %d,标志位%d,时间 %d\r\n",fVoltage1,bat_percent2,only_one_flag,chongman_time); |
| | | #endif |
| | | if( HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_10)) |
| | | { |
| | | bat_percent2=Power_GetBatteryPercentage(); |
| | | // if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | // { |
| | | // chongman_time=0; |
| | | // only_one_flag=0; |
| | | // if(!power_state&&!chargedbg_flag) |
| | | // { |
| | | // CloseRTK4G(); |
| | | // DBG_SetMode(DBG_MODE_CHARGE); |
| | | // power_state = 1; |
| | | // } |
| | | // while(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)&&DBG_GetMode() == DBG_MODE_CHARGE) |
| | | // { |
| | | // if(HIDO_TimerGetTick()-adctick>6000) //6s采样一次 电量 |
| | | // { |
| | | // adctick = HIDO_TimerGetTick(); |
| | | // chongman_time=chongman_time+6; |
| | | // #ifdef BATTARY_DEBUG |
| | | // //printf("电压: %f V,电量 %d,标志位%d,时间 %d\r\n",fVoltage1,bat_percent2,only_one_flag,chongman_time); |
| | | // #endif |
| | | // if( HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_10)) |
| | | // { |
| | | // bat_percent2=Power_GetBatteryPercentage(); |
| | | |
| | | }else{ |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); |
| | | bat_percent2=Power_GetBatteryPercentage(); |
| | | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); |
| | | } |
| | | } |
| | | if(fVoltage1>=4.15&&!only_one_flag) |
| | | { |
| | | only_one_flag=1; |
| | | chongman_time=0; |
| | | } |
| | | if(fVoltage1>=4.15&&chongman_time>=1800) |
| | | { |
| | | powerled = GREEN; |
| | | }else{ |
| | | powerled = RED; |
| | | } |
| | | delay_ms(100); |
| | | DBG_Poll(); |
| | | Internet_Poll(); |
| | | Set4LEDColor(0,0,0,powerled); |
| | | } |
| | | } |
| | | // }else{ |
| | | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); |
| | | // bat_percent2=Power_GetBatteryPercentage(); |
| | | // HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); |
| | | // } |
| | | // } |
| | | // if(fVoltage1>=4.15&&!only_one_flag) |
| | | // { |
| | | // only_one_flag=1; |
| | | // chongman_time=0; |
| | | // } |
| | | // if(fVoltage1>=4.15&&chongman_time>=1800) |
| | | // { |
| | | // powerled = GREEN; |
| | | // }else{ |
| | | // powerled = RED; |
| | | // } |
| | | // delay_ms(100); |
| | | // DBG_Poll(); |
| | | // Internet_Poll(); |
| | | // Set4LEDColor(0,0,0,powerled); |
| | | // } |
| | | // } |
| | | |
| | | chargeon = 0; |
| | | if(power_state) |