kk
Gabriel Morell





Filtering the output
posted June 20, 2015, 1 p.m.
all entries

So now that I had a base twisted project, a working loop, and some rudimentary lighting programs, I decided to look into output filtering,

In my mind output filters can do any number of mathematical operation to the calculated output. Things like inverting the colors, reordering the output channels. Output filtering is done at the end as part of the write() function before the arrays are converted into bytes and shoved into the output device.

The entire output buffer is passed into a class and the do_filter() function is called. One of the simplest filters written is the RGB to GRB which I used for a ws2811 string that had the channels inverted:

1
2
3
4
5
6
class RGBtoGRBLambentOutputFilter(object):
    _desc = "RGB -> GRB"

    def do_filter(self, rgbvals):
        val = [rgbvals[1], rgbvals[0], rgbvals[2]]
        return val

Based on this I wrote a few useful filters including, inverted colors, pastels, saturated, RGB=>GRB conversion. I also considered output filters that only modify a few pixels in the array, such as a weather overlay filter, and time until next train filter.

Building the Aether
Discovering New Instances