create debugging drivers

This commit is contained in:
chrys 2017-10-24 23:35:08 +02:00
parent d4b0525e06
commit 81ea81575d
13 changed files with 271 additions and 39 deletions

View File

@ -5,10 +5,11 @@
# By Chrys, Storm Dragon, and contributers.
from core import debug
from core.brailleDriver import brailleDriver
class driver():
class driver(brailleDriver):
def __init__(self):
self._isInitialized = False
brailleDriver.__init__(self)
self._brl = None
def initialize(self, environment):

View File

@ -0,0 +1,49 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from core.brailleDriver import brailleDriver
class driver(brailleDriver):
def __init__(self):
brailleDriver.__init__(self)
def initialize(self, environment):
self.env = environment
self._isInitialized = True
self.deviceSize = (40,0)
print('Braille Debug Driver: Initialized')
def getDeviceSize(self):
if not self._isInitialized:
return (0,0)
print('Braille Debug Driver: getDeviceSize ' + str(self.deviceSize))
return self.deviceSize
def writeText(self,text):
if not self._isInitialized:
return
print('Braille Debug Driver: writeText:' + str(text))
print('Braille Debug Driver: -----------------------------------')
def connectDevice(self):
print('Braille Debug Driver: connectDevice')
def enterScreen(self, screen):
if not self._isInitialized:
return
print('Braille Debug Driver: enterScreen')
def leveScreen(self):
if not self._isInitialized:
return
print('Braille Debug Driver: leveScreen')
def shutdown(self):
if self._isInitialized:
self.leveScreen()
self._isInitialized = False
print('Braille Debug Driver: Shutdown')

View File

@ -9,48 +9,33 @@ from core import debug
class brailleDriver():
def __init__(self):
self._isInitialized = False
self.printMessages = False
self.deviceSize = None
def initialize(self, environment):
self.env = environment
self.deviceSize = (40,0)
if self.printMessages:
print('BrailleDummyDriver: Initialize')
self._isInitialized = True
def getDeviceSize(self):
if not self._isInitialized:
return (0,0)
if self.printMessages:
print('BrailleDummyDriver: getDeviceSize ' + str(self.deviceSize))
return self.deviceSize
return (0,0)
def writeText(self,text):
if not self._isInitialized:
return
if self.printMessages:
print('BrailleDummyDriver: writeText:' + str(text))
print('BrailleDummyDriver: -----------------------------------')
def connectDevice(self):
if self.printMessages:
print('BrailleDummyDriver: connectDevice')
pass
def enterScreen(self, screen):
if not self._isInitialized:
return
if self.printMessages:
print('BrailleDummyDriver: enterScreen')
def leveScreen(self):
if not self._isInitialized:
return
if self.printMessages:
print('BrailleDummyDriver: leveScreen')
def shutdown(self):
if not self._isInitialized:
return
if self.printMessages:
print('BrailleDummyDriver: Shutdown')
self.leveScreen()
self._isInitialized = False

View File

@ -13,6 +13,8 @@ class inputDriver():
self.env = environment
self._isInitialized = True
def shutdown(self):
if self._initialized:
self.releaseDevices()
self._isInitialized = False
def getInputEvent(self):
time.sleep(0.05)

View File

@ -110,7 +110,7 @@ class outputManager():
self.env['output']['messageOffset'] = {'x':0,'y':0}
self.env['output']['messageText'] = text
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
self.env['runtime']['brailleDriver'].writeText('flush '+ displayText)
else:
if self.env['output']['nextFlush'] < time.time():
if self.env['output']['messageText'] != '':
@ -121,7 +121,7 @@ class outputManager():
x, y, self.env['output']['brlText'] = \
line_utils.getCurrentLine(cursor['x'], cursor['y'], self.env['screen']['newContentText'])
displayText = self.getBrailleTextWithOffset(self.env['screen']['newContentText'], self.env['output']['cursorOffset'], cursor)
self.env['runtime']['brailleDriver'].writeText('notflush'+displayText)
self.env['runtime']['brailleDriver'].writeText('notflush ' + displayText)
else:
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['runtime']['brailleDriver'].writeText('flush'+displayText)

View File

@ -43,8 +43,6 @@ class screenDriver():
return ''
def getFenrirFontSize(self, attribute):
return ''
def getContent(self):
pass
def update(self, trigger='onUpdate'):
pass

View File

@ -8,7 +8,7 @@ from core import debug
class soundDriver():
def __init__(self):
self.volume = 1.0
self.volume = None
self._initialized = False
def initialize(self, environment):
@ -27,7 +27,6 @@ class soundDriver():
if interrupt:
self.cancel()
def playSoundFile(self, filePath, interrupt = True):
if not self._initialized:
return

View File

@ -20,6 +20,7 @@ class speechDriver():
self._isInitialized = True
def shutdown(self):
if self._isInitialized:
self.cancel()
self._isInitialized = False
@ -46,16 +47,16 @@ class speechDriver():
def setVoice(self, voice):
if not self._isInitialized:
return
if not voice:
if not isinstance(voice, float):
return
if voice =='':
if voice == '':
return
self.voice = voice
def setPitch(self, pitch):
if not self._isInitialized:
return
if not pitch:
if not isinstance(pitch, float):
return
if pitch < 0.0:
retrun
@ -65,7 +66,7 @@ class speechDriver():
def setRate(self, rate):
if not self._isInitialized:
return
if not rate:
if not isinstance(rate, float):
return
if rate < 0.0:
retrun
@ -75,24 +76,24 @@ class speechDriver():
def setModule(self, module):
if not self._isInitialized:
return
if not module:
if not isinstance(module, str):
return
if module =='':
if module == '':
return
self.module = module
def setLanguage(self, language):
if not self._isInitialized:
return
if not language:
if not isinstance(language, str):
return
if language =='':
if language == '':
return
self.language = language
def setVolume(self, volume):
if not self._isInitialized:
return
if not volume:
if not isinstance(volume,float):
return
if volume < 0.0:
retrun

