import NavigationInstance
from enigma import iRecordableService
from Components.ConfigList import ConfigListScreen
-from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger, ConfigSlider
+from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSlider
+from enigma import eTimer
config.plugins.simplefancontrols = ConfigSubsection()
-config.plugins.simplefancontrols.standbymode = ConfigSelection(default = "on", choices = [
- ("off", _("off")), ("on", _("on"))])
-config.plugins.simplefancontrols.recordingmode = ConfigSelection(default = "on", choices = [
- ("off", _("no")), ("on", _("yes"))])
-config.plugins.simplefancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (5, 255))
+config.plugins.simplefancontrols.standbymode = ConfigSelection(default = "yes", choices = [
+ ("no", _("no")), ("yes", _("yes"))])
+config.plugins.simplefancontrols.pwmvalue = ConfigSlider(default = 100, increment = 5, limits = (0, 255))
class instandbyOn:
def __init__(self):
+ self.fanoffmode = 'OFF'
+ self.default_pwm_value_onRecordings = 5
config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
+ if config.plugins.simplefancontrols.pwmvalue.value == 0:
+ self.fanoffmode = 'ON'
+ self.InitTimer = eTimer()
+ if self.initConfig not in self.InitTimer.callback:
+ self.InitTimer.callback.append(self.initConfig)
+ print "<SimpleFancontrol> init : Timer loop start!!"
+ self.InitTimer.startLongTimer(3)
+ print "<SimpleFancontrol> init : self.fanoffmode : ", self.fanoffmode
+ print "<SimpleFancontrol> init : config.plugins.simplefancontrols.pwmvalue.value : ", config.plugins.simplefancontrols.pwmvalue.value
+
+ def initConfig(self):
+ print "<SimpleFancontrol>Try initConfig..."
+ if NavigationInstance.instance is None:
+ self.InitTimer.startLongTimer(1)
+ else:
+ if config.plugins.simplefancontrols.pwmvalue.value == 0:
+ currentPWM = self.getPWM()
+ NavigationInstance.instance.record_event.append(self.getRecordEvent_onFanOFF)
+ recordings = NavigationInstance.instance.getRecordings()
+ print "<SimpleFancontrol> initConfig : recordings : ", recordings
+ if recordings and currentPWM != self.default_pwm_value_onRecordings:
+ self.setPWM(self.default_pwm_value_onRecordings)
+ elif not recordings and currentPWM > 0:
+ self.setPWM(0)
+ else:
+ print "<SimpleFancontrol> initConfig : setPWM pass"
+ elif self.getPWM() != config.plugins.simplefancontrols.pwmvalue.value:
+ self.setPWM(config.plugins.simplefancontrols.pwmvalue.value)
def standbyBegin(self, configElement):
- print "<SimpleFancontrol> config.plugins.fancontrols.standbymode.value : ", config.plugins.simplefancontrols.standbymode.value
- if config.plugins.simplefancontrols.standbymode.value == "on":
+ print "<SimpleFancontrol> standbyBegin : config.plugins.fancontrols.standbymode.value : ", config.plugins.simplefancontrols.standbymode.value
+ print "<SimpleFancontrol> standbyBegin : self.fanoffmode : ", self.fanoffmode
+ if config.plugins.simplefancontrols.standbymode.value == "yes" and config.plugins.simplefancontrols.pwmvalue > 0:
from Screens.Standby import inStandby
inStandby.onClose.append(self.StandbyEnd)
NavigationInstance.instance.record_event.append(self.getRecordEvent)
f.write("%x" % value)
f.close()
+ def appendRecordEventCallback(self):
+ print "<SimpleFancontrol> appendRecordEventCallback "
+ NavigationInstance.instance.record_event.append(self.getRecordEvent_onFanOFF)
+ recordings = NavigationInstance.instance.getRecordings()
+ if recordings:
+ instandbyon.setPWM(self.default_pwm_value_onRecordings)
+
+ def removeRecordEventCallback(self):
+ print "<SimpleFancontrol> removeRecordEventCallback "
+ NavigationInstance.instance.record_event.remove(self.getRecordEvent_onFanOFF)
+
+ def getRecordEvent_onFanOFF(self, recservice, event):
+ recordings = len(NavigationInstance.instance.getRecordings())
+ print "<SimpleFancontrol_> recordings : %d , event : %d" % (recordings,event)
+ if event == iRecordableService.evEnd:
+ print "<SimpleFancontrol_> getRecordEvent : evEnd"
+ if recordings == 0:
+ self.setPWM(0)
+ elif event == iRecordableService.evStart:
+ print "<SimpleFancontrol_> getRecordEvent : evStart"
+ if self.getPWM() == 0:
+ self.setPWM(self.default_pwm_value_onRecordings)
+
instandbyon = instandbyOn()
from Components.Sources.StaticText import StaticText
from Plugins.Plugin import PluginDescriptor
from Plugins.SystemPlugins.ManualFancontrol.InstandbyOn import instandbyon
+import NavigationInstance
class ManualFancontrol(Screen,ConfigListScreen):
skin = """
def __init__(self,session):
Screen.__init__(self,session)
- print "init"
- self.setup_title="TestSetupTitle"
self.session = session
self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
{
self["key_red"] = StaticText(_("Cancel"))
self["key_green"] = StaticText(_("Save"))
self["current"] = StaticText(_(" "))
- self.createSetup()
+ self.configSetup()
+ self.backup_pwm = instandbyon.getPWM()
+ self.OnRecording = False
+
+ def isRecording(self):
+ recordings = NavigationInstance.instance.getRecordings()
+ if recordings :
+ return True
+ else:
+ return False
def displayCurrentValue(self):
- cur = self["config"].getCurrent()[0]
- val = self["config"].getCurrent()[1].value
- currrent_val = cur+" : "+str(val)
+ currrent_val = self["config"].getCurrent()[0]+" : "+str(self["config"].getCurrent()[1].value)
self["current"].setText(_(currrent_val))
print currrent_val
def selectionChanged(self):
- self.displayCurrentValue()
if self["config"].getCurrent() == self.pwmEntry:
instandbyon.setPWM(self["config"].getCurrent()[1].value)
def keyLeft(self):
+ oldpwmvalue=config.plugins.simplefancontrols.pwmvalue.value
ConfigListScreen.keyLeft(self)
- self.newConfig()
+ if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 5:
+ self.createSetup()
+ else:
+ self.displayCurrentValue()
self.selectionChanged()
def keyRight(self):
+ oldpwmvalue=config.plugins.simplefancontrols.pwmvalue.value
ConfigListScreen.keyRight(self)
- self.newConfig()
+ if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 0:
+ self.createSetup()
+ while self["config"].getCurrent() != self.pwmEntry:
+ self["config"].setCurrentIndex(self["config"].getCurrentIndex()+1)
+ else:
+ self.displayCurrentValue()
self.selectionChanged()
def createSetup(self):
self.list = []
- self.standbyEntry = getConfigListEntry(_("FanOFF InStanby"), config.plugins.simplefancontrols.standbymode)
- self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.simplefancontrols.pwmvalue)
- self.list.append( self.standbyEntry )
+ if config.plugins.simplefancontrols.pwmvalue.value > 0:
+ self.list.append( self.standbyEntry )
self.list.append( self.pwmEntry )
self["config"].list = self.list
self["config"].l.setList(self.list)
+
+ def configSetup(self):
+ self.standbyEntry = getConfigListEntry(_("FanOFF InStanby"), config.plugins.simplefancontrols.standbymode)
+ self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.simplefancontrols.pwmvalue)
if not self.displayCurrentValue in self["config"].onSelectionChanged:
self["config"].onSelectionChanged.append(self.displayCurrentValue)
+ self.createSetup()
def newConfig(self):
- if self["config"].getCurrent() == self.standbyEntry:
+ if self["config"].getCurrent() == self.pwmEntry and config.plugins.simplefancontrols.pwmvalue.value == 0:
self.createSetup()
def keySave(self):
+ if instandbyon.fanoffmode is 'OFF' and config.plugins.simplefancontrols.pwmvalue.value == 0:
+ instandbyon.appendRecordEventCallback()
+ instandbyon.fanoffmode = 'ON'
+ print "<SimpleFancontrol> instandbyon.fanoffmode 'OFF' -> 'ON'"
+
+ elif instandbyon.fanoffmode is 'ON' and config.plugins.simplefancontrols.pwmvalue.value != 0:
+ instandbyon.removeRecordEventCallback()
+ instandbyon.fanoffmode = 'OFF'
+ print "<SimpleFancontrol> instandbyon.fanoffmode 'ON' -> 'OFF'"
+ if instandbyon.fanoffmode == 'ON' and self.isRecording() and instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
+ instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
ConfigListScreen.keySave(self)
+ def cancelConfirm(self, result):
+ if not result:
+ return
+ for x in self["config"].list:
+ x[1].cancel()
+ if instandbyon.fanoffmode == 'ON' and self.isRecording():
+ if instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
+ instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
+ else:
+ pass
+ else:
+ instandbyon.setPWM(config.plugins.simplefancontrols.pwmvalue.value)
+ self.close()
+
def keyCancel(self):
- ConfigListScreen.keyCancel(self)
+ if self["config"].isChanged():
+ self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
+ else:
+ if instandbyon.fanoffmode == 'ON' and self.isRecording() and instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
+ instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
+ self.close()
def main(session, **kwargs):
session.open(ManualFancontrol)