Added global brightness controll

This commit is contained in:
Andreas Völker
2019-01-01 12:49:26 +01:00
parent 50f8dd29f7
commit 4da4c93a3e
3 changed files with 29 additions and 1 deletions

13
main.py
View File

@@ -222,6 +222,7 @@ class AppRunner(threading.Thread):
super().__init__()
self.currentApp = -1
self.requestedApp = 0
self.intensity = config.DefaultBrightness
self.app = None
self.cv = threading.Condition()
self.param = ""
@@ -268,7 +269,9 @@ class AppRunner(threading.Thread):
if self.requestedApp != None:
self.updateApp()
self.requestedApp = None
data = self.app.datasource.getData()
data = bytearray(self.app.datasource.getData())
for i in range(len(data)):
data[i] = int(data[i]*self.intensity)
self.datasource.pushData(data)
self.cv.wait()
self.serial.join()
@@ -349,6 +352,14 @@ def setGamma(r, g, b):
runner.setGamma(r, g, b)
return "ok"
@route("/setbrightness/<i>")
def setGamma(i):
i = float(i)
if i < 0 or i > 1:
return "bad_value"
runner.intensity = i
return "ok"
########################################################################
# Startup #
########################################################################