Setting gamma kindof works

This commit is contained in:
deckensteuerung
2018-10-21 15:55:12 +02:00
parent 037017ca94
commit ea653b6840
3 changed files with 25 additions and 3 deletions

View File

@@ -97,7 +97,8 @@ class SerialWriter(threading.Thread):
data = self.datasource.getData()
with self.cv:
if self.updateGamma:
buf = bytearray("\x00")*3*256
buf = bytearray(b"\x00")*3*256
self.updateGamma = False
r = self.r
g = self.g
b = self.b
@@ -105,6 +106,9 @@ class SerialWriter(threading.Thread):
gr = int(math.pow(i/255, r)*255)
gg = int(math.pow(i/255, g)*255)
gb = int(math.pow(i/255, b)*255)
assert gr >= 0 and gr <= 255
assert gg >= 0 and gg <= 255
assert gb >= 0 and gb <= 255
buf[i] =gr
buf[i+255] = gg
buf[i+511] = gb