STMicroelectronics-CentralLabs / ST_Drone_FCU_F401

Toy drone project for STEVAL-FCU001V1 flight controller unit demo board.
Other
157 stars 114 forks source link

Battery voltage #18

Open ETH-PBL opened 3 years ago

ETH-PBL commented 3 years ago

The battery voltage measurement is not representative. It is providing a percentage between 0V to 4.2V, so the drone actually die at 80% of the battery. I propose this modification:

// VBAT percentage between 3.7 and 4.2V
VBAT = ((VBAT - 3.7f)*100.0f)/(4.2f-3.7f);
if (VBAT < 0) VBAT = 0;
MCR_BLUEMS_F2I_1D(((int32_t)(VBAT)), intPart, decPart);
BattToSend = intPart*10+decPart;
if (BattToSend > 1000){
    BattToSend =1000;
}