Skip to content

Commit

Permalink
[VfdSymbols + VfdDisplay] Add it again
Browse files Browse the repository at this point in the history
- Revert it from this commit ef48ae1
-Fix crash (AttributeError: ledblinkcontrolcolor) on dreamboxone/two
  • Loading branch information
fairbird committed Feb 2, 2024
1 parent d29bfb3 commit 8ce505a
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/python/Components/Converter/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ install_PYTHON = \
EventName2.py ExtendedServiceInfo.py ExtremeInfo.py HbbtvApplicationInfo.py LayoutInfo.py MovieBarInfo.py \
MovieReference.py ProgressDiskSpaceInfo.py RefString.py RouteInfo.py ServiceInfo2.py ServiceInfoEX.py \
ServiceName2.py TextAddAfter.py TextAddBefore.py Textreplace.py TextToUpper.py VAudioInfo.py VExtraNumText.py \
VNetSpeedInfo.py VtiTempFan.py VWeather.py YWeather.py VtiInfo.py Bitrate2.py
VNetSpeedInfo.py VtiTempFan.py VWeather.py YWeather.py VtiInfo.py Bitrate2.py VfdDisplay.py
81 changes: 81 additions & 0 deletions lib/python/Components/Converter/VfdDisplay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from datetime import datetime

from Components.Converter.Poll import Poll
from Components.Converter.Converter import Converter
from Components.Element import cached


class VfdDisplay(Poll, Converter):
def __init__(self, type):
Converter.__init__(self, type)
Poll.__init__(self)
self.num = None
self.showclock = 0
self.delay = 5000
self.loop = -1
self.type = type.lower().split(';')
if 'number' in self.type and 'clock' not in self.type: # Only channel number
self.delay = 0
self.poll_enabled = False
else:
self.poll_enabled = True
if 'clock' in self.type and 'number' not in self.type: # Only clock
self.showclock = 1
self.delay = -1
else:
for x in self.type:
if x.isdigit():
self.delay = int(x) * 1000
break
if 'loop' in self.type and self.delay:
self.loop = self.delay
if 'nozero' in self.type:
self.hour = '%-'
else:
self.hour = '%'
if '12h' in self.type:
self.hour = self.hour + 'I'
else:
self.hour = self.hour + 'H'

@cached
def getText(self):
if self.showclock == 0:
if self.delay:
self.poll_interval = self.delay
self.showclock = 1
if self.num:
return self.num
else:
if self.showclock == 1:
if 'noblink' in self.type:
self.poll_interval = self.delay
else:
self.poll_interval = 1000
self.showclock = 3
clockformat = self.hour + '%M'
elif self.showclock == 2:
self.showclock = 3
clockformat = self.hour + '%M'
else:
self.showclock = 2
clockformat = self.hour + ':%M'
if self.loop != -1:
self.loop -= 1000
if self.loop <= 0:
self.loop = self.delay
self.showclock = 0
return datetime.today().strftime(clockformat)

text = property(getText)

def changed(self, what):
if what[0] is self.CHANGED_SPECIFIC and self.delay >= 0:
self.showclock = 0
if self.loop != -1:
self.loop = self.delay
service = self.source.serviceref
self.num = service and ('%d' if 'nozero' in self.type else '%04d') % service.getChannelNum() or None
Converter.changed(self, what)
elif what[0] is self.CHANGED_POLL:
Converter.changed(self, what)
2 changes: 1 addition & 1 deletion lib/python/Components/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ install_PYTHON = \
Keyboard.py Sensors.py FanControl.py HdmiCec.py RcModel.py \
Netlink.py InputHotplug.py updatecheck.py \
ImportChannels.py StackTrace.py EpgLoadSave.py \
HdmiRecord.py PowerOffTimer.py NetworkTime.py
HdmiRecord.py PowerOffTimer.py NetworkTime.py VfdSymbols.py
291 changes: 291 additions & 0 deletions lib/python/Components/VfdSymbols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
# -*- coding: utf-8 -*-
from twisted.internet import threads
from Components.config import config
from enigma import eTimer, iPlayableService, iServiceInformation
import NavigationInstance
from Tools.Directories import fileExists
from Components.ParentalControl import parentalControl
from Components.ServiceEventTracker import ServiceEventTracker
from Components.SystemInfo import SystemInfo
from Tools.HardwareInfo import HardwareInfo
from time import time, sleep


POLLTIME = 5 # seconds


def SymbolsCheck(session, **kwargs):
global symbolspoller, POLLTIME
if SystemInfo["VFDSymbol"]:
POLLTIME = 1
symbolspoller = SymbolsCheckPoller(session)
symbolspoller.start()


class SymbolsCheckPoller:
def __init__(self, session):
self.session = session
self.blink = False
self.led = "0"
self.timer = eTimer()
self.onClose = []
self.__event_tracker = ServiceEventTracker(screen=self, eventmap={
iPlayableService.evUpdatedInfo: self.__evUpdatedInfo,
})

def __onClose(self):
pass

def start(self):
if self.symbolscheck not in self.timer.callback:
self.timer.callback.append(self.symbolscheck)
self.timer.startLongTimer(0)

