Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
lampda::utils Namespace Reference

Utility function and classes. More...

Namespaces

namespace  ColorSpace
 Define commonly used color spaces.
 
namespace  curves
 Curves classes to sample values from predefined custom parameters.
 
namespace  ELK
 decode ELK control messages
 

Classes

struct  RotationMatrix
 Represent an XYZ rotation matrix. More...
 
class  StateMachine
 Define a state machine. More...
 
struct  TransformationMatrix
 Transform a vector from a space to another. More...
 
struct  vec2d
 2d vector in any space More...
 
struct  vec3d
 3d vector in any space More...
 
struct  vec4d
 4d vector in any space More...
 

Functions

static uint32_t Color (uint8_t r, uint8_t g, uint8_t b)
 Convert separate red, green and blue values into a single "packed" 32-bit RGB color.
 
static uint32_t Color (uint8_t r, uint8_t g, uint8_t b, uint8_t w)
 Convert separate red, green, blue and white values into a single "packed" 32-bit WRGB color.
 
uint32_t get_random_complementary_color (const uint32_t color, const float tolerance)
 Compute the complementary color of the given color, with a random variation.
 
uint32_t get_gradient (const uint32_t colorStart, const uint32_t colorEnd, const float level)
 Return the color gradient between colorStart to colorEnd.
 
COLOR color_fade (COLOR c1, uint8_t amount, bool video)
 
COLOR color_add (COLOR c1, COLOR c2, bool fast)
 
uint32_t hue_to_rgb_sinus (const uint16_t angle)
 
template<typename T >
static constexpr uint32_t hash (const T s, const uint16_t maxSize=14, const uint16_t off=0)
 Hash input string into a 32-bit unsigned integer.
 
constexpr double analogReadToVoltage (const uint16_t analogVal)
 
constexpr uint16_t voltageToAnalogRead (const float voltage)
 

Variables

constexpr platform::gpio::DigitalPin::GPIO RedIndicator = platform::gpio::DigitalPin::GPIO::gpio0
 
constexpr platform::gpio::DigitalPin::GPIO GreenIndicator = platform::gpio::DigitalPin::GPIO::gpio1
 
constexpr platform::gpio::DigitalPin::GPIO BlueIndicator = platform::gpio::DigitalPin::GPIO::gpio2
 

Detailed Description

Utility function and classes.

Function Documentation

◆ Color() [1/2]

static uint32_t lampda::utils::Color ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
static

Convert separate red, green and blue values into a single "packed" 32-bit RGB color.

Parameters
rRed brightness, 0 to 255.
gGreen brightness, 0 to 255.
bBlue brightness, 0 to 255.
Returns
32-bit packed RGB value, which can then be assigned to a variable for later use or passed to the setPixelColor() function. Packed RGB format is predictable, regardless of LED strand color order.

◆ Color() [2/2]

static uint32_t lampda::utils::Color ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  w 
)
static

Convert separate red, green, blue and white values into a single "packed" 32-bit WRGB color.

Parameters
rRed brightness, 0 to 255.
gGreen brightness, 0 to 255.
bBlue brightness, 0 to 255.
wWhite brightness, 0 to 255.
Returns
32-bit packed WRGB value, which can then be assigned to a variable for later use or passed to the setPixelColor() function. Packed WRGB format is predictable, regardless of LED strand color order.

◆ get_gradient()

uint32_t lampda::utils::get_gradient ( const uint32_t  colorStart,
const uint32_t  colorEnd,
const float  level 
)

Return the color gradient between colorStart to colorEnd.

Parameters
[in]colorStartStart color of the gradient
[in]colorEndEnd color of the gradient
[in]levelbetween 0 and 1, the gradient between the two colors

◆ get_random_complementary_color()

uint32_t lampda::utils::get_random_complementary_color ( const uint32_t  color,
const float  tolerance 
)

Compute the complementary color of the given color, with a random variation.

Parameters
[in]colorThe color to find a complement for
[in]tolerancebetween 0 and 1, the variation tolerance. 1 will give a totally random color, 0 will return the base complementary color
Returns
the random complementary color

◆ hash()

template<typename T >
static constexpr uint32_t lampda::utils::hash ( const T  s,
const uint16_t  maxSize = 14,
const uint16_t  off = 0 
)
staticconstexpr

Hash input string into a 32-bit unsigned integer.

This is the xor-variant of the "djb2 hash" in its iterative form, starting from the beginning of the string for simplicity.

Parameters
[in]sZero-terminated input string
[in]maxSize(optional) Maximal byte count to process, defaults to 14
[in]off(optional) Skip the first off bytes, defaults to 0
Remarks
By default, only the first 14 bytes of the string are used!