leds - LEDs

The leds module provides functions to interact with card10’s RGB LEDs. This is the 11 LEDs above the display and 4 LEDs on the underside of the top-board, in the four corners.

leds.BOTTOM_LEFT = 11

ID of the LED in the bottom left corner.

leds.BOTTOM_RIGHT = 12

ID of the LED in the bottom right corner.

leds.TOP_RIGHT = 13

ID of the LED in the top right corner.

leds.TOP_LEFT = 14

ID of the LED in the top left corner.

leds.update()[source]

Updates the RGB LEDs.

This will apply changes that have been set with leds.prep() or leds.prep_hsv(). The LEDs can be only updated in bulk, so using this approach instead of leds.set() or leds.set_hsv() significantly reduces the load on the corresponding hardware bus.

leds.clear()[source]

Turns all LEDs off.

Does not reactivate powersave if it has been deactivated, in which case ~15mA will be wasted.

leds.set_flashlight(on)[source]

Turn on the bright side LED.

This LED can serve as a flashlight if worn on the left wrist or as a rad tattoo illuminator if worn on the right wrist.

Warning

Because of a small error in the Harmonic Board layout, we could not populate the flashlight LEDs in the production run. You can handsolder it, though you have to reverse the direction.

Parameters

on (bool) – Side LED on if True.

leds.set_rocket(led, value)[source]

Set brightness of one of the rocket LEDs.

Parameters
  • led (int) –

    Choose your rocket!

    ID

    Color

    Location

    0

    Blue

    Left

    1

    Yellow

    Top

    2

    Green

    Right

  • value (int) – Brightness of LED (value between 0 and 31).

leds.get_rocket(led)[source]

Get brightness of one of the rocket LEDs.

Parameters

led (int) –

Choose your rocket!

ID

Color

Location

0

Blue

Left

1

Yellow

Top

2

Green

Right

Return type

int

Returns

Brightness of LED (value between 0 and 31).

New in version 1.10.

leds.dim_top(value)[source]

Set global brightness for top RGB LEDs.

Parameters

value (int) – Brightness. Default = 1, Range = 1..8

leds.dim_bottom(value)[source]

Set global brightness for bottom RGB LEDs.

Parameters

value (int) – Brightness. Default = 8, Range = 1..8

leds.prep(led, color)[source]

Prepare am RGB LED to be set to an RGB value.

Changes are applied upon calling leds.update(). This is faster than individual leds.set() or leds.set_hsv() calls in case of multiple changes.

Parameters
  • led (int) – Which LED to prepare. 0-10 are the LEDs on the top and 11-14 are the 4 “ambient” LEDs

  • color ([r,g,b]) – RGB triplet

leds.prep_hsv(led, color)[source]

Prepare an RGB LED to be set to an HSV value.

Changes are applied upon calling leds.update(). This is faster than individual leds.set() or leds.set_hsv() calls in case of multiple changes.

Parameters
  • led (int) – Which LED to prepare. 0-10 are the LEDs on the top and 11-14 are the 4 “ambient” LEDs

  • color ([h,s,v]) – HSV triplet

leds.set(led, color)[source]

Set an RGB LED to an RGB value.

Parameters
  • led (int) – Which LED to set. 0-10 are the LEDs on the top and 11-14 are the 4 “ambient” LEDs

  • color ([r,g,b]) – RGB triplet

leds.get_rgb(led)[source]

Get the current RGB value for an RGB LED.

Parameters

led (int) – Which LED to set. 0-10 are the LEDs on the top and 11-14 are the 4 “ambient” LEDs

Return [r,g,b] color

RGB triplet

New in version 1.10.

leds.set_hsv(led, color)[source]

Prepare an RGB LED to be set to an HSV value.

Parameters
  • led (int) – Which LED to set. 0-10 are the LEDs on the top and 11-14 are the 4 “ambient” LEDs

  • color ([h,s,v]) – HSV triplet

leds.set_all(colors)[source]

Set multiple RGB LEDs to RGB values.

Filling starts at LED0 ascending.

Example:

import leds, color

# 1st red, 2nd green & 3rd blue:
leds.set_all([color.RED, color.GREEN, color.BLUE])
Parameters

colors – List of RGB triplets

leds.set_all_hsv(colors)[source]

Set multiple RGB LEDs to HSV values.

Filling starts at LED0 ascending.

Parameters

colors – List of HSV triplets

leds.gay(value=0.5)[source]

Gamma Adjust Yassistant. Prints a rainbow.

Recommended calibration prodecure:

import leds

leds.gay(1)
# adjust gain for uniform brightness
leds.gamma_rgb(channel=..., gain=...)

leds.gay(0.5)
# adjust power~4 for uniform brightness
leds.gamma_rgb(channel=..., power=...)
Parameters

value – Brightness. Default = 0.5

leds.set_powersave(eco=True)[source]

Enable or disable powersave mode.

Even when set to zero, the RGB LEDs still individually consume ~1mA. Powersave intelligently switches the supply power in groups. This introduces delays in the magnitude of ~10us, so it can be disabled for high speed applications such as POV.

Parameters

eco (bool) – Activates powersave if True, disables it when False.

leds.set_gamma(power=4.0)[source]

Applies same power function gamma correction to all RGB channels.

Parameters

power (float) – Exponent of power function.

leds.set_gamma_rgb(channel, power=4.0, gain=1.0)[source]

Applies power function gamma correction with optional amplification to a single RGB channel.

Parameters
  • channel (int) – RGB channel to be adjusted. 0->Red, 1->Green, 2->Blue.

  • power (float) – Exponent of power function.

  • gain (float) – Amplification of channel. Values above 1.0 might cause overflow.

ledfx - LED Effects

ledfx.col_cor(colors, brightness=1, gamma=1)[source]

Gamma and brightness correction for the RGB channels

ledfx.halo(colors)[source]

Set the four bottom/side LEDs to colors corresponding to the color spectrum on the outermost of the top 11 LEDs.

ledfx.kitt(cycles=100, delay=80, power=10, minimum=0.3, rgb=[255, 0, 0], spectrum=[], halo=False)[source]

LED Animation. Knight rider-Style.

Parameters
  • cycles (int) – Amount of cycles for the animation

  • delay (int) – Time in microseconds until the animation moves on (Inverse of Framerate).

  • power (int) – Shape of your brightness curve. Bigger values make a steeper curve, smaller values make the curve wider.

  • minimum (float) – Minimal brightness.

  • rgb ([r,g,b]) – If you don’t enter a spectrum this is the color used.

  • spectrum (list) – A color spectrum consisting of up to 11 RGB-Value-Lists (e.g. [[255,255,255], [0,0,0], [255,255,255], ...] ). If you use less, the animation will be less wide.

  • halo (func) – Halo function. See ledfx.halo().