1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

optimize math (#5287)

* optimize math

Results in considerable flash saving

* log_approx, exp_approx, pow_approx

Taken from https://github.com/jhjourdan/SIMD-math-prims/blob/master/simd_math_prims.h

* Fix pow in rangefinder

* Use approximate function in baro calculation

Maximum error is < 20cm

* fixup! Fix pow in rangefinder
This commit is contained in:
Petr Ledvina 2018-03-03 13:26:33 +01:00 committed by Michael Keller
parent b64802d931
commit c11d016bc7
7 changed files with 117 additions and 7 deletions

View file

@ -728,7 +728,7 @@ static bool osdDrawSingleElement(uint8_t item)
const float value = constrain(batteryConfig()->batteryCapacity - getMAhDrawn(), 0, batteryConfig()->batteryCapacity);
// Calculate mAh used progress
const uint8_t mAhUsedProgress = ceil((value / (batteryConfig()->batteryCapacity / MAIN_BATT_USAGE_STEPS)));
const uint8_t mAhUsedProgress = ceilf((value / (batteryConfig()->batteryCapacity / MAIN_BATT_USAGE_STEPS)));
// Create empty battery indicator bar
buff[0] = SYM_PB_START;