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

@ -23,7 +23,6 @@ Apps = [
{"guiname": "Dual moodlight", "name": "bimood", "cmd": "apps/bimood", "persistent": False}, {"guiname": "Dual moodlight", "name": "bimood", "cmd": "apps/bimood", "persistent": False},
{"guiname": "IDLE", "name": "pixelflut", "cmd": "apps/idle.py", "persistent": False}, {"guiname": "IDLE", "name": "pixelflut", "cmd": "apps/idle.py", "persistent": False},
{"guiname": "IDLE2", "name": "idlec", "cmd": "apps/idle2"}, {"guiname": "IDLE2", "name": "idlec", "cmd": "apps/idle2"},
<<<<<<< HEAD
{"guiname": "YoutubeDL", "name": "youtubedl", "cmd": "apps/youtubedl.sh", "persistent": False}, {"guiname": "YoutubeDL", "name": "youtubedl", "cmd": "apps/youtubedl.sh", "persistent": False},
{"guiname": "Stream", "name": "stream", "cmd": "apps/stream.sh", "persistent": False}, {"guiname": "Stream", "name": "stream", "cmd": "apps/stream.sh", "persistent": False},
{"guiname": "Wget Video/Gif/Images", "name": "wget", "cmd": "apps/wget.sh", "persistent": False}, {"guiname": "Wget Video/Gif/Images", "name": "wget", "cmd": "apps/wget.sh", "persistent": False},

View File

@ -16,6 +16,16 @@
</form> </form>
</div> </div>
<h2>Gamma:</h2>
<div id='container'>
<form id='gammeform' onSubmit="return setgamma()">
Rot: <input id="gammar" value=2.8 /><br/>
Grün: <input id="gammag" value=2.65 /><br/>
Blau: <input id="gammab" value=2.65 /><br/>
<button id="sendgamma">Setzen</button>
</form>
</div>
<h2>Log:</h2> <h2>Log:</h2>
<div id='log'> <div id='log'>
<textarea readonly id='logs' style="width: 500px; height: 500px;"></textarea> <textarea readonly id='logs' style="width: 500px; height: 500px;"></textarea>
@ -91,6 +101,15 @@
return false; return false;
} }
function setgamma(){
let r = document.getElementById('gammar').value;
let g = document.getElementById('gammag').value;
let b = document.getElementById('gammab').value;
let url = "/setgamma/" + r+"/"+g+"/"+b;
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;
@ -106,4 +125,4 @@
</html> </html>

View File

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