diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-04-04 09:24:39 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-04-04 09:24:39 +0000 |
| commit | 200264273687a4c4bd97574ee7f725122548d019 (patch) | |
| tree | 0568e6181ddd0ba4e8d34d3eea6065adebbfc11f /lib/python/Components | |
| parent | deddfcf89d1356ae1b3782f800ad6925caf92335 (diff) | |
| download | enigma2-200264273687a4c4bd97574ee7f725122548d019.tar.gz enigma2-200264273687a4c4bd97574ee7f725122548d019.zip | |
avoid future redundant code by moving functionality for tuner status display to a seperate component (which is a BIT slower because infobar values are gathered twice)
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Components/TunerInfo.py | 83 | ||||
| -rw-r--r-- | lib/python/Components/__init__.py | 2 |
3 files changed, 85 insertions, 2 deletions
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index 94a8c06c..8f43cae1 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -13,6 +13,6 @@ install_PYTHON = \ BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \ PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \ FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \ - MultiContent.py MediaPlayer.py + MultiContent.py MediaPlayer.py TunerInfo.py diff --git a/lib/python/Components/TunerInfo.py b/lib/python/Components/TunerInfo.py new file mode 100644 index 00000000..e22ce468 --- /dev/null +++ b/lib/python/Components/TunerInfo.py @@ -0,0 +1,83 @@ +from GUIComponent import GUIComponent + +from enigma import eLabel, eSlider, iFrontendStatusInformation + +from math import log + +class TunerInfo(GUIComponent): + SNR_PERCENTAGE = 0 + AGC_PERCENTAGE = 1 + BER_VALUE = 2 + SNR_BAR = 3 + AGC_BAR = 4 + BER_BAR = 5 + def __init__(self, type, servicefkt): + GUIComponent.__init__(self) + self.instance = None + self.message = None + self.value = None + + self.servicefkt = servicefkt + self.type = type + self.update() + + def setText(self, text): + self.message = text + if self.instance: + self.instance.setText(self.message) + + def setValue(self, value): + self.value = value + if self.instance: + self.instance.setValue(self.value) + + def calc(self,val): + if not val: + return 0 + if val < 2500: + return (long)(log(val)/log(2)) + return val*100/65535 + + def update(self): + service = self.servicefkt() + value = 0 + if service is not None: + feinfo = service.frontendStatusInfo() + if feinfo is not None: + if self.type == self.SNR_PERCENTAGE or self.type == self.SNR_BAR: + value = feinfo.getFrontendInfo(iFrontendStatusInformation.signalPower) * 100 / 65536 + elif self.type == self.AGC_PERCENTAGE or self.type == self.AGC_BAR: + value = feinfo.getFrontendInfo(iFrontendStatusInformation.signalQuality) * 100 / 65536 + elif self.type == self.BER_VALUE or self.type == self.BER_BAR: + value = feinfo.getFrontendInfo(iFrontendStatusInformation.bitErrorRate) + + if self.type == self.SNR_PERCENTAGE or self.type == self.AGC_PERCENTAGE: + self.setText("%d%%" % (value)) + elif self.type == self.BER_VALUE: + self.setText("%d" % (value)) + elif self.type == self.SNR_BAR or self.type == self.AGC_BAR: + self.setValue(value) + elif self.type == self.BER_BAR: + self.setValue(self.calc(value)) + + def createWidget(self, parent): + if self.SNR_PERCENTAGE <= self.type <= self.BER_VALUE: + return eLabel(parent) + elif self.SNR_BAR <= self.type <= self.BER_BAR: + self.g = eSlider(parent) + self.g.setRange(0, 100) + return self.g + + def GUIcreate(self, parent): + self.instance = self.createWidget(parent) + if self.message is not None: + self.instance.setText(self.message) + elif self.value is not None: + self.instance.setValue(self.value) + + def GUIdelete(self): + self.removeWidget(self.instance) + self.instance = None + + def removeWidget(self, instance): + pass
\ No newline at end of file diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index 1b148d79..b6ad939c 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -7,4 +7,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway", "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry", "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList", "TimerSanityCheck", - "FileList", "MultiContent" ] + "FileList", "MultiContent", "TunerInfo" ] |
