Merge branch 'master' of git.opendreambox.org:/git/enigma2
[enigma2.git] / lib / python / Screens / SessionGlobals.py
1 from Screens.Screen import Screen
2 from Components.Sources.CurrentService import CurrentService
3 from Components.Sources.EventInfo import EventInfo
4 from Components.Sources.FrontendStatus import FrontendStatus
5 from Components.Sources.FrontendInfo import FrontendInfo
6 from Components.Sources.Source import Source
7 from Components.Sources.TunerInfo import TunerInfo
8 from Components.Sources.Boolean import Boolean
9 from Components.Sources.RecordState import RecordState
10 from Components.Converter.Combine import Combine
11 from Components.Renderer.FrontpanelLed import FrontpanelLed
12
13 class SessionGlobals(Screen):
14         def __init__(self, session):
15                 Screen.__init__(self, session)
16                 self["CurrentService"] = CurrentService(session.nav)
17                 self["Event_Now"] = EventInfo(session.nav, EventInfo.NOW)
18                 self["Event_Next"] = EventInfo(session.nav, EventInfo.NEXT)
19                 self["FrontendStatus"] = FrontendStatus(service_source = session.nav.getCurrentService)
20                 self["FrontendInfo"] = FrontendInfo(navcore = session.nav)
21                 self["VideoPicture"] = Source()
22                 self["TunerInfo"] = TunerInfo()
23                 self["RecordState"] = RecordState(session)
24                 self["Standby"] = Boolean(fixed = False)
25                 
26                 from Components.SystemInfo import SystemInfo
27                 
28                 combine = Combine(func = lambda s: {(False, False): 0, (False, True): 1, (True, False): 2, (True, True): 3}[(s[0].boolean, s[1].boolean)])
29                 combine.connect(self["Standby"])
30                 combine.connect(self["RecordState"])
31
32                 #                      |  two leds  | single led |
33                 # recordstate  standby   red green   
34                 #    false      false    off   on     off
35                 #    true       false    blnk  on     blnk
36                 #    false      true      on   off    off
37                 #    true       true     blnk  off    blnk
38                 
39                 PATTERN_ON     = (20, 0xffffffff, 0xffffffff)
40                 PATTERN_OFF    = (20, 0, 0)
41                 PATTERN_BLINK  = (20, 0x55555555, 0xa7fccf7a)
42
43                 nr_leds = SystemInfo.get("NumFrontpanelLEDs", 0)
44
45                 if nr_leds == 1:
46                         FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_OFF, PATTERN_BLINK]).connect(combine)
47                 elif nr_leds == 2:
48                         FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_ON, PATTERN_BLINK]).connect(combine)
49                         FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_ON, PATTERN_ON, PATTERN_OFF, PATTERN_OFF]).connect(combine)