Skip to content

Commit c9291be

Browse files
authored
[LED] Update to make it more compatible with DreamOne/Two
1 parent 64ac50c commit c9291be

File tree

12 files changed

+242
-526
lines changed

12 files changed

+242
-526
lines changed

data/setup.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,15 @@
390390
<item level="0" requires="ConfigDisplay" text="Show HDMI-Output Res" description="Show HDMI Output Resulution">config.lcd.showoutputresolution</item>
391391
</setup>
392392
<setup key="LedDisplay" title="LED Setup">
393-
<item level="0" text="LED color during normal operations" description="Configure front LED color during normal operations (this needs an enigma2 restart).">config.usage.frontled_color</item>
394-
<item level="0" text="LED color during recording" description="Configure front LED color during recording (this needs an enigma2 restart).">config.usage.frontledrec_color</item>
395-
<item level="0" text="LED color during standby" description="Configure front LED color during standby (this needs an enigma2 restart).">config.usage.frontledstdby_color</item>
396-
<item level="0" text="LED color during recording in standby" description="Configure front LED color during recording in standby (this needs an enigma2 restart).">config.usage.frontledrecstdby_color</item>
393+
<item level="0" requires="LEDControl" text="LED color during normal operations" description="Configure front LED color during normal operations (this needs an enigma2 restart).">config.usage.frontled_color</item>
394+
<item level="0" requires="LEDControl" text="LED color during recording" description="Configure front LED color during recording (this needs an enigma2 restart).">config.usage.frontledrec_color</item>
395+
<item level="0" requires="LEDControl" text="LED color during standby" description="Configure front LED color during standby (this needs an enigma2 restart).">config.usage.frontledstdby_color</item>
396+
<item level="0" requires="LEDControl" text="LED color during recording in standby" description="Configure front LED color during recording in standby (this needs an enigma2 restart).">config.usage.frontledrecstdby_color</item>
397+
<item level="1" requires="LEDColorControl" text="LED Color" description="With this option you can switch the LED color or deactivate the LED.">config.fp.led.default_color</item>
398+
<item level="1" requires="LEDColorControl" text="LED Brightness" description="LED brightness during normal operations.">config.fp.led.default_brightness</item>
399+
<item level="1" requires="LEDColorControl" text="LED Idle Color" description="With this option you can switch the LED color or deactivate the LED.">config.fp.led.standby_color</item>
400+
<item level="1" requires="LEDColorControl" text="LED Idle Brightness" description="LED brightness during deep standby.">config.fp.led.standby_brightness</item>
401+
<item level="1" requires="LEDColorControl" text="LED Shutdown Color" description="Power LED state during deep-standby.">config.fp.led.shutdown_color</item>
397402
<item level="0" text="LED Normal" description="LED brightness during normal operations.">config.lcd.ledbrightness</item>
398403
<item level="0" text="LED Standby" description="LED brightness during standby.">config.lcd.ledbrightnessstandby</item>
399404
<item level="0" text="LED Deep Standby" description="LED brightness during deep standby.">config.lcd.ledbrightnessdeepstandby</item>
@@ -404,10 +409,6 @@
404409
<item level="0" requires="LedPowerColor" text="Operating LED status while running" description="With this option you can switch the LED color or deactivate the LED.">config.lcd.ledpowercolor</item>
405410
<item level="0" requires="LedStandbyColor" text="Operating LED status in standby mode" description="With this option you can switch the LED color or deactivate the LED.">config.lcd.ledstandbycolor</item>
406411
<item level="0" requires="LedSuspendColor" text="Operating LED status in deep standby mode" description="With this option you can switch the LED color or deactivate the LED.">config.lcd.ledsuspendcolor</item>
407-
<item level="0" requires="FrontpanelLEDBlinkControl" text="Operating LED color while blinking." description="With this option you can switch the LED color while blinking.">config.lcd.ledblinkcontrolcolor</item>
408-
<item level="0" requires="FrontpanelLEDBrightnessControl" text="Operating LED brightness." description="With this option you can switch the LED brightness.">config.lcd.ledbrightnesscontrol</item>
409-
<item level="0" requires="FrontpanelLEDColorControl" text="Operating LED color." description="With this option you can switch the LED color.">config.lcd.ledcolorcontrolcolor</item>
410-
<item level="0" requires="FrontpanelLEDFadeControl" text="Operating LED fade." description="With this option you can switch the LED fade.">config.lcd.ledfadecontrolcolor</item>
411412
<item level="0" requires="Power4x7On" text="Switch on the display during operation" description="With this option you can switch on the display during operation.">config.lcd.power4x7on</item>
412413
<item level="0" requires="Power4x7Standby" text="Switch on the display during Standby Mode" description="With this option you can switch on the display in Standby Mode.">config.lcd.power4x7standby</item>
413414
<item level="0" requires="Power4x7Suspend" text="Switch on the display during Suspend Mode" description="With this option you can switch on the display in Deep Standby Mode.">config.lcd.power4x7suspend</item>

