-
Notifications
You must be signed in to change notification settings - Fork 56
DriverBase
DriverBase provides the framework on which driver 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 their own drivers.
(num, width = 0, height = 0, c_order = ChannelOrder.RGB, gamma = None)
- num - Number of pixels to be controlled.
- width - Optional: Width of matrix display. If using Matrix, its width property will automatically be set from this value.
- height - Optional: Height of matrix display. If using Matrix, its height property will automatically be set from this value.
- c_order - Optional: Channel order used by the attached display. Can be any of the six options in the ChannelOrder class. See Channel Order for more details.
- gamma - 256 value gamma correction list. The list MUST contain 256 8-bit integer values. Predefined corrections lists can be found in bibliopixel.gamma
For new drivers that inherit from DriverBase, only the num parameter needs to be made available, but it is greatly suggested that the rest are also made available to provide a common interface.
(data)
- data - Pixel data in the format [R0, G0, B0, R1, G1, B1, ...]
The driver update() method is automatically called by the update() method of Strip or Matrix. This method MUST be implemented by new driver classes and is where the pixel data should be pushed to the display.
(brightness)
- brightness - 8-bit (0-255) brightness value.
This method only need be implemented by new drivers if it is for a device that supports brightness control in hardware. If it is implemented, the method must return true to inform Strip or Matrix that brightness control has been passed off to the driver. When setMasterBrightness is called on Strip or Matrix, it will first check if the driver supports it and, if not, will fall back to scaling colors internally.
(data)
- data - Pixel data in the format [R0, G0, B0, R1, G1, B1, ...]
This method should be called byte the driver's update() method. The default implementation in DriverBase will re-order the color channels and apply gamma correction if available. In most cases this is good enough, but the method may be overridden if anything extra is needed. If this method is not called in a new driver's update() method, the c_order and gamma options should not be made available in that driver's init.
Number of LEDs to be controlled by the driver.
256 value gamma correction list. Predefined corrections lists can be found in bibliopixel.gamma.
Currently set channel order being used by the driver.
Width of the matrix controlled by the driver, if set.
Height of the matrix controlled by the driver, if set.
Expected total byte count in the display buffer. Currently this is always numLEDs * 3.
Where the channel and gamma corrected data is placed by _fixData and what should then be used by update() to push to the display. This data buffer is used because some drivers, like LPD8806 require extra data bytes before or after the pixel data and this allows _fixData to just manipulate the pixel data.