def stop(self):
if self.symbolscheck in self.timer.callback:
self.timer.callback.remove(self.symbolscheck)
self.timer.stop()

def symbolscheck(self):
threads.deferToThread(self.JobTask)
self.timer.startLongTimer(POLLTIME)

def JobTask(self):
self.Recording()
self.PlaySymbol()
self.timer.startLongTimer(POLLTIME)

def __evUpdatedInfo(self):
self.service = self.session.nav.getCurrentService()
self.Subtitle()
self.ParentalControl()
del self.service

def Recording(self):
if SystemInfo["FrontpanelLEDBrightnessControl"]:
BRIGHTNESS_DEFAULT = 0xff
if config.lcd.ledbrightnesscontrol.value > 0xff or config.lcd.ledbrightnesscontrol.value < 0:
print("[VfdSymbols] LED brightness has to be between 0x0 and 0xff! Using default value (%x)" % (BRIGHTNESS_DEFAULT))
config.lcd.ledbrightnesscontrol.value = BRIGHTNESS_DEFAULT
open(SystemInfo["FrontpanelLEDBrightnessControl"], "w").write(config.lcd.ledbrightnesscontrol.value)
elif SystemInfo["FrontpanelLEDColorControl"]:
COLOR_DEFAULT = 0xffffff
if config.lcd.ledcolorcontrolcolor.value > 0xffffff or config.lcd.ledcolorcontrolcolor.value < 0:
print("[VfdSymbols] LED color has to be between 0x0 and 0xffffff (r, g b)! Using default value (%x)" % (COLOR_DEFAULT))
config.lcd.ledcolorcontrolcolor.value = COLOR_DEFAULT
open(SystemInfo["FrontpanelLEDColorControl"], "w").write(config.lcd.ledcolorcontrolcolor.value)
elif fileExists("/proc/stb/lcd/symbol_circle"):
recordings = len(NavigationInstance.instance.getRecordings())
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_circle")
if recordings > 0:
open("/proc/stb/lcd/symbol_circle", "w").write("3")
else:
open("/proc/stb/lcd/symbol_circle", "w").write("0")
elif HardwareInfo().get_device_name() in ("dm7020hd") and fileExists("/proc/stb/fp/led_set"):
recordings = len(NavigationInstance.instance.getRecordings())
self.blink = not self.blink
print("[VfdSymbols] Write to /proc/stb/fp/led_set")
if recordings > 0:
if self.blink:
open("/proc/stb/fp/led_set", "w").write("0x00000000")
self.led = "1"
else:
open("/proc/stb/fp/led_set", "w").write("0xffffffff")
self.led = "0"
else:
open("/proc/stb/fp/led_set", "w").write("0xffffffff")
elif SystemInfo["FrontpanelLEDFadeControl"]:
FADE_DEFAULT = 0x7
if config.lcd.ledfadecontrolcolor.value > 0xff or config.lcd.ledfadecontrolcolor.value < 0:
print("[VfdSymbols] LED fade has to be between 0x0 and 0xff! Using default value (%x)" % (FADE_DEFAULT))
config.lcd.ledfadecontrolcolor.value = FADE_DEFAULT
open(SystemInfo["FrontpanelLEDFadeControl"], "w").write(config.lcd.ledfadecontrolcolor.value)
elif SystemInfo["FrontpanelLEDBlinkControl"]:
BLINK_DEFAULT = 0x0710ff
if config.lcd.ledblinkcontrolcolor.value > 0xffffff or config.lcd.ledblinkcontrolcolor.value < 0:
print("[VfdSymbols] LED blink has to be between 0x0 and 0xffffff (on, total, repeats)! Using default value (%x)" % (BLINK_DEFAULT))
config.lcd.ledblinkcontrolcolor.value = BLINK_DEFAULT
open(SystemInfo["FrontpanelLEDBlinkControl"], "w").write(config.lcd.ledblinkcontrolcolor.value)
else:
if not fileExists("/proc/stb/lcd/symbol_recording") or not fileExists("/proc/stb/lcd/symbol_record_1") or not fileExists("/proc/stb/lcd/symbol_record_2"):
return

recordings = len(NavigationInstance.instance.getRecordings())

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_recording")
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_record_1")
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_record_2")
if recordings > 0:
open("/proc/stb/lcd/symbol_recording", "w").write("1")
if recordings == 1:
open("/proc/stb/lcd/symbol_record_1", "w").write("1")
open("/proc/stb/lcd/symbol_record_2", "w").write("0")
elif recordings >= 2:
open("/proc/stb/lcd/symbol_record_1", "w").write("1")
open("/proc/stb/lcd/symbol_record_2", "w").write("1")
else:
open("/proc/stb/lcd/symbol_recording", "w").write("0")
open("/proc/stb/lcd/symbol_record_1", "w").write("0")
open("/proc/stb/lcd/symbol_record_2", "w").write("0")

def Subtitle(self):
if not fileExists("/proc/stb/lcd/symbol_smartcard") and not fileExists("/proc/stb/lcd/symbol_subtitle"):
return

