This files contains random useful functions.
More...
Go to the source code of this file.
|
| float | constrain (float input, float minValue, float maxValue) |
| | Constrains an input between two values. More...
|
| |
| uint16_t | constrain16 (uint16_t input, uint16_t minValue, uint16_t maxValue) |
| | Constrains an input uint16_t between two values. More...
|
| |
| float | standardRadianFormat (float angle) |
| | Puts a value in standard radian format. More...
|
| |
| uint16_t | dshot3dFormat (int16_t rxCmd) |
| | Formats values from an iBus receiver for 3D mode. More...
|
| |
| float | stringToFloat (const char *p) |
| | Simple and fast atof (ascii to float) function. More...
|
| |
This files contains random useful functions.
- Author
- Jeremy Wolfe
- Date
- 07 MAR 2022
◆ valid_digit
| #define valid_digit |
( |
|
c | ) |
((c) >= '0' && (c) <= '9') |
◆ white_space
| #define white_space |
( |
|
c | ) |
((c) == ' ' || (c) == '\t') |
◆ constrain()
| float constrain |
( |
float |
input, |
|
|
float |
minValue, |
|
|
float |
maxValue |
|
) |
| |
Constrains an input between two values.
- Parameters
-
| input | Value to be constrained. |
| minValue | Lower threshold. |
| maxValue | Upper threshold. |
- Returns
- float Constrained value.
◆ constrain16()
| uint16_t constrain16 |
( |
uint16_t |
input, |
|
|
uint16_t |
minValue, |
|
|
uint16_t |
maxValue |
|
) |
| |
Constrains an input uint16_t between two values.
- Parameters
-
| input | Value to be constrained. |
| minValue | Lower threshold. |
| maxValue | Upper threshold. |
- Returns
- uint16_t Constrained value.
◆ dshot3dFormat()
| uint16_t dshot3dFormat |
( |
int16_t |
rxCmd | ) |
|
Formats values from an iBus receiver for 3D mode.
- Parameters
-
| rxCommand | Value from iBus receiver. |
- Returns
- uint16_t Formatted value.
◆ standardRadianFormat()
| float standardRadianFormat |
( |
float |
angle | ) |
|
Puts a value in standard radian format.
- Parameters
-
| angle | Value to be formatted. |
- Returns
- float Formatted value.
◆ stringToFloat()
| float stringToFloat |
( |
const char * |
p | ) |
|
Simple and fast atof (ascii to float) function.
Executes about 5x faster than standard MSCRT library atof()
-An attractive alternative if the number of calls is in the millions.
-Assumes input is a proper integer, fraction, or scientific format.
-Matches library atof() to 15 digits (except at extreme exponents).
-Follows atof() precedent of essentially no error checking.
09-May-2009 Tom Van Baak (tvb) www.LeapSecond.com
- Parameters
-
- Returns
- float Converted float value.