lib/python/Components/Converter/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ install_PYTHON = \
1212
EventName2.py ExtendedServiceInfo.py ExtremeInfo.py HbbtvApplicationInfo.py LayoutInfo.py MovieBarInfo.py \
1313
MovieReference.py ProgressDiskSpaceInfo.py RefString.py RouteInfo.py ServiceInfo2.py ServiceInfoEX.py \
1414
ServiceName2.py TextAddAfter.py TextAddBefore.py Textreplace.py TextToUpper.py VAudioInfo.py VExtraNumText.py \
15-
VNetSpeedInfo.py VtiTempFan.py VWeather.py YWeather.py VtiInfo.py Bitrate2.py VfdDisplay.py
15+
VNetSpeedInfo.py VtiTempFan.py VWeather.py YWeather.py VtiInfo.py Bitrate2.py

lib/python/Components/Converter/VfdDisplay.py

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
from enigma import iRecordableService
2+
from Components.config import config, ConfigSlider, ConfigSelection, ConfigSubsection
3+
from Tools.Directories import fileExists
4+
5+
6+
config.fp = ConfigSubsection()
7+
config.fp.led = ConfigSubsection()
8+
colors = [
9+
("0xFF0000", _("red")),
10+
("0xFF3333", _("rose")),
11+
("0xFF5500", _("orange")),
12+
("0xDD9900", _("yellow")),
13+
("0x99DD00", _("lime")),
14+
("0x00FF00", _("green")),
15+
("0x00FF99", _("aqua")),
16+
("0x00BBFF", _("olympic blue")),
17+
("0x0000FF", _("blue")),
18+
("0x6666FF", _("azure")),
19+
("0x9900FF", _("purple")),
20+
("0xFF0066", _("pink")),
21+
("0xFFFFFF", _("white")),
22+
]
23+
# running
24+
config.fp.led.default_color = ConfigSelection(colors, default="0xFFFFFF")
25+
config.fp.led.default_brightness = ConfigSlider(default=0xff, increment=25, limits=(0, 0xff))
26+
# standby
27+
config.fp.led.standby_color = ConfigSelection(colors, default="0xFFFFFF")
28+
config.fp.led.standby_brightness = ConfigSlider(default=0x08, increment=8, limits=(0, 0xff))
29+
# shutdown
30+
config.fp.led.shutdown_color = ConfigSelection(colors, default="0xFF5500")
31+
32+
frontPanelLed = None
33+
34+
35+
class FrontPanelLed:
36+
BLINK_PATH = "/proc/stb/fp/led_blink"
37+
BLINK_DEFAULT = 0x0710ff
38+
39+
BRIGHTNESS_PATH = "/proc/stb/fp/led_brightness"
40+
BRIGHTNESS_DEFAULT = 0xFF
41+
42+
COLOR_PATH = "/proc/stb/fp/led_color"
43+
COLOR_DEFAULT = 0xFFFFFF
44+
45+
FADE_PATH = "/proc/stb/fp/led_fade"
46+
FADE_DEFAULT = 0x7
47+
48+
instance = None
49+
50+
def __init__(self):
51+
assert (not FrontPanelLed.instance)
52+
FrontPanelLed.instance = self
53+
self._session = None
54+
self.default()
55+
config.misc.standbyCounter.addNotifier(self._onStandby, initial_call=False)
56+
config.fp.led.default_color.addNotifier(self._onDefaultChanged, initial_call=False)
57+
config.fp.led.default_brightness.addNotifier(self._onDefaultChanged, initial_call=False)
58+
59+
def init(self, session):
60+
self._session = session
61+
session.nav.record_event.append(self.checkRecordings)
62+
63+
def _onDefaultChanged(self, *args):
64+
from Screens.Standby import inStandby
65+
if not inStandby:
66+
FrontPanelLed.default()
67+
68+
def _onStandby(self, *args):
69+
FrontPanelLed.standby()
70+
from Screens.Standby import inStandby
71+
if inStandby:
72+
inStandby.onClose.append(self._onLeaveStandby)
73+
74+
def _onLeaveStandby(self):
75+
FrontPanelLed.default()
76+
77+
def checkRecordings(self, service=None, event=iRecordableService.evEnd):
78+
if not self._session:
79+
return
80+
if event == iRecordableService.evEnd:
81+
recordings = self._session.nav.getRecordings()
82+
if not recordings:
83+
FrontPanelLed.stopRecording()
84+
else:
85+
FrontPanelLed.recording()
86+
elif event == iRecordableService.evStart:
87+
FrontPanelLed.recording()
88+
89+
@staticmethod
90+
def _write(path, value):
91+
if not fileExists(path):
92+
print("[FrontPanelLed] %s does not exist!" % (path))
93+
return
94+
with open(path, 'w') as f:
95+
value = "%x" % (value)
96+
print("[FrontPanelLed] : %s" % (value))
97+
f.write(value)
98+
99+
# 8 bit brightness
100+
@staticmethod
101+
def setBrightness(value=BRIGHTNESS_DEFAULT):
102+
if value > 0xff or value < 0:
103+
print("[FrontPanelLed] LED brightness has to be between 0x0 and 0xff! Using default value (%x)" % (FrontPanelLed.BRIGHTNESS_DEFAULT))
104+
value = FrontPanelLed.BRIGHTNESS_DEFAULT
105+
FrontPanelLed._write(FrontPanelLed.BRIGHTNESS_PATH, value)
106+
107+
# 24 bit RGB
108+
@staticmethod
109+
def setColor(value=COLOR_DEFAULT):
110+
if value > 0xffffff or value < 0:
111+
print("[FrontPanelLed] LED color has to be between 0x0 and 0xffffff (r, g b)! Using default value (%x)" % (FrontPanelLed.COLOR_DEFAULT))
112+
value = FrontPanelLed.COLOR_DEFAULT
113+
FrontPanelLed._write(FrontPanelLed.COLOR_PATH, value)
114+
115+
# 8 bit on-time (* 31ms), 8 bit total time (* 31ms), 8 bit number of repeats (ff == unlimited)
116+
@staticmethod
117+
def setBlink(value=BLINK_DEFAULT):
118+
if value > 0xffffff or value < 0:
119+
print("[FrontPanelLed] LED blink has to be between 0x0 and 0xffffff (on, total, repeats)! Using default value (%x)" % (FrontPanelLed.BLINK_DEFAULT))
120+
value = FrontPanelLed.BLINK_DEFAULT
121+
FrontPanelLed._write(FrontPanelLed.BLINK_PATH, value)
122+
123+
# 8 bit fade time (* 51ms)
124+
@staticmethod
125+
def setFade(value=FADE_DEFAULT):
126+
if value > 0xff or value < 0:
127+
value = FrontPanelLed.FADE_DEFAULT
128+
print("[FrontPanelLed] LED fade has to be between 0x0 and 0xff! Using default value (%x)" % (FrontPanelLed.FADE_DEFAULT))
129+
FrontPanelLed._write(FrontPanelLed.FADE_PATH, value)
130+
131+
@staticmethod
132+
def default(checkRec=True):
133+
FrontPanelLed.setBrightness(config.fp.led.default_brightness.value)
134+
FrontPanelLed.setColor(int(config.fp.led.default_color.value, 0))
135+
if checkRec:
136+
FrontPanelLed.instance.checkRecordings()
137+
138+
@staticmethod
139+
def recording():
140+
FrontPanelLed.setFade()
141+
FrontPanelLed.setBlink()
142+
143+
@staticmethod
144+
def stopRecording():
145+
from Screens.Standby import inStandby
146+
if inStandby:
147+
FrontPanelLed.standby(False)
148+
else:
149+
FrontPanelLed.default(False)
150+
151+
@staticmethod
152+
def standby(checkRec=True):
153+
FrontPanelLed.setBrightness(config.fp.led.standby_brightness.value)
154+
FrontPanelLed.setColor(int(config.fp.led.standby_color.value, 0))
155+
if checkRec:
156+
FrontPanelLed.instance.checkRecordings()
157+
158+
@staticmethod
159+
def shutdown():
160+
FrontPanelLed.setFade(0)
161+
FrontPanelLed.setBrightness(0xFF)
162+
FrontPanelLed.setColor(int(config.fp.led.shutdown_color.value, 0))
163+
FrontPanelLed.setBlink()
164+
165+
166+
frontPanelLed = FrontPanelLed()

