add autotime toggle, announce date on change, make configurable what is spoken date or time or both

This commit is contained in:
chrys
2016-11-09 23:17:58 +01:00
parent 90ebbaf749
commit 3171018e6e
10 changed files with 65 additions and 12 deletions

View File

@ -0,0 +1,26 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'enables or disables automatic reading of time after an period'
def run(self):
self.env['runtime']['settingsManager'].setSetting('time', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled')))
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'):
self.env['runtime']['outputManager'].presentText("autotime enabled", soundIcon='', interrupt=True)
else:
self.env['runtime']['outputManager'].presentText("autotime disabled", soundIcon='', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -15,6 +15,8 @@ class command():
def initialize(self, environment):
self.env = environment
self.lastTime = time.time()
self.lastDateString = ''
self.lastTimeString = ''
def shutdown(self):
pass
def getDescription(self):
@ -26,15 +28,19 @@ class command():
if int(time.time() - self.lastTime) < self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec'):
return
timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
# get the time formatted
timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat)
# present the time
self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False)
self.lastTime = time.time()
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime'):
# present the time
self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False)
# and date if changes
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentDate'):
if self.lastDateString != dateString:
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False)
self.lastDateString = dateString
self.lastTime = time.time()
self.lastTimeString = timeString
def setCallback(self, callback):
pass

View File

@ -66,6 +66,8 @@ settings = {
},
'time':{
'enabled': False,
'presentTime': True,
'presentDate': True,
'delaySec': 3600,
},
'keyboard':{