Name space for maths related utilities.
More...
|
| int | mapValue (int x, int in_min, int in_max, int out_min, int out_max) |
| | Maps a value from one range to another using linear interpolation. This function takes an input value within a specified range and maps it to a corresponding value in a different output range using std::lerp.
|
| |
| float | sineFromDegrees (float angle) |
| | Computes the sine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the sine of that angle using the standard C++ sin function.
|
| |
| float | cosineFromDegrees (float angle) |
| | Computes the cosine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the cosine of that angle using the standard C++ cos function.
|
| |
| uint16_t | generateColor (uint8_t value) |
| | This function is designed to return a color in the 16-bit RGB format based on the input value, creating a smooth transition between colors in different stages.
|
| |
| uint16_t | blend565 (uint16_t c1, uint16_t c2, uint8_t amount) |
| | : Blend two RGB565 colors using 8-bit mix factor
|
| |
Name space for maths related utilities.
◆ blend565()
| uint16_t rdlib_maths::blend565 |
( |
uint16_t |
c1, |
|
|
uint16_t |
c2, |
|
|
uint8_t |
amount |
|
) |
| |
: Blend two RGB565 colors using 8-bit mix factor
- Parameters
-
| c1 | first 16-bit color (RGB565) |
| c2 | second 16-bit color (RGB565) |
| amount | blend level (0–255), 0=c1, 255=c2 |
- Returns
- mixed 16-bit RGB565 color
Performs channel-wise interpolation in 565 space. c1 blended towardc2 using linear scaling.
◆ cosineFromDegrees()
| float rdlib_maths::cosineFromDegrees |
( |
float |
angle | ) |
|
Computes the cosine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the cosine of that angle using the standard C++ cos function.
- Parameters
-
| angle | The angle in degrees. |
- Returns
- The cosine value of the given angle.
◆ generateColor()
| uint16_t rdlib_maths::generateColor |
( |
uint8_t |
value | ) |
|
This function is designed to return a color in the 16-bit RGB format based on the input value, creating a smooth transition between colors in different stages.
- Parameters
-
- Returns
- 16 bit color
The gradient is calculated by cycling through different color transitions as val increases, allowing for smooth visual effects such as changing hues or creating rainbow-like effects on an LCD. 1-127 will This will create a gradient color between blue and red based on the value.
◆ mapValue()
| int rdlib_maths::mapValue |
( |
int |
x, |
|
|
int |
in_min, |
|
|
int |
in_max, |
|
|
int |
out_min, |
|
|
int |
out_max |
|
) |
| |
Maps a value from one range to another using linear interpolation. This function takes an input value within a specified range and maps it to a corresponding value in a different output range using std::lerp.
- Parameters
-
| x | The input value to map. |
| in_min | The lower bound of the input range. |
| in_max | The upper bound of the input range. |
| out_min | The lower bound of the output range. |
| out_max | The upper bound of the output range. |
- Returns
- The mapped value in the output range.
◆ sineFromDegrees()
| float rdlib_maths::sineFromDegrees |
( |
float |
angle | ) |
|
Computes the sine of an angle given in degrees. This function converts the input angle from degrees to radians and then calculates the sine of that angle using the standard C++ sin function.
- Parameters
-
| angle | The angle in degrees. |
- Returns
- The sine value of the given angle.