more sophisticated LED control, not yet model-specific
[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                 combine = Combine(func = lambda s: {(False, False): 0, (False, True): 1, (True, False): 2, (True, True): 3}[(s[0].boolean, s[1].boolean)])
26                 combine.connect(self["Standby"])
27                 combine.connect(self["RecordState"])
28
29                 #                      |  two leds  | single led |
30                 # recordstate  standby   red green   
31                 #    false      false    off   on     off
32                 #    true       false    blnk  on     blnk
33                 #    false      true      on   off    off
34                 #    true       true     blnk  off    blnk
35                 
36                 PATTERN_ON     = (20, 0xffffffff, 0)
37                 PATTERN_OFF    = (20, 0, 0xffffffff)
38                 PATTERN_BLINK  = (20, 0x55555555, 0x84fc8c04)
39
40                 FrontpanelLed(which = 0, boolean = False, patterns = [PATTERN_ON, PATTERN_ON, PATTERN_OFF, PATTERN_OFF]).connect(combine)
41                 FrontpanelLed(which = 1, boolean = False, patterns = [PATTERN_OFF, PATTERN_BLINK, PATTERN_ON, PATTERN_BLINK]).connect(combine)