mirror of
https://github.com/Hopiu/rpi-rgb-led-matrix.git
synced 2026-04-08 00:51:08 +00:00
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
36 lines
No EOL
986 B
Python
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() |