-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPFSwe.py
More file actions
160 lines (144 loc) · 5.64 KB
/
PFSwe.py
File metadata and controls
160 lines (144 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
from . import _
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Components.ConfigList import ConfigListScreen
from Components.ActionMap import ActionMap
from Components.Label import Label
from Components.Input import Input
from Components.config import getConfigListEntry, ConfigInteger, ConfigYesNo, ConfigClock, ConfigSelection, ConfigNumber, ConfigSequence, config, NoSave
from enigma import eDVBVolumecontrol,eServiceReference, iRecordableService, iPlayableService,eTimer
from time import localtime, mktime
from Components.ServiceEventTracker import ServiceEventTracker
class PFS_show_we(Screen,ConfigListScreen):
skin = """
<screen name="Show_Exif" position="center,center" size="310,120" title="Info" >
<ePixmap pixmap="skin_default/buttons/red.png" position="10,80" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/green.png" position="155,80" size="140,40" alphatest="on" />
<widget name="key_red" position="10,85" zPosition="1" size="140,35" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
<widget name="key_green" position="155,85" zPosition="1" size="140,35" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
<widget name="config" position="5,5" size="300,65" scrollbarMode="showOnDemand" />
</screen>"""
def __init__(self, session):
self.wecker=0
self.al_vol_max=40
self.now = [x for x in localtime()]
t1=mktime((self.now[0],self.now[1],self.now[2],self.now[3],self.now[4],0,0,0,-1))
self.alarm_time=NoSave(ConfigClock(default =t1))
self.alarm_volume = NoSave(ConfigInteger(default=30, limits=(0, 99)))
self.sound_on=False
self.list1 = []
self.list1.extend((
getConfigListEntry(_("alarm time"), self.alarm_time),
getConfigListEntry(_("max volume"), self.alarm_volume),
))
Screen.__init__(self, session)
self.setTitle(_("alarm-clock")+" - PlanerFS ")
ConfigListScreen.__init__(self, self.list1)
self["key_green"] = Label(_("Start"))
self["key_red"] = Label(_("Cancel"))
self["actions"] = ActionMap(["OkCancelActions", "ColorActions","DirectionActions","MenuActions","InfobarChannelSelection"],
{
"ok": self.wecker_timer,
"green": self.wecker_timer,
"red": self.close,
"cancel": self.close,
}, -1)
self.musicfile="/usr/lib/enigma2/python/Plugins/Extensions/PlanerFS/PFSsound.mp3"
self["config"].setList(self.list1)
def nix(self):
pass
def loadList(self):
self.list1 = []
self.list1.extend((
getConfigListEntry(_("alarm time"), self.alarm_time),
getConfigListEntry(_("max volume"), self.alarm_volume),
))
def wecker_timer(self):
if self.wecker==0:
lt = localtime()
jetzt=(3600*lt[3])+(60*lt[4])+lt[5]
meldezeit=3600*self.alarm_time.value[0]+60*self.alarm_time.value[1]
if meldezeit <= jetzt:
minuszeit=jetzt-meldezeit
zeitdiff= 86400-minuszeit
else:
zeitdiff= meldezeit-jetzt
self.session.openWithCallback(self.back,PFS_alarm_clock,self.alarm_volume.value,zeitdiff)
else:
pass
def back(self,result):
if result==0:
self.close()
else:
pass
class PFS_alarm_clock(Screen):
skin = """
<screen name="alert" position="center,center" size="250,60" title="alert" flags="wfNoBorder" backgroundColor="transparent">
<widget name="time" size="250,60" font="Regular;58" foregroundColor="white" valign="center" halign="center" backgroundColor="transparent" />
</screen>"""
def __init__(self, session,max_vol=40,zeitdiff =1):
self.al_vol_max=max_vol
self.zeitdiff=zeitdiff
self.timer1_instanz=False
self.timer1 = eTimer()
self.timer1.timeout.get().append(self.klang)
self.sound_on=False
self.volctrl = eDVBVolumecontrol.getInstance()
Screen.__init__(self, session)
self.setTitle(_("alarm-clock")+" - PlanerFS ")
self["time"] = Label(" ")
self["time"].hide()
self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
{
iPlayableService.evEOF: self.__schleife,
})
self["actions"] = ActionMap(["OkCancelActions", "ColorActions","DirectionActions","MenuActions","InfobarChannelSelection"],
{
"red": self.exit,
"cancel": self.exit,
"ok": self.info,
"back": self.info,
"left": self.info,
"right": self.info,
"up": self.info,
"down": self.info,
}, -1)
self.musicfile="/usr/lib/enigma2/python/Plugins/Extensions/PlanerFS/PFSsound.mp3"
self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
self.onLayoutFinish.append(self.start_timer)
def info(self):
self.session.open(MessageBox,(_("alert-clock is running - press ESC for abort")), MessageBox.TYPE_INFO, timeout = 5)
def start_timer(self):
self.we_timer = eTimer()
if hasattr(self.we_timer, 'callback'):
self.we_timer.callback.append(self.klang)
else:
self.we_timer_conn = self.we_timer.timeout.connect(self.klang)
self.we_timer.startLongTimer(self.zeitdiff)
def klang(self):
self.we_timer=None
if self.sound_on == False:
lt = localtime()
self["time"].setText('%0.2d:%0.2d' %(lt[3],lt[4]))
self["time"].show()
oldvol2 = self.volctrl.getVolume()
if oldvol2 < self.al_vol_max:
self.volctrl.setVolume(oldvol2+1, oldvol2+1)
sref = eServiceReference(4097, 0, self.musicfile)
self.session.nav.playService(sref)
self.sound_on=1
def __schleife(self):
self.sound_on=False
self.session.nav.playService(self.oldService)
self.timer1.startLongTimer(15)
def exit(self):
num=0
if self.we_timer:
self.we_timer.stop()
num=1
if self.sound_on:
self.session.nav.stopService()
self.session.nav.playService(self.oldService)
if self.timer1_instanz:
self.timer1.stop()
self.close(num)