This commit is contained in:
deckensteuerung 2018-10-21 15:21:06 +02:00
commit 037017ca94
2 changed files with 37 additions and 1 deletions

View File

@ -23,6 +23,7 @@ Apps = [
{"guiname": "Dual moodlight", "name": "bimood", "cmd": "apps/bimood", "persistent": False},
{"guiname": "IDLE", "name": "pixelflut", "cmd": "apps/idle.py", "persistent": False},
{"guiname": "IDLE2", "name": "idlec", "cmd": "apps/idle2"},
<<<<<<< HEAD
{"guiname": "YoutubeDL", "name": "youtubedl", "cmd": "apps/youtubedl.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},
@ -30,6 +31,7 @@ Apps = [
{"guiname": "SkyScrapper", "name": "sky", "cmd": "apps/weather/main.py"},
{"guiname": "Strobo", "name": "strobo", "cmd": "apps/strobo.py", "persistent": False},
{"guiname": "Snake", "name": "snake", "cmd": "apps/snake.py", "persistent": False},
{"guiname": "Strobo", "name": "strobo", "cmd": "apps/strobo.py"},
{"name": "pong", "cmd": "apps/pong.py"},
{"name": "framebuffer", "cmd": ["apps/fbcp", "/dev/fb0"]},
{"name": "gif", "cmd": "apps/gif.sh"},

34
main.py
View File

@ -11,6 +11,7 @@ import time
import sys
import signal
import logging
import math
logging.basicConfig(filename='pixelserver.log',level=config.LogLevel)
@ -79,6 +80,7 @@ class SerialWriter(threading.Thread):
self.cv = threading.Condition()
self.datasource = datasource
self.datasource.addListener(self.cv)
self.updateGamma = False
def run(self):
should_connect = True
@ -93,6 +95,22 @@ class SerialWriter(threading.Thread):
with self.cv:
self.cv.wait(timeout = 1/30)
data = self.datasource.getData()
with self.cv:
if self.updateGamma:
buf = bytearray("\x00")*3*256
r = self.r
g = self.g
b = self.b
for i in range(256):
gr = int(math.pow(i/255, r)*255)
gg = int(math.pow(i/255, g)*255)
gb = int(math.pow(i/255, b)*255)
buf[i] =gr
buf[i+255] = gg
buf[i+511] = gb
ser.write(b"\x02")
ser.write(buf)
self.updateGamma = False
ser.write(b"\01")
ser.write(data)
ser.flush()
@ -108,6 +126,14 @@ class SerialWriter(threading.Thread):
self.cv.notify_all()
super().join()
def setGamma(self, r, g, b):
with self.cv:
self.r = r
self.g = g
self.b = b
self.updateGamma = True
self.cv.notify_all()
class WatchDog(threading.Thread):
def __init__(self, check, action):
super().__init__()
@ -277,6 +303,8 @@ class AppRunner(threading.Thread):
if self.app == None:
return ""
return self.app.getLog()
def setGamma(self, r, g, b):
self.serial.setGamma(r, g, b)
@ -342,6 +370,12 @@ def apps_running():
def index():
return bottle.static_file("index.html", root='html')
#return open("html/index.html").read()
@route("/setgamma/<r>/<g>/<b>")
def setGamma(r, g, b):
r = float(r)
g = float(g)
b = float(b)
runner.setGamma(r, g, b)
run(host=config.WebHost, port=config.WebPort)
running = False