EdgeTX / edgetx-sdcard

SD Card contents and images for EdgeTX
125 stars 41 forks source link

BattAnalog widget shows 1% when battery is fully charged #166

Open LoooooKe opened 1 month ago

LoooooKe commented 1 month ago

The BattAnalog widget shows 1% when the battery is fully charged. I narrowed it down to the following line:

https://github.com/EdgeTX/edgetx-sdcard/blob/b236171b6fae5ff247748acb303b8177c61aaba3/sdcard/c480x272/WIDGETS/BattAnalog/main.lua#L257

If the voltage is equal or even .01 above the value in voltageRange, the method returns the wrong cell count, which then leads to a wrong calculation of the cellPercentage value here:

https://github.com/EdgeTX/edgetx-sdcard/blob/b236171b6fae5ff247748acb303b8177c61aaba3/sdcard/c480x272/WIDGETS/BattAnalog/main.lua#L326

My suggestion is to round singleVoltage to one decimal and change the '<' to a '<='. This should fix the issue for all battery types.