2016-07-07 13:43:31 -04:00
|
|
|
#!/bin/python
|
|
|
|
|
|
|
|
# Fenrir TTY screen reader
|
|
|
|
# By Chrys, Storm Dragon, and contributers.
|
|
|
|
|
2016-07-08 03:49:59 -04:00
|
|
|
import os, sys, time, signal
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
if not os.getcwd() in sys.path:
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
|
2016-07-07 17:59:21 -04:00
|
|
|
from threading import Thread
|
2016-07-07 13:43:31 -04:00
|
|
|
from core import environment
|
2016-07-07 15:40:10 -04:00
|
|
|
from core import inputManager
|
2016-07-07 13:43:31 -04:00
|
|
|
from utils import debug
|
2016-07-07 15:40:10 -04:00
|
|
|
|
2016-07-07 13:43:31 -04:00
|
|
|
from speech import espeak as es
|
|
|
|
from speech import speechd as sd
|
|
|
|
from screen import linux as lx
|
|
|
|
|
|
|
|
class fenrir():
|
|
|
|
def __init__(self):
|
2016-07-07 17:59:21 -04:00
|
|
|
self.threadUpdateScreen = None
|
|
|
|
self.threadHandleInput = None
|
2016-07-07 18:07:03 -04:00
|
|
|
self.threadHandleCommandQueue = None
|
2016-07-08 05:29:50 -04:00
|
|
|
self.environment = environment.environment
|
|
|
|
self.environment['runtime']['inputManager'] = inputManager.inputManager()
|
2016-07-08 06:30:47 -04:00
|
|
|
self.environment['runtime']['debug'] = debug.debug()
|
2016-07-08 03:49:59 -04:00
|
|
|
signal.signal(signal.SIGINT, self.captureSignal)
|
|
|
|
|
2016-07-07 15:40:10 -04:00
|
|
|
# the following hard coded, in future we have a config loader
|
2016-07-08 05:29:50 -04:00
|
|
|
self.environment['runtime']['speechDriver'] = sd.speech()
|
|
|
|
self.environment['runtime']['screenDriver'] = lx.screenManager()
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
def proceed(self):
|
2016-07-07 17:59:21 -04:00
|
|
|
self.threadUpdateScreen = Thread(target=self.updateScreen, args=())
|
|
|
|
self.threadHandleInput = Thread(target=self.handleInput, args=())
|
2016-07-07 18:07:03 -04:00
|
|
|
self.threadCommandQueue = Thread(target=self.handleCommandQueue, args=())
|
2016-07-07 17:59:21 -04:00
|
|
|
self.threadUpdateScreen.start()
|
|
|
|
self.threadHandleInput.start()
|
2016-07-07 18:07:03 -04:00
|
|
|
self.threadCommandQueue.start()
|
2016-07-08 05:29:50 -04:00
|
|
|
while(self.environment['generalInformation']['running']):
|
2016-07-08 08:29:35 -04:00
|
|
|
time.sleep(0.2)
|
2016-07-07 15:53:37 -04:00
|
|
|
self.shutdown()
|
|
|
|
|
2016-07-07 17:59:21 -04:00
|
|
|
def handleInput(self):
|
2016-07-08 05:29:50 -04:00
|
|
|
while(self.environment['generalInformation']['running']):
|
|
|
|
self.environment = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
2016-07-07 17:59:21 -04:00
|
|
|
|
|
|
|
def updateScreen(self):
|
2016-07-08 05:29:50 -04:00
|
|
|
while(self.environment['generalInformation']['running']):
|
|
|
|
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment)
|
2016-07-07 17:59:21 -04:00
|
|
|
|
2016-07-07 18:07:03 -04:00
|
|
|
def handleCommandQueue(self):
|
2016-07-08 05:29:50 -04:00
|
|
|
while(self.environment['generalInformation']['running']):
|
|
|
|
self.environment = self.environment # command queue here
|
2016-07-07 18:07:03 -04:00
|
|
|
|
2016-07-07 13:56:46 -04:00
|
|
|
def shutdown(self):
|
2016-07-08 05:29:50 -04:00
|
|
|
self.environment['generalInformation']['running'] = False
|
|
|
|
if self.environment['runtime']['speechDriver'] != None:
|
|
|
|
self.environment['runtime']['speechDriver'].shutdown()
|
|
|
|
if self.environment['runtime']['debug'] != None:
|
|
|
|
self.environment['runtime']['debug'].closeDebugFile()
|
2016-07-08 06:30:47 -04:00
|
|
|
if self.environment['runtime']['soundDriver'] != None:
|
|
|
|
self.environment['runtime']['soundDriver'].shutdown()
|
2016-07-08 03:49:59 -04:00
|
|
|
|
|
|
|
def captureSignal(self, siginit, frame):
|
|
|
|
self.shutdown()
|
2016-07-07 13:43:31 -04:00
|
|
|
|
|
|
|
app = fenrir()
|
|
|
|
app.proceed()
|