tweak main looop
This commit is contained in:
parent
54cde85c7f
commit
fb63606bfb
@ -5,7 +5,7 @@ class command():
|
|||||||
pass
|
pass
|
||||||
def run(self, environment):
|
def run(self, environment):
|
||||||
pass
|
pass
|
||||||
def setCallback(self, callback)
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
|
@ -8,11 +8,11 @@ from core import screenData
|
|||||||
from core import generalInformation
|
from core import generalInformation
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
'screenData' = screenData.screenData,
|
'screenData': screenData.screenData,
|
||||||
'runtime' = runtime.runtime,
|
'runtime': runtime.runtime,
|
||||||
'generalInformation' = generalInformation.generalInformation,
|
'generalInformation': generalInformation.generalInformation,
|
||||||
'settings' = settings.settings,
|
'settings': settings.settings,
|
||||||
'bindings' = bindings.bindings,
|
'bindings': bindings.bindings,
|
||||||
'soundIcons' = soundIcons.soundIcons,
|
'soundIcons': soundIcons.soundIcons,
|
||||||
'autospeak' = ['speak_delta']
|
'autospeak': ['speak_delta']
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class fenrir():
|
|||||||
self.threadHandleInput.start()
|
self.threadHandleInput.start()
|
||||||
self.threadCommandQueue.start()
|
self.threadCommandQueue.start()
|
||||||
while(self.environment['generalInformation']['running']):
|
while(self.environment['generalInformation']['running']):
|
||||||
time.sleep(2)
|
time.sleep(0.2)
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
def handleInput(self):
|
def handleInput(self):
|
||||||
|
@ -12,7 +12,7 @@ class screenManager():
|
|||||||
def analyzeScreen(self, environment):
|
def analyzeScreen(self, environment):
|
||||||
# read screen
|
# read screen
|
||||||
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
|
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
|
||||||
runtime['newTTY'] = currTTY.read()[3:-1]
|
environment['screenData']['newTTY'] = currTTY.read()[3:-1]
|
||||||
currTTY.close()
|
currTTY.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -44,7 +44,7 @@ class screenManager():
|
|||||||
if environment['screenData']['oldContentBytes'] != environment['screenData']['newContentBytes']:
|
if environment['screenData']['oldContentBytes'] != environment['screenData']['newContentBytes']:
|
||||||
if ((len(environment['screenData']['delta']) < 4) or environment['screenData']['oldTTY'] != environment['screenData']['newTTY']):
|
if ((len(environment['screenData']['delta']) < 4) or environment['screenData']['oldTTY'] != environment['screenData']['newTTY']):
|
||||||
environment['runtime']['speechDriver'].cancel()
|
environment['runtime']['speechDriver'].cancel()
|
||||||
diff = difflib.ndiff(runtime['oldContentText'], environment['screenData']['newContentText'])
|
diff = difflib.ndiff(environment['screenData']['oldContentText'], environment['screenData']['newContentText'])
|
||||||
environment['screenData']['delta'] = ''.join(x[2:] for x in diff if x.startswith('+ '))
|
environment['screenData']['delta'] = ''.join(x[2:] for x in diff if x.startswith('+ '))
|
||||||
environment['runtime']['speechDriver'].speak(environment['screenData']['delta'])
|
environment['runtime']['speechDriver'].speak(environment['screenData']['delta'])
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class speech():
|
|||||||
self._es.cancel()
|
self._es.cancel()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setCallback(self, callback)
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clear_buffer(self):
|
def clear_buffer(self):
|
||||||
|
@ -27,7 +27,7 @@ class speech():
|
|||||||
self._sd.cancel()
|
self._sd.cancel()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setCallback(self, callback)
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clear_buffer(self):
|
def clear_buffer(self):
|
||||||
@ -71,7 +71,10 @@ class speech():
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
if not self._isInitialized:
|
||||||
|
return False
|
||||||
|
self._isInitialized = False
|
||||||
self.cancel()
|
self.cancel()
|
||||||
self._sd.close()
|
self._sd.close()
|
||||||
|
return True
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# Debugger module for the Fenrir screen reader.
|
# Debugger module for the Fenrir screen reader.
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
class debugLevel(Enum):
|
class debugLevel(Enum):
|
||||||
DEACTIVE = 0
|
DEACTIVE = 0
|
||||||
ERROR = 1
|
ERROR = 1
|
||||||
@ -31,9 +32,9 @@ class debug():
|
|||||||
else:
|
else:
|
||||||
if not self._fileOpened:
|
if not self._fileOpened:
|
||||||
self.openDebugFile()
|
self.openDebugFile()
|
||||||
self.writeLog(environment, text, level):
|
self.writeLog(environment, text, level)
|
||||||
|
|
||||||
def writeLog(self, environment, text, level:
|
def writeLog(self, environment, text, level = debugLevel.DEACTIVE):
|
||||||
if envirionment['settings']['debugLevel'] < level:
|
if envirionment['settings']['debugLevel'] < level:
|
||||||
return False
|
return False
|
||||||
if not self._fileOpened:
|
if not self._fileOpened:
|
||||||
@ -54,7 +55,7 @@ class debug():
|
|||||||
def setDebugFile(self, fileName):
|
def setDebugFile(self, fileName):
|
||||||
self.closeDebugFile()
|
self.closeDebugFile()
|
||||||
if self._fileOpened:
|
if self._fileOpened:
|
||||||
self.openDebugFile(self, fileName):
|
self.openDebugFile(self, fileName)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user