View File

@ -0,0 +1,66 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
import time
from core import debug
from core.inputDriver import inputDriver
class driver(inputDriver):
def __init__(self):
inputDriver.__init__(self)
def initialize(self, environment):
self.env = environment
self._initialized = True
print('Input Debug Driver: Initialized')
def shutdown(self):
if self._initialized:
self.releaseDevices()
self._initialized = False
print('Input Debug Driver: Shutdown')
def getInputEvent(self):
time.sleep(0.05)
if not self._initialized:
return None
print('Input Debug Driver: getInputEvent')
return None
def writeEventBuffer(self):
if not self._initialized:
return
print('Input Debug Driver: writeEventBuffer')
def clearEventBuffer(self):
if not self._initialized:
return
del self.env['input']['eventBuffer'][:]
print('Input Debug Driver: clearEventBuffer')
def updateInputDevices(self, force = False, init = False):
if not self._initialized:
return
print('Input Debug Driver: updateInputDevices')
def getLedState(self, led = 0):
if not self._initialized:
return False
return False
def toggleLedState(self, led = 0):
if not self._initialized:
return
print('Input Debug Driver: toggleLedState')
def grabDevices(self):
if not self._initialized:
return
print('Input Debug Driver: grabDevices')
def releaseDevices(self):
if not self._initialized:
return
print('Input Debug Driver: releaseDevices')
def __del__(self):
if self._initialized:
self.releaseDevices()
print('Input Debug Driver: __del__')

View File

@ -13,6 +13,6 @@ class driver(inputDriver):
inputDriver.__init__(self)
def getInputEvent(self):
time.sleep(0.05)
time.sleep(0.1)
if not self._initialized:
return None

View File

@ -0,0 +1,56 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
from core.soundDriver import soundDriver
class driver(soundDriver):
def __init__(self):
soundDriver.__init__(self)
def initialize(self, environment):
self.env = environment
self._initialized = True
print('Sound Debug Driver: Initialized')
def shutdown(self):
if not self._initialized:
return
self.cancel()
self._initialized = False
print('Sound Debug Driver: Shutdown')
def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0):
if not self._initialized:
return
if interrupt:
self.cancel()
print('Sound Debug Driver: playFrequence:' + ' freq:' + str(frequence) + ' duration:' + str(duration) + ' adjustVolume:' + str(adjustVolume) )
print('Sound Debug Driver: -----------------------------------')
def playSoundFile(self, filePath, interrupt = True):
if not self._initialized:
return
if interrupt:
self.cancel()
print('Sound Debug Driver: playSoundFile:' + str(filePath))
print('Sound Debug Driver: -----------------------------------')
def cancel(self):
if not self._initialized:
return
print('Sound Debug Driver: Cancel')
def setCallback(self, callback):
if not self._initialized:
return
print('Sound Debug Driver: setCallback')
def setVolume(self, volume):
if not self._initialized:
return
self.volume = volume
print('Sound Debug Driver: setVolume:' + str(self.volume))

View File

@ -0,0 +1,74 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
# generic driver
from core import debug
from core.speechDriver import speechDriver
class driver(speechDriver):
def __init__(self):
speechDriver.__init__(self
def initialize(self, environment):
self._isInitialized = True
self.env = environment
print('Speech Debug Driver: Iitialized')
def shutdown(self):
if self._isInitialized:
self.cancel()
self._isInitialized = False
print('Speech Debug Driver: Shutdown')
def speak(self,text, queueable=True):
if not self._isInitialized:
return
if not queueable:
self.cancel()
print('Speech Debug Driver: Speak:'+text)
print('Speech Debug Driver: -----------------------------------')
def cancel(self):
if not self._isInitialized:
return
print('Speech Debug Driver: Cancel')
def setCallback(self, callback):
print('Speech Debug Driver: setCallback')
def clear_buffer(self):
if not self._isInitialized:
return
print('Speech Debug Driver: clear_buffer')
def setVoice(self, voice):
if not self._isInitialized:
return
print('Speech Debug Driver: setVoice:' + str(voice))
def setPitch(self, pitch):
if not self._isInitialized:
return
print('Speech Debug Driver: setPitch:' + str(pitch))
def setRate(self, rate):
if not self._isInitialized:
return
print('Speech Debug Driver: setRate:' + str(rate))
def setModule(self, module):
if not self._isInitialized:
return
print('Speech Debug Driver: setModule:' + str(module))
def setLanguage(self, language):
if not self._isInitialized:
return
print('Speech Debug Driver: setLanguage:' + str(language))
def setVolume(self, volume):
if not self._isInitialized:
return
print('Speech Debug Driver: setVolume:' + str(volume))

View File

@ -7,6 +7,7 @@
from core import debug
from core.speechDriver import speechDriver
class driver(speechDriver):
def __init__(self):
speechDriver.__init__(self)