lib/python/Components/Lcd.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,6 @@
1616

1717
MODEL = BoxInfo.getItem("model")
1818

19-
colorsList = [
20-
("0xff0000", _("Red")),
21-
("0xff3333", _("Rose")),
22-
("0xff5500", _("Orange")),
23-
("0xdd9900", _("Yellow")),
24-
("0x99dd00", _("Lime")),
25-
("0x00ff00", _("Green")),
26-
("0x00ff99", _("Aqua")),
27-
("0x00bbff", _("Olympic blue")),
28-
("0x0000ff", _("Blue")),
29-
("0x6666ff", _("Azure")),
30-
("0x9900ff", _("Purple")),
31-
("0xff0066", _("Pink")),
32-
("0xffffff", _("White")),
33-
]
34-
config.lcd = ConfigSubsection()
35-
config.lcd.ledblinkcontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")
36-
config.lcd.ledbrightnesscontrol = ConfigSlider(default=0xff, increment=25, limits=(0, 0xff))
37-
config.lcd.ledcolorcontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")
38-
config.lcd.ledfadecontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")
39-
4019

4120
class dummyScreen(Screen):
4221
skin = """
@@ -288,6 +267,7 @@ def standbyCounterChanged(configElement):
288267
def InitLcd():
289268
detected = eDBoxLCD.getInstance().detected()
290269
BoxInfo.setItem("Display", detected)
270+
config.lcd = ConfigSubsection()
291271
if isfile("/proc/stb/lcd/mode"):
292272
can_lcdmodechecking = fileReadLine("/proc/stb/lcd/mode")
293273
else:
@@ -480,14 +460,6 @@ def setXcoreVFD(configElement):
480460
config.lcd.ledsuspendcolor = ConfigSelection(default="2", choices=colorchoices)
481461
if isfile("/proc/stb/fp/ledsuspendledcolor"):
482462
config.lcd.ledsuspendcolor.addNotifier(setLedSuspendColor)
483-
if isfile("/proc/stb/fp/led_blink"):
484-
config.lcd.ledblinkcontrolcolor.addNotifier(setLedBlinkControlColor)
485-
if isfile("/proc/stb/fp/led_brightness"):
486-
config.lcd.ledbrightnesscontrol.addNotifier(setLedBrightnessControl)
487-
if isfile("/proc/stb/fp/led_color"):
488-
config.lcd.ledcolorcontrolcolor.addNotifier(setLedColorControlColor)
489-
if isfile("/proc/stb/fp/led_fade"):
490-
config.lcd.ledfadecontrolcolor.addNotifier(setLedFadeControlColor)
491463
config.lcd.power4x7on = ConfigSelection(choices=[
492464
("off", _("Off")),
493465
("on", _("On"))

lib/python/Components/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ install_PYTHON = \
2222
Keyboard.py Sensors.py FanControl.py HdmiCec.py RcModel.py \
2323
Netlink.py InputHotplug.py updatecheck.py \
2424
ImportChannels.py StackTrace.py EpgLoadSave.py \
25-
HdmiRecord.py PowerOffTimer.py NetworkTime.py VfdSymbols.py
25+
HdmiRecord.py PowerOffTimer.py NetworkTime.py FrontPanelLed.py
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from Components.Element import Element
2+
from os import path
3+
# this is not a GUI renderer.
4+
5+
6+
class FrontpanelLed2(Element):
7+
def __init__(self, which=0, patterns=None, boolean=True):
8+
if not patterns:
9+
patterns = [(20, 0, 0xffffffff), (20, 0x55555555, 0x84fc8c04)]
10+
self.which = which
11+
self.boolean = boolean
12+
self.patterns = patterns
13+
Element.__init__(self)
14+
15+
def changed(self, *args, **kwargs):
16+
if self.boolean:
17+
val = self.source.boolean and 0 or 1
18+
else:
19+
val = self.source.value
20+
21+
(speed, pattern, pattern_4bit) = self.patterns[val]
22+
23+
if path.exists("/proc/stb/fp/led%d_pattern" % self.which):
24+
f = open("/proc/stb/fp/led%d_pattern" % self.which, "w")
25+
f.write("%08x" % pattern)
26+
f.close()
27+
if self.which == 0:
28+
if path.exists("/proc/stb/fp/led_set_pattern"):
29+
f = open("/proc/stb/fp/led_set_pattern", "w")
30+
f.write("%08x" % pattern_4bit)
31+
f.close()
32+
if path.exists("/proc/stb/fp/led_set_speed"):
33+
f = open("/proc/stb/fp/led_set_speed", "w")
34+
f.write("%d" % speed)
35+
f.close()
36+
if path.exists("/proc/stb/fp/led_pattern_speed"):
37+
f = open("/proc/stb/fp/led_pattern_speed", "w")
38+
f.write("%d" % speed)
39+
f.close()

lib/python/Components/Renderer/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ installdir = $(pkglibdir)/python/Components/Renderer
33
install_PYTHON = \
44
__init__.py Label.py Progress.py Listbox.py Renderer.py Pixmap.py \
55
FixedLabel.py PositionGauge.py Canvas.py CiModuleControl.py Picon.py Pig.py \
6-
FrontpanelLed.py ChannelNumber.py VideoSize.py NextEpgInfo.py GaugeRender.py \
6+
FrontpanelLed.py FrontpanelLed2.py ChannelNumber.py VideoSize.py NextEpgInfo.py GaugeRender.py \
77
AnalogClockLCD.py AudioIcon.py Bhclock.py Cover.py EmptyEpg.py LcdPicon.py \
88
NextEvents.py PicCript.py PicEmu2.py PiconUni.py RollerCharLCD.py RollerCharLCDLong.py \
99
RunningText.py VolumeText.py VRunningText.py VWatches.py VtiEmuInfo.py VtiImageVersion.py

0 commit comments

Comments
 (0)