subtitle = self.service and self.service.subtitle()
subtitlelist = subtitle and subtitle.getSubtitleList()

if subtitlelist:
subtitles = len(subtitlelist)
if fileExists("/proc/stb/lcd/symbol_subtitle"):
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_subtitle")
if subtitles > 0:
open("/proc/stb/lcd/symbol_subtitle", "w").write("1")
else:
open("/proc/stb/lcd/symbol_subtitle", "w").write("0")
else:
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_smartcard")
if subtitles > 0:
open("/proc/stb/lcd/symbol_smartcard", "w").write("1")
else:
open("/proc/stb/lcd/symbol_smartcard", "w").write("0")
else:
if fileExists("/proc/stb/lcd/symbol_smartcard"):
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_smartcard")
open("/proc/stb/lcd/symbol_smartcard", "w").write("0")

def ParentalControl(self):
if not fileExists("/proc/stb/lcd/symbol_parent_rating"):
return

service = self.session.nav.getCurrentlyPlayingServiceReference()

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_parent_rating")
if service:
if parentalControl.getProtectionLevel(service.toCompareString()) == -1:
open("/proc/stb/lcd/symbol_parent_rating", "w").write("0")
else:
open("/proc/stb/lcd/symbol_parent_rating", "w").write("1")
else:
open("/proc/stb/lcd/symbol_parent_rating", "w").write("0")

def PlaySymbol(self):
if not fileExists("/proc/stb/lcd/symbol_play"):
return

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_play")
if SystemInfo["SeekStatePlay"]:
open("/proc/stb/lcd/symbol_play", "w").write("1")
else:
open("/proc/stb/lcd/symbol_play", "w").write("0")

def PauseSymbol(self):
if not fileExists("/proc/stb/lcd/symbol_pause"):
return

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_pause")
if SystemInfo["StatePlayPause"]:
open("/proc/stb/lcd/symbol_pause", "w").write("1")
else:
open("/proc/stb/lcd/symbol_pause", "w").write("0")

def PowerSymbol(self):
if not fileExists("/proc/stb/lcd/symbol_power"):
return

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_power")
if SystemInfo["StandbyState"]:
open("/proc/stb/lcd/symbol_power", "w").write("0")
else:
open("/proc/stb/lcd/symbol_power", "w").write("1")

def Resolution(self):
if not fileExists("/proc/stb/lcd/symbol_hd"):
return

info = self.service and self.service.info()
if not info:
return ""

videosize = int(info.getInfo(iServiceInformation.sVideoWidth))

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_hd")
if videosize >= 1280:
open("/proc/stb/lcd/symbol_hd", "w").write("1")
else:
open("/proc/stb/lcd/symbol_hd", "w").write("0")

def Crypted(self):
if not fileExists("/proc/stb/lcd/symbol_scramled"):
return

info = self.service and self.service.info()
if not info:
return ""

crypted = int(info.getInfo(iServiceInformation.sIsCrypted))

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_scramled")
if crypted == 1:
open("/proc/stb/lcd/symbol_scramled", "w").write("1")
else:
open("/proc/stb/lcd/symbol_scramled", "w").write("0")

def Teletext(self):
if not fileExists("/proc/stb/lcd/symbol_teletext"):
return

info = self.service and self.service.info()
if not info:
return ""

tpid = int(info.getInfo(iServiceInformation.sTXTPID))

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_teletext")
if tpid != -1:
open("/proc/stb/lcd/symbol_teletext", "w").write("1")
else:
open("/proc/stb/lcd/symbol_teletext", "w").write("0")

def Hbbtv(self):
if not fileExists("/proc/stb/lcd/symbol_epg"):
return

info = self.service and self.service.info()
if not info:
return ""

hbbtv = int(info.getInfo(iServiceInformation.sHBBTVUrl))

print("[VfdSymbols] Write to /proc/stb/lcd/symbol_epg")
if hbbtv != -1:
open("/proc/stb/lcd/symbol_epg", "w").write("0")
else:
open("/proc/stb/lcd/symbol_epg", "w").write("1")

def Audio(self):
if not fileExists("/proc/stb/lcd/symbol_dolby_audio"):
return

audio = self.service.audioTracks()
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_dolby_audio")
if audio:
n = audio.getNumberOfTracks()
idx = 0
while idx < n:
i = audio.getTrackInfo(idx)
description = i.getDescription()
if "AC3" in description or "AC-3" in description or "DTS" in description:
open("/proc/stb/lcd/symbol_dolby_audio", "w").write("1")
return
idx += 1
open("/proc/stb/lcd/symbol_dolby_audio", "w").write("0")

def Timer(self):
if fileExists("/proc/stb/lcd/symbol_timer"):
timer = NavigationInstance.instance.RecordTimer.getNextRecordingTime()
print("[VfdSymbols] Write to /proc/stb/lcd/symbol_timer")
if timer > 0:
open("/proc/stb/lcd/symbol_timer", "w").write("1")
else:
open("/proc/stb/lcd/symbol_timer", "w").write("0")

0 comments on commit 8ce505a

Please sign in to comment.