mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 08:45:36 +03:00
Use fabsf() instead of ABS() for floats
The ABS() macro doesn't handle -0 floats correctly. Also fabsf() is more efficient.
This commit is contained in:
parent
628fdb8adc
commit
3d671c7134
8 changed files with 23 additions and 22 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
|
@ -791,7 +792,7 @@ static void applyLedIndicatorLayer(bool updateNow, timeUs_t *timer)
|
|||
if (updateNow) {
|
||||
if (rxIsReceivingSignal()) {
|
||||
// calculate update frequency
|
||||
int scale = MAX(ABS(rcCommand[ROLL]), ABS(rcCommand[PITCH])); // 0 - 500
|
||||
int scale = MAX(fabsf(rcCommand[ROLL]), fabsf(rcCommand[PITCH])); // 0 - 500
|
||||
scale = scale - INDICATOR_DEADBAND; // start increasing frequency right after deadband
|
||||
*timer += HZ_TO_US(5 + (45 * scale) / (500 - INDICATOR_DEADBAND)); // 5 - 50Hz update, 2.5 - 25Hz blink
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue