More flexible apps
This commit is contained in:
parent
8b7a34956b
commit
b822fb9c1c
@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
#width
|
#width
|
||||||
ScreenX = 24
|
ScreenX = 24
|
||||||
@ -9,12 +10,14 @@ Serial = "/dev/ttyACM0"
|
|||||||
# kills app after some seconds if it sends no data
|
# kills app after some seconds if it sends no data
|
||||||
NoDataTimeout = 20
|
NoDataTimeout = 20
|
||||||
|
|
||||||
|
LogLevel = logging.DEBUG
|
||||||
|
|
||||||
UseGui = True
|
UseGui = True
|
||||||
GuiScaleFactor = 10
|
GuiScaleFactor = 10
|
||||||
|
|
||||||
# first app is always running in IDLE
|
# first app is always running in IDLE
|
||||||
Apps = [
|
Apps = [
|
||||||
{"name": "pixelflut", "cmd": "apps/idle.py", "permanent": True},
|
{"name": "pixelflut", "cmd": "apps/idle.py", "permanent": True},
|
||||||
{"name": "framebuffer", "cmd": "apps/framebuffercp"},
|
{"name": "framebuffer", "cmd": ["apps/fbcp", "/dev/fb0"]},
|
||||||
{"name": "play_youtube", "cmd": "apps/play_youtube.sh"}
|
{"name": "play_youtube", "cmd": "apps/play_youtube.sh"}
|
||||||
]
|
]
|
28
main.py
28
main.py
@ -21,9 +21,11 @@ if config.UseGui:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.data = b"\x00"*config.ScreenX*config.ScreenY*3
|
self.data = b"\x00"*config.ScreenX*config.ScreenY*3
|
||||||
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
def setData(self, data):
|
def setData(self, data):
|
||||||
self.data = data
|
with self.lock:
|
||||||
|
self.data = data
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
global running
|
global running
|
||||||
@ -37,14 +39,18 @@ if config.UseGui:
|
|||||||
logging.debug("GUI quits app")
|
logging.debug("GUI quits app")
|
||||||
running = False
|
running = False
|
||||||
screen.fill((0, 255, 0))
|
screen.fill((0, 255, 0))
|
||||||
for x in range(config.ScreenX):
|
with self.lock:
|
||||||
for y in range(config.ScreenY):
|
try:
|
||||||
i = x+y*config.ScreenX
|
for x in range(config.ScreenX):
|
||||||
r = (self.data[i*3+0])
|
for y in range(config.ScreenY):
|
||||||
g = (self.data[i*3+1])
|
i = x+y*config.ScreenX
|
||||||
b = (self.data[i*3+2])
|
r = (self.data[i*3+0])
|
||||||
|
g = (self.data[i*3+1])
|
||||||
|
b = (self.data[i*3+2])
|
||||||
|
|
||||||
pygame.draw.rect(screen, (r, g, b), pygame.Rect(sf*x, sf*y, sf, sf))
|
pygame.draw.rect(screen, (r, g, b), pygame.Rect(sf*x, sf*y, sf, sf))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
logging.info("Closing GUI")
|
logging.info("Closing GUI")
|
||||||
|
|
||||||
@ -155,7 +161,11 @@ class AppRunner(threading.Thread):
|
|||||||
if self.app != None:
|
if self.app != None:
|
||||||
self.app.terminate()
|
self.app.terminate()
|
||||||
self.app.stderr.close()
|
self.app.stderr.close()
|
||||||
args = [os.getcwd()+"/"+config.Apps[self.requestedApp]["cmd"], str(config.ScreenX), str(config.ScreenY), self.param]
|
cmd = config.Apps[self.requestedApp]["cmd"]
|
||||||
|
logging.debug(str(cmd))
|
||||||
|
if type(cmd) != list:
|
||||||
|
cmd = [cmd,]
|
||||||
|
args = cmd+[str(config.ScreenX), str(config.ScreenY), self.param]
|
||||||
self.app = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
self.app = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
|
||||||
self.logreader.clear()
|
self.logreader.clear()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user