mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
GPS: handle negative and high altitudes; safer macros in maths.h
Fixes underflows at negative altitude (below MSL) and overflows at altitude higher than 655.35m Corrected parenthesis in maths.h avoid incorrect equations if arguments contain expressions.
This commit is contained in:
parent
a5ba01666b
commit
536ad399e6
4 changed files with 11 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* This file is part of Cleanflight and Betaflight.
|
||||
*
|
||||
|
@ -33,13 +34,13 @@
|
|||
#define M_PIf 3.14159265358979323846f
|
||||
|
||||
#define RAD (M_PIf / 180.0f)
|
||||
#define DEGREES_TO_DECIDEGREES(angle) (angle * 10)
|
||||
#define DECIDEGREES_TO_DEGREES(angle) (angle / 10)
|
||||
#define DECIDEGREES_TO_RADIANS(angle) ((angle / 10.0f) * 0.0174532925f)
|
||||
#define DEGREES_TO_DECIDEGREES(angle) ((angle) * 10)
|
||||
#define DECIDEGREES_TO_DEGREES(angle) ((angle) / 10)
|
||||
#define DECIDEGREES_TO_RADIANS(angle) ((angle) / 10.0f * 0.0174532925f)
|
||||
#define DEGREES_TO_RADIANS(angle) ((angle) * 0.0174532925f)
|
||||
|
||||
#define CM_S_TO_KM_H(centimetersPerSecond) (centimetersPerSecond * 36 / 1000)
|
||||
#define CM_S_TO_MPH(centimetersPerSecond) (((centimetersPerSecond * 10000) / 5080) / 88)
|
||||
#define CM_S_TO_KM_H(centimetersPerSecond) ((centimetersPerSecond) * 36 / 1000)
|
||||
#define CM_S_TO_MPH(centimetersPerSecond) ((centimetersPerSecond) * 10000 / 5080 / 88)
|
||||
|
||||
#define MIN(a,b) \
|
||||
__extension__ ({ __typeof__ (a) _a = (a); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue