Skip to content

Commit

Permalink
[LED] Update to make it more compatible with DreamOne/Two
Browse files Browse the repository at this point in the history
  • Loading branch information
fairbird authored Feb 6, 2024
1 parent 64ac50c commit c9291be
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 526 deletions.
17 changes: 9 additions & 8 deletions data/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,15 @@
<item level="0" requires="ConfigDisplay" text="Show HDMI-Output Res" description="Show HDMI Output Resulution">config.lcd.showoutputresolution</item>
</setup>
<setup key="LedDisplay" title="LED Setup">
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<item level="1" requires="LEDColorControl" text="LED Brightness" description="LED brightness during normal operations.">config.fp.led.default_brightness</item>
<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>
<item level="1" requires="LEDColorControl" text="LED Idle Brightness" description="LED brightness during deep standby.">config.fp.led.standby_brightness</item>
<item level="1" requires="LEDColorControl" text="LED Shutdown Color" description="Power LED state during deep-standby.">config.fp.led.shutdown_color</item>
<item level="0" text="LED Normal" description="LED brightness during normal operations.">config.lcd.ledbrightness</item>
<item level="0" text="LED Standby" description="LED brightness during standby.">config.lcd.ledbrightnessstandby</item>
<item level="0" text="LED Deep Standby" description="LED brightness during deep standby.">config.lcd.ledbrightnessdeepstandby</item>
Expand All @@ -404,10 +409,6 @@
<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>
<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>
<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>
<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>
<item level="0" requires="FrontpanelLEDBrightnessControl" text="Operating LED brightness." description="With this option you can switch the LED brightness.">config.lcd.ledbrightnesscontrol</item>
<item level="0" requires="FrontpanelLEDColorControl" text="Operating LED color." description="With this option you can switch the LED color.">config.lcd.ledcolorcontrolcolor</item>
<item level="0" requires="FrontpanelLEDFadeControl" text="Operating LED fade." description="With this option you can switch the LED fade.">config.lcd.ledfadecontrolcolor</item>
<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>
<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>
<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>
Expand Down
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 VfdDisplay.py
VNetSpeedInfo.py VtiTempFan.py VWeather.py YWeather.py VtiInfo.py Bitrate2.py
81 changes: 0 additions & 81 deletions lib/python/Components/Converter/VfdDisplay.py

This file was deleted.

166 changes: 166 additions & 0 deletions lib/python/Components/FrontPanelLed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
from enigma import iRecordableService
from Components.config import config, ConfigSlider, ConfigSelection, ConfigSubsection
from Tools.Directories import fileExists


config.fp = ConfigSubsection()
config.fp.led = ConfigSubsection()
colors = [
("0xFF0000", _("red")),
("0xFF3333", _("rose")),
("0xFF5500", _("orange")),
("0xDD9900", _("yellow")),
("0x99DD00", _("lime")),
("0x00FF00", _("green")),
("0x00FF99", _("aqua")),
("0x00BBFF", _("olympic blue")),
("0x0000FF", _("blue")),
("0x6666FF", _("azure")),
("0x9900FF", _("purple")),
("0xFF0066", _("pink")),
("0xFFFFFF", _("white")),
]
# running
config.fp.led.default_color = ConfigSelection(colors, default="0xFFFFFF")
config.fp.led.default_brightness = ConfigSlider(default=0xff, increment=25, limits=(0, 0xff))
# standby
config.fp.led.standby_color = ConfigSelection(colors, default="0xFFFFFF")
config.fp.led.standby_brightness = ConfigSlider(default=0x08, increment=8, limits=(0, 0xff))
# shutdown
config.fp.led.shutdown_color = ConfigSelection(colors, default="0xFF5500")

frontPanelLed = None


class FrontPanelLed:
BLINK_PATH = "/proc/stb/fp/led_blink"
BLINK_DEFAULT = 0x0710ff

BRIGHTNESS_PATH = "/proc/stb/fp/led_brightness"
BRIGHTNESS_DEFAULT = 0xFF

COLOR_PATH = "/proc/stb/fp/led_color"
COLOR_DEFAULT = 0xFFFFFF

FADE_PATH = "/proc/stb/fp/led_fade"
FADE_DEFAULT = 0x7

instance = None

def __init__(self):
assert (not FrontPanelLed.instance)
FrontPanelLed.instance = self
self._session = None
self.default()
config.misc.standbyCounter.addNotifier(self._onStandby, initial_call=False)
config.fp.led.default_color.addNotifier(self._onDefaultChanged, initial_call=False)
config.fp.led.default_brightness.addNotifier(self._onDefaultChanged, initial_call=False)

def init(self, session):
self._session = session
session.nav.record_event.append(self.checkRecordings)

def _onDefaultChanged(self, *args):
from Screens.Standby import inStandby
if not inStandby:
FrontPanelLed.default()

def _onStandby(self, *args):
FrontPanelLed.standby()
from Screens.Standby import inStandby
if inStandby:
inStandby.onClose.append(self._onLeaveStandby)

def _onLeaveStandby(self):
FrontPanelLed.default()

def checkRecordings(self, service=None, event=iRecordableService.evEnd):
if not self._session:
return
if event == iRecordableService.evEnd:
recordings = self._session.nav.getRecordings()
if not recordings:
FrontPanelLed.stopRecording()
else:
FrontPanelLed.recording()
elif event == iRecordableService.evStart:
FrontPanelLed.recording()

@staticmethod
def _write(path, value):
if not fileExists(path):
print("[FrontPanelLed] %s does not exist!" % (path))
return
with open(path, 'w') as f:
value = "%x" % (value)
print("[FrontPanelLed] : %s" % (value))
f.write(value)

# 8 bit brightness
@staticmethod
def setBrightness(value=BRIGHTNESS_DEFAULT):
if value > 0xff or value < 0:
print("[FrontPanelLed] LED brightness has to be between 0x0 and 0xff! Using default value (%x)" % (FrontPanelLed.BRIGHTNESS_DEFAULT))
value = FrontPanelLed.BRIGHTNESS_DEFAULT
FrontPanelLed._write(FrontPanelLed.BRIGHTNESS_PATH, value)

# 24 bit RGB
@staticmethod
def setColor(value=COLOR_DEFAULT):
if value > 0xffffff or value < 0:
print("[FrontPanelLed] LED color has to be between 0x0 and 0xffffff (r, g b)! Using default value (%x)" % (FrontPanelLed.COLOR_DEFAULT))
value = FrontPanelLed.COLOR_DEFAULT
FrontPanelLed._write(FrontPanelLed.COLOR_PATH, value)

# 8 bit on-time (* 31ms), 8 bit total time (* 31ms), 8 bit number of repeats (ff == unlimited)
@staticmethod
def setBlink(value=BLINK_DEFAULT):
if value > 0xffffff or value < 0:
print("[FrontPanelLed] LED blink has to be between 0x0 and 0xffffff (on, total, repeats)! Using default value (%x)" % (FrontPanelLed.BLINK_DEFAULT))
value = FrontPanelLed.BLINK_DEFAULT
FrontPanelLed._write(FrontPanelLed.BLINK_PATH, value)

# 8 bit fade time (* 51ms)
@staticmethod
def setFade(value=FADE_DEFAULT):
if value > 0xff or value < 0:
value = FrontPanelLed.FADE_DEFAULT
print("[FrontPanelLed] LED fade has to be between 0x0 and 0xff! Using default value (%x)" % (FrontPanelLed.FADE_DEFAULT))
FrontPanelLed._write(FrontPanelLed.FADE_PATH, value)

@staticmethod
def default(checkRec=True):
FrontPanelLed.setBrightness(config.fp.led.default_brightness.value)
FrontPanelLed.setColor(int(config.fp.led.default_color.value, 0))
if checkRec:
FrontPanelLed.instance.checkRecordings()

@staticmethod
def recording():
FrontPanelLed.setFade()
FrontPanelLed.setBlink()

@staticmethod
def stopRecording():
from Screens.Standby import inStandby
if inStandby:
FrontPanelLed.standby(False)
else:
FrontPanelLed.default(False)

@staticmethod
def standby(checkRec=True):
FrontPanelLed.setBrightness(config.fp.led.standby_brightness.value)
FrontPanelLed.setColor(int(config.fp.led.standby_color.value, 0))
if checkRec:
FrontPanelLed.instance.checkRecordings()

@staticmethod
def shutdown():
FrontPanelLed.setFade(0)
FrontPanelLed.setBrightness(0xFF)
FrontPanelLed.setColor(int(config.fp.led.shutdown_color.value, 0))
FrontPanelLed.setBlink()


frontPanelLed = FrontPanelLed()
30 changes: 1 addition & 29 deletions lib/python/Components/Lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,6 @@

MODEL = BoxInfo.getItem("model")

colorsList = [
("0xff0000", _("Red")),
("0xff3333", _("Rose")),
("0xff5500", _("Orange")),
("0xdd9900", _("Yellow")),
("0x99dd00", _("Lime")),
("0x00ff00", _("Green")),
("0x00ff99", _("Aqua")),
("0x00bbff", _("Olympic blue")),
("0x0000ff", _("Blue")),
("0x6666ff", _("Azure")),
("0x9900ff", _("Purple")),
("0xff0066", _("Pink")),
("0xffffff", _("White")),
]
config.lcd = ConfigSubsection()
config.lcd.ledblinkcontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")
config.lcd.ledbrightnesscontrol = ConfigSlider(default=0xff, increment=25, limits=(0, 0xff))
config.lcd.ledcolorcontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")
config.lcd.ledfadecontrolcolor = ConfigSelection(choices=colorsList, default="0xffffff")


class dummyScreen(Screen):
skin = """
Expand Down Expand Up @@ -288,6 +267,7 @@ def standbyCounterChanged(configElement):
def InitLcd():
detected = eDBoxLCD.getInstance().detected()
BoxInfo.setItem("Display", detected)
config.lcd = ConfigSubsection()
if isfile("/proc/stb/lcd/mode"):
can_lcdmodechecking = fileReadLine("/proc/stb/lcd/mode")
else:
Expand Down Expand Up @@ -480,14 +460,6 @@ def setXcoreVFD(configElement):
config.lcd.ledsuspendcolor = ConfigSelection(default="2", choices=colorchoices)
if isfile("/proc/stb/fp/ledsuspendledcolor"):
config.lcd.ledsuspendcolor.addNotifier(setLedSuspendColor)
if isfile("/proc/stb/fp/led_blink"):
config.lcd.ledblinkcontrolcolor.addNotifier(setLedBlinkControlColor)
if isfile("/proc/stb/fp/led_brightness"):
config.lcd.ledbrightnesscontrol.addNotifier(setLedBrightnessControl)
if isfile("/proc/stb/fp/led_color"):
config.lcd.ledcolorcontrolcolor.addNotifier(setLedColorControlColor)
if isfile("/proc/stb/fp/led_fade"):
config.lcd.ledfadecontrolcolor.addNotifier(setLedFadeControlColor)
config.lcd.power4x7on = ConfigSelection(choices=[
("off", _("Off")),
("on", _("On"))
Expand Down
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 VfdSymbols.py
HdmiRecord.py PowerOffTimer.py NetworkTime.py FrontPanelLed.py
39 changes: 39 additions & 0 deletions lib/python/Components/Renderer/FrontpanelLed2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from Components.Element import Element
from os import path
# this is not a GUI renderer.


class FrontpanelLed2(Element):
def __init__(self, which=0, patterns=None, boolean=True):
if not patterns:
patterns = [(20, 0, 0xffffffff), (20, 0x55555555, 0x84fc8c04)]
self.which = which
self.boolean = boolean
self.patterns = patterns
Element.__init__(self)

def changed(self, *args, **kwargs):
if self.boolean:
val = self.source.boolean and 0 or 1
else:
val = self.source.value

(speed, pattern, pattern_4bit) = self.patterns[val]

if path.exists("/proc/stb/fp/led%d_pattern" % self.which):
f = open("/proc/stb/fp/led%d_pattern" % self.which, "w")
f.write("%08x" % pattern)
f.close()
if self.which == 0:
if path.exists("/proc/stb/fp/led_set_pattern"):
f = open("/proc/stb/fp/led_set_pattern", "w")
f.write("%08x" % pattern_4bit)
f.close()
if path.exists("/proc/stb/fp/led_set_speed"):
f = open("/proc/stb/fp/led_set_speed", "w")
f.write("%d" % speed)
f.close()
if path.exists("/proc/stb/fp/led_pattern_speed"):
f = open("/proc/stb/fp/led_pattern_speed", "w")
f.write("%d" % speed)
f.close()
2 changes: 1 addition & 1 deletion lib/python/Components/Renderer/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ installdir = $(pkglibdir)/python/Components/Renderer
install_PYTHON = \
__init__.py Label.py Progress.py Listbox.py Renderer.py Pixmap.py \
FixedLabel.py PositionGauge.py Canvas.py CiModuleControl.py Picon.py Pig.py \
FrontpanelLed.py ChannelNumber.py VideoSize.py NextEpgInfo.py GaugeRender.py \
FrontpanelLed.py FrontpanelLed2.py ChannelNumber.py VideoSize.py NextEpgInfo.py GaugeRender.py \
AnalogClockLCD.py AudioIcon.py Bhclock.py Cover.py EmptyEpg.py LcdPicon.py \
NextEvents.py PicCript.py PicEmu2.py PiconUni.py RollerCharLCD.py RollerCharLCDLong.py \
RunningText.py VolumeText.py VRunningText.py VWatches.py VtiEmuInfo.py VtiImageVersion.py
Loading

0 comments on commit c9291be

Please sign in to comment.