create debugging drivers
This commit is contained in:
parent
d4b0525e06
commit
81ea81575d
@ -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):
|
||||
|
49
src/fenrir/brailleDriver/debugDriver.py
Normal file
49
src/fenrir/brailleDriver/debugDriver.py
Normal 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')
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -43,8 +43,6 @@ class screenDriver():
|
||||
return ''
|
||||
def getFenrirFontSize(self, attribute):
|
||||
return ''
|
||||
def getContent(self):
|
||||
pass
|
||||
def update(self, trigger='onUpdate'):
|
||||
pass
|
||||
|
||||
|
@ -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
|
||||
|
@ -20,6 +20,7 @@ class speechDriver():
|
||||
self._isInitialized = True
|
||||
|
||||
def shutdown(self):
|
||||
if self._isInitialized:
|
||||
self.cancel()
|
||||
self._isInitialized = False
|
||||
|
||||
@ -46,7 +47,7 @@ class speechDriver():
|
||||
def setVoice(self, voice):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not voice:
|
||||
if not isinstance(voice, float):
|
||||
return
|
||||
if voice == '':
|
||||
return
|
||||
@ -55,7 +56,7 @@ class speechDriver():
|
||||
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,7 +76,7 @@ class speechDriver():
|
||||
def setModule(self, module):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not module:
|
||||
if not isinstance(module, str):
|
||||
return
|
||||
if module == '':
|
||||
return
|
||||
@ -84,7 +85,7 @@ class speechDriver():
|
||||
def setLanguage(self, language):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not language:
|
||||
if not isinstance(language, str):
|
||||
return
|
||||
if language == '':
|
||||
return
|
||||
@ -92,7 +93,7 @@ class speechDriver():
|
||||
def setVolume(self, volume):
|
||||
if not self._isInitialized:
|
||||
return
|
||||
if not volume:
|
||||
if not isinstance(volume,float):
|
||||
return
|
||||
if volume < 0.0:
|
||||
retrun
|
||||
|
66
src/fenrir/inputDriver/debugDriver.py
Normal file
66
src/fenrir/inputDriver/debugDriver.py
Normal 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__')
|
||||
|
||||
|
@ -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
|
||||
|
56
src/fenrir/soundDriver/debugDriver.py
Normal file
56
src/fenrir/soundDriver/debugDriver.py
Normal 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))
|
74
src/fenrir/speechDriver/debugDriver.py
Normal file
74
src/fenrir/speechDriver/debugDriver.py
Normal 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))
|
@ -7,6 +7,7 @@
|
||||
|
||||
from core import debug
|
||||
from core.speechDriver import speechDriver
|
||||
|
||||
class driver(speechDriver):
|
||||
def __init__(self):
|
||||
speechDriver.__init__(self)
|
||||
|
Loading…
Reference in New Issue
Block a user