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