dont show display contrast setting in display setup when a oled is detected
[enigma2.git] / lib / python / Components / Sources / FrontendStatus.py
1 from Source import Source
2 from enigma import eTimer
3
4 class FrontendStatus(Source):
5         def __init__(self, service_source = None, frontend_source = None, update_interval = 1000):
6                 Source.__init__(self)
7                 self.update_interval = update_interval
8                 self.service_source = service_source
9                 self.frontend_source = frontend_source
10                 self.invalidate()
11                 self.poll_timer = eTimer()
12                 self.poll_timer.timeout.get().append(self.updateFrontendStatus)
13                 self.poll_timer.start(update_interval)
14
15         def invalidate(self):
16                 self.snr = self.agc = self.ber = self.lock = self.snr_db = None
17
18         def updateFrontendStatus(self):
19                 status = self.getFrontendStatus()
20                 if not status:
21                         self.invalidate()
22                 else:
23                         self.snr = status.get("tuner_signal_power")
24                         self.snr_db = status.get("tuner_signal_power_db")
25                         self.agc = status.get("tuner_signal_quality")
26                         self.ber = status.get("tuner_bit_error_rate")
27                         self.lock = status.get("tuner_locked")
28                 self.changed((self.CHANGED_ALL, ))
29
30         def getFrontendStatus(self):
31                 if self.frontend_source:
32                         frontend = self.frontend_source()
33                         dict = { }
34                         if frontend:
35                                 frontend.getFrontendStatus(dict)
36                         return dict
37                 elif self.service_source:
38                         service = self.service_source()
39                         feinfo = service and service.frontendInfo()
40                         return feinfo and feinfo.getFrontendStatus()
41                 else:
42                         return None
43
44         def doSuspend(self, suspended):
45                 if suspended:
46                         self.poll_timer.stop()
47                 else:
48                         self.poll_timer.start(self.update_interval)
49