make it possible to align autotime to an minute
This commit is contained in:
parent
92e7a8aebc
commit
7bc4745e2a
@ -125,4 +125,7 @@ list=
|
|||||||
enabled=False
|
enabled=False
|
||||||
presentTime=True
|
presentTime=True
|
||||||
presentDate=True
|
presentDate=True
|
||||||
delaySec=3600
|
delaySec=0
|
||||||
|
# present time after to given minutes example every 15 minutes: 00,15,30,45
|
||||||
|
# if delaySec is >0 onMinutes is ignored
|
||||||
|
onMinutes=00,30
|
||||||
|
@ -130,5 +130,8 @@ enabled=False
|
|||||||
presentTime=True
|
presentTime=True
|
||||||
# present date (on change)
|
# present date (on change)
|
||||||
presentDate=True
|
presentDate=True
|
||||||
# present time after x seconds
|
# present time after a given period of seconds
|
||||||
delaySec=3600
|
delaySec=0
|
||||||
|
# present time after to given minutes example every 15 minutes: 00,15,30,45
|
||||||
|
# if delaySec is >0 onMinutes is ignored
|
||||||
|
onMinutes=00,30
|
||||||
|
@ -131,4 +131,7 @@ presentTime=True
|
|||||||
# present date (on change)
|
# present date (on change)
|
||||||
presentDate=True
|
presentDate=True
|
||||||
# present time after x seconds
|
# present time after x seconds
|
||||||
delaySec=3600
|
delaySec=0
|
||||||
|
# present time after to given minutes example every 15 minutes: 00,15,30,45
|
||||||
|
# if delaySec is >0 onMinutes is ignored
|
||||||
|
onMinutes=00,30
|
||||||
|
@ -81,4 +81,7 @@ presentTime=True
|
|||||||
# present date (on change)
|
# present date (on change)
|
||||||
presentDate=True
|
presentDate=True
|
||||||
# present time after x seconds
|
# present time after x seconds
|
||||||
delaySec=3600
|
delaySec=0
|
||||||
|
# present time after to given minutes example every 15 minutes: 00,15,30,45
|
||||||
|
# if delaySec is >0 onMinutes is ignored
|
||||||
|
onMinutes=00,30
|
||||||
|
@ -14,7 +14,7 @@ class command():
|
|||||||
pass
|
pass
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
self.lastTime = time.time()
|
self.lastTime = datetime.datetime.now()
|
||||||
self.lastDateString = ''
|
self.lastDateString = ''
|
||||||
self.lastTimeString = ''
|
self.lastTimeString = ''
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -25,13 +25,31 @@ class command():
|
|||||||
def run(self):
|
def run(self):
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'):
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'):
|
||||||
return
|
return
|
||||||
if int(time.time() - self.lastTime) < self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec'):
|
onMinutes = self.env['runtime']['settingsManager'].getSetting('time', 'onMinutes')
|
||||||
|
delaySec = self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec')
|
||||||
|
# no need
|
||||||
|
if onMinutes == '' and delaySec <= 0:
|
||||||
return
|
return
|
||||||
|
onMinutes = onMinutes.split(',')
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
# ignore onMinutes if there is a delaySec
|
||||||
|
if delaySec > 0:
|
||||||
|
if int((now-self.lastTime).total_seconds()) < delaySec:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# shoul announce?
|
||||||
|
if not str(now.minute) in onMinutes:
|
||||||
|
return
|
||||||
|
# already announced?
|
||||||
|
if now.hour == self.lastTime.hour:
|
||||||
|
if now.minute == self.lastTime.minute:
|
||||||
|
return
|
||||||
|
|
||||||
timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
|
timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
|
||||||
timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat)
|
timeString = datetime.datetime.strftime(now, timeFormat)
|
||||||
|
|
||||||
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
|
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
|
||||||
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
|
dateString = datetime.datetime.strftime(now, dateFormat)
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime'):
|
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime'):
|
||||||
# present the time
|
# present the time
|
||||||
self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False)
|
||||||
@ -40,7 +58,7 @@ class command():
|
|||||||
if self.lastDateString != dateString:
|
if self.lastDateString != dateString:
|
||||||
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False)
|
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False)
|
||||||
self.lastDateString = dateString
|
self.lastDateString = dateString
|
||||||
self.lastTime = time.time()
|
self.lastTime = datetime.datetime.now()
|
||||||
self.lastTimeString = timeString
|
self.lastTimeString = timeString
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -68,7 +68,8 @@ settings = {
|
|||||||
'enabled': False,
|
'enabled': False,
|
||||||
'presentTime': True,
|
'presentTime': True,
|
||||||
'presentDate': True,
|
'presentDate': True,
|
||||||
'delaySec': 3600,
|
'delaySec': 0,
|
||||||
|
'onMinutes': '00,30',
|
||||||
},
|
},
|
||||||
'keyboard':{
|
'keyboard':{
|
||||||
'driver': 'evdev',
|
'driver': 'evdev',
|
||||||
|
Loading…
Reference in New Issue
Block a user