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. # By Chrys, Storm Dragon, and contributers.
from core import debug from core import debug
from core.brailleDriver import brailleDriver
class driver(): class driver(brailleDriver):
def __init__(self): def __init__(self):
self._isInitialized = False brailleDriver.__init__(self)
self._brl = None self._brl = None
def initialize(self, environment): 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(): class brailleDriver():
def __init__(self): def __init__(self):
self._isInitialized = False self._isInitialized = False
self.printMessages = False self.deviceSize = None
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
self.deviceSize = (40,0)
if self.printMessages:
print('BrailleDummyDriver: Initialize')
self._isInitialized = True self._isInitialized = True
def getDeviceSize(self): def getDeviceSize(self):
if not self._isInitialized: if not self._isInitialized:
return (0,0) return (0,0)
if self.printMessages: return (0,0)
print('BrailleDummyDriver: getDeviceSize ' + str(self.deviceSize))
return self.deviceSize
def writeText(self,text): def writeText(self,text):
if not self._isInitialized: if not self._isInitialized:
return return
if self.printMessages:
print('BrailleDummyDriver: writeText:' + str(text))
print('BrailleDummyDriver: -----------------------------------')
def connectDevice(self): def connectDevice(self):
if self.printMessages: pass
print('BrailleDummyDriver: connectDevice')
def enterScreen(self, screen): def enterScreen(self, screen):
if not self._isInitialized: if not self._isInitialized:
return return
if self.printMessages:
print('BrailleDummyDriver: enterScreen')
def leveScreen(self): def leveScreen(self):
if not self._isInitialized: if not self._isInitialized:
return return
if self.printMessages:
print('BrailleDummyDriver: leveScreen')
def shutdown(self): def shutdown(self):
if not self._isInitialized: if not self._isInitialized:
return return
if self.printMessages: self.leveScreen()
print('BrailleDummyDriver: Shutdown')
self._isInitialized = False self._isInitialized = False

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,8 @@ class speechDriver():
self._isInitialized = True self._isInitialized = True
def shutdown(self): def shutdown(self):
self.cancel() if self._isInitialized:
self.cancel()
self._isInitialized = False self._isInitialized = False
def speak(self,text, queueable=True): def speak(self,text, queueable=True):
@ -28,7 +29,7 @@ class speechDriver():
return return
if not queueable: if not queueable:
self.cancel() self.cancel()
def cancel(self): def cancel(self):
if not self._isInitialized: if not self._isInitialized:
return return
@ -46,16 +47,16 @@ class speechDriver():
def setVoice(self, voice): def setVoice(self, voice):
if not self._isInitialized: if not self._isInitialized:
return return
if not voice: if not isinstance(voice, float):
return return
if voice =='': if voice == '':
return return
self.voice = voice self.voice = voice
def setPitch(self, pitch): def setPitch(self, pitch):
if not self._isInitialized: if not self._isInitialized:
return return
if not pitch: if not isinstance(pitch, float):
return return
if pitch < 0.0: if pitch < 0.0:
retrun retrun
@ -65,7 +66,7 @@ class speechDriver():
def setRate(self, rate): def setRate(self, rate):
if not self._isInitialized: if not self._isInitialized:
return return
if not rate: if not isinstance(rate, float):
return return
if rate < 0.0: if rate < 0.0:
retrun retrun
@ -75,24 +76,24 @@ class speechDriver():
def setModule(self, module): def setModule(self, module):
if not self._isInitialized: if not self._isInitialized:
return return
if not module: if not isinstance(module, str):
return return
if module =='': if module == '':
return return
self.module = module self.module = module
def setLanguage(self, language): def setLanguage(self, language):
if not self._isInitialized: if not self._isInitialized:
return return
if not language: if not isinstance(language, str):
return return
if language =='': if language == '':
return return
self.language = language self.language = language
def setVolume(self, volume): def setVolume(self, volume):
if not self._isInitialized: if not self._isInitialized:
return return
if not volume: if not isinstance(volume,float):
return return
if volume < 0.0: if volume < 0.0:
retrun 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) inputDriver.__init__(self)
def getInputEvent(self): def getInputEvent(self):
time.sleep(0.05) time.sleep(0.1)
if not self._initialized: if not self._initialized:
return None 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 import debug
from core.speechDriver import speechDriver from core.speechDriver import speechDriver
class driver(speechDriver): class driver(speechDriver):
def __init__(self): def __init__(self):
speechDriver.__init__(self) speechDriver.__init__(self)