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

View File

@ -5,6 +5,8 @@ ScreenX = 80
#height #height
ScreenY = 40 ScreenY = 40
DefaultBrightness = 1.0
Serial = "/dev/ttyACM0" Serial = "/dev/ttyACM0"
# kills app after some seconds if it sends no data # kills app after some seconds if it sends no data

View File

@ -16,6 +16,14 @@
</form> </form>
</div> </div>
<h2>Brightness:</h2>
<div id='container'>
<form id='brightnessform' onSubmit="return setbrightness()">
Rot: <input id="brightness" value=1.0 /><br/>
<button id="sendbrightness">Setzen</button>
</form>
</div>
<h2>Gamma:</h2> <h2>Gamma:</h2>
<div id='container'> <div id='container'>
<form id='gammeform' onSubmit="return setgamma()"> <form id='gammeform' onSubmit="return setgamma()">
@ -110,6 +118,13 @@
return false; return false;
} }
function setbrightness(){
let i = document.getElementById('brightness').value;
let url = "/setbrightness/" + i;
getRaw(url, function test(){});
return false;
}
function updateLog(){ function updateLog(){
getRaw("/apps/log", function(text){ getRaw("/apps/log", function(text){
document.getElementById('logs').innerText = text; document.getElementById('logs').innerText = text;

13
main.py
View File

@ -222,6 +222,7 @@ class AppRunner(threading.Thread):
super().__init__() super().__init__()
self.currentApp = -1 self.currentApp = -1
self.requestedApp = 0 self.requestedApp = 0
self.intensity = config.DefaultBrightness
self.app = None self.app = None
self.cv = threading.Condition() self.cv = threading.Condition()
self.param = "" self.param = ""
@ -268,7 +269,9 @@ class AppRunner(threading.Thread):
if self.requestedApp != None: if self.requestedApp != None:
self.updateApp() self.updateApp()
self.requestedApp = None 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.datasource.pushData(data)
self.cv.wait() self.cv.wait()
self.serial.join() self.serial.join()
@ -349,6 +352,14 @@ def setGamma(r, g, b):
runner.setGamma(r, g, b) runner.setGamma(r, g, b)
return "ok" 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 # # Startup #
######################################################################## ########################################################################