LEDBase - adammhaile/ae45LhX89i GitHub Wiki

class bibliopixel.LEDBase

LEDBase provides the framework on which the LEDStrip and LEDMatrix classes build. It cannot be used directly by itself. This is here to document the methods it provides for the classes built upon it and for anyone wanting to build upon it directly. LEDBase actually lives at bibliopixel.led.LEDBase but can be accessed at bibiliopixel.LEDBase for convenience.

__init__(driver)

  • driver - A driver class that inherits from bibliopixel.drivers.DriverBase. See the Drivers page for more info.

_get_base(pixel)

  • pixel - Integer index of pixel in the buffer array.

Returns RGB tuple, (r,g,b), if pixel is in bounds. Otherwise returns (0,0,0).

Not intended to be used directly. Provides basis for LEDStrip and LEDMatrix calls.

_set_base(pixel, color)

  • pixel - Integer index of pixel in the buffer array.
  • color - RGB tuple, (r,g,b), representing the color to set.

Not intended to be used directly. Provides basis for LEDStrip and LEDMatrix calls.

update()

Pushes the current pixel buffer to the loaded driver. Callable from LEDStrip and LEDMatrix.

setBuffer(buf)

  • buf - Pre-generated display buffer that must be in the format [R0, G0, B0, R1, G1, B1, ...] and contain exactly bufByteCount (numLEDs*3) number of values.

Use Caution! - setBuffer is provided for speed but bypasses rotation, brightness, and color channel (depending on the driver) control. It will raise ValueError if the buffer length is not the required size.

setMasterBrightness(bright)

  • bright - An 8-bit (0-255) integer value to scale the brightness by.

Callable from LEDStrip and LEDMatrix. This will attempt to pass the brightness setting to the loaded driver. Returns True if the driver supports brightness directly, otherwise returns False. In many cases, sending the brightness to the driver can be preferred. For example, some driver chipsets support power levels directly, allowing a brightness to be set without loosing fidelity of the color value. For example, if the brightness value is set to 128 and the driver does not support it, all color values are simply scaled by 50%, also cutting the number of possible colors by 50%. Chipsets that support direct power management have the ability to decrease brightness while maintaining the full color-space. In some instances, passing the brightness to the driver can provide faster scaling operations, if supported by the driving device.

setRGB(pixel, r, g, b)

  • pixel - Integer index of pixel in the buffer array.
  • r - 8-bit (0-255) Red color component.
  • g - 8-bit (0-255) Green color component.
  • b - 8-bit (0-255) Blue color component.

Callable from LEDStrip and LEDMatrix. Convenience method for setting color with individual components instead of RGB tuple.

setHSV(pixel, hsv)

  • pixel - Integer index of pixel in the buffer array.
  • hsv - 8-bit HSV tuple (h,s,v)

Callable from LEDStrip and LEDMatrix. Convenience method for setting color with an 8-bit HSV tuple value.

setOff(pixel)

  • pixel - Integer index of pixel in the buffer array.

Callable from LEDStrip and LEDMatrix. Convenience method for setting pixel to off.

all_off()

Callable from LEDStrip and LEDMatrix. High performance convenience method for clearing the entire buffer.

Properties


driver

Callable from LEDStrip and LEDMatrix. The currently loaded driver instance.

numLEDs

Callable from LEDStrip and LEDMatrix. Total number of LEDs based on values provided by the driver.

bufByteCount

Callable from LEDStrip and LEDMatrix. Total byte count in the display buffer. Currently this is always numLEDs * 3.

lastIndex

Callable from LEDStrip and LEDMatrix. The last valid pixel index accepted by methods like _set_base

buffer

Callable from LEDStrip and LEDMatrix. The current display buffer, in the format [R0, G0, B0, R1, G1, B1, ...]. *Use caution. It is not recommended to modify this directly. Use setBuffer instead.

masterBrightness

Callable from LEDStrip and LEDMatrix. The currently set 8-bit master brightness value. If setMasterBrightness returned True and the driver took over brightness control, this will always be 255.