rpi-rgb-led-matrix/python/samples/pulsing-brightness.py
Saij f5e779ae05 Remove -j parameter (doesn't exist anymore)
Implemented SetBrightness function
Rewritten SetBrightness function (only first idea at the moment)
Use CIE1931 to modify brightness
Adding new function to python bindings
Fixed bug with CIE1931 lookup
- Adding brightness control to python library
- Adding new python sample for brightness control
Fixed bug without CIE1931 correction
Fixed typings
2015-07-06 09:28:12 +02:00

36 lines
No EOL
986 B
Python

#!/usr/bin/env python
from samplebase import SampleBase
import time
class GrayscaleBlock(SampleBase):
def __init__(self, *args, **kwargs):
super(GrayscaleBlock, self).__init__(*args, **kwargs)
def Run(self):
max_brightness = self.matrix.brightness
count = 0
c = 255
while (True):
if self.matrix.brightness < 1:
self.matrix.brightness = max_brightness
count += 1
else:
self.matrix.brightness -= 1
if count % 4 == 0:
self.matrix.Fill(c, 0, 0)
elif count % 4 == 1:
self.matrix.Fill(0, c, 0)
elif count % 4 == 2:
self.matrix.Fill(0, 0, c)
elif count % 4 == 3:
self.matrix.Fill(c, c, c)
self.usleep(20 * 1000)
# Main function
if __name__ == "__main__":
parser = GrayscaleBlock()
if (not parser.process()):
parser.print_help()