adafruit_fancyled
¶
TODO(description)
- Author(s): PaintYourDragon
-
adafruit_fancyled.
clamp
(val, lower, upper)[source]¶ Constrain value within a numeric range (inclusive).
-
adafruit_fancyled.
denormalize
(val, inplace=False)[source]¶ Convert normalized (0.0 to 1.0) value to 8-bit (0 to 255) value ACCEPTS: float, 0.0 to 1.0 range or a list or tuple of floats. In list
case, ‘inplace’ can be used to control whether the original list is modified (True) or a new list is generated and returned (False).RETURNS: integer, 0 to 255 range, or list of integers (or None if inplace).
-
adafruit_fancyled.
expand_gradient
(grad, length)[source]¶ Convert gradient palette into standard equal-interval palette. ACCEPTS: List or tuple of of 2-element lists/tuples containing position
(0.0 to 1.0) and color (packed int, CRGB or CHSV). It’s OK if the list/tuple elements are either lists OR tuples, but don’t mix and match lists and tuples – use all one or the other.RETURNS: CRGB list, can be used with palette_lookup() function.
-
adafruit_fancyled.
gamma_adjust
(val, gamma_value=None, brightness=1.0, inplace=False)[source]¶ - Provides gamma adjustment for single values, CRGB and CHSV types
- and lists of any of these.
- ACCEPTS: One of three ways:
- A single normalized level (0.0 to 1.0) and optional gamma-adjustment factor (float usu. > 1.0, default if unspecified is GFACTOR) and brightness (float 0.0 to 1.0, default is 1.0).
- A single CRGB or CHSV type, optional single gamma factor OR a (R,G,B) gamma tuple (3 values usu. > 1.0), optional single brightness factor OR a (R,G,B) brightness tuple. The input tuples are RGB even when a CHSV color is passed.
- A list or tuple of normalized levels, CRGB or CHSV types (and optional gamma and brightness levels or tuples applied to all).
In cases 2 and 3, if the input is a list (NOT a tuple!), the ‘inplace’ flag determines whether a new tuple/list is calculated and returned, or the existing value is modified in-place. By default this is ‘False’. If you try to inplace-modify a tuple, there will be…trouble.
- RETURNS: Corresponding to above cases:
- Single normalized gamma-corrected brightness level (0.0 to 1.0).
- A normalized gamma-corrected CRGB type (NOT CHSV!).
- A list of gamma-corrected values or CRGB types (NOT CHSV!).
In cases 2 and 3, there is NO return value if ‘inplace’ is True – the original values are modified.
-
adafruit_fancyled.
mix
(color1, color2, weight2=0.5)[source]¶ Blend between two colors using given ratio. ACCEPTS: two colors (each may be CRGB, CHSV or packed integer),
and weighting (0.0 to 1.0) of second color.RETURNS: CRGB color in most cases, CHSV if both inputs are CHSV.
-
adafruit_fancyled.
normalize
(val, inplace=False)[source]¶ Convert 8-bit (0 to 255) value to normalized (0.0 to 1.0) value. ACCEPTS: integer, 0 to 255 range (input is clamped) or a list or tuple
of integers. In list case, ‘inplace’ can be used to control whether the original list is modified (True) or a new list is generated and returned (False).RETURNS: float, 0.0 to 1.0 range, or list of floats (or None if inplace).
-
adafruit_fancyled.
pack
(val)[source]¶ ‘Pack’ a CRGB or CHSV color into a 24-bit RGB integer. ACCEPTS: CRGB or CHSV color. RETURNS: 24-bit integer a la 0x00RRGGBB.