Example #1
0
	def getCustom(self,profilenr):
		try:
			log("",self)
			fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "r")
			customsettings = fo.read(256)
			fo.close()

			customsettings = customsettings.split("|")
			config.plugins.enigmalight.saturation.setValue(customsettings[0])
			config.plugins.enigmalight.value.setValue(customsettings[1])
			config.plugins.enigmalight.speed.setValue(customsettings[2])
			config.plugins.enigmalight.valuemax.setValue(customsettings[3])
			config.plugins.enigmalight.valuemin.setValue(customsettings[4])
			config.plugins.enigmalight.saturationmin.setValue(customsettings[5])
			config.plugins.enigmalight.saturationmax.setValue(customsettings[6])
			config.plugins.enigmalight.gamma.setValue(customsettings[7])
			config.plugins.enigmalight.threshold.setValue(customsettings[8])
			config.plugins.enigmalight.autospeed.setValue(customsettings[9])

			if self.controller.lightsEnabled:
				self.controller.writeSettings()

		except:
			from traceback import format_exc
			log("Error: " + format_exc(),self)
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				showMessage(self._session,_("Can't get settings from profile...", "W", timeout = 10))
			except:
				pass
Example #2
0
	def getCustom(self,profilenr):
		try:
			log("",self)
			fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "r")
			customsettings = fo.read(256)
			fo.close()
			
			customsettings = customsettings.split("|")
			config.plugins.enigmalight.saturation.setValue(customsettings[0])
			config.plugins.enigmalight.value.setValue(customsettings[1])
			config.plugins.enigmalight.speed.setValue(customsettings[2])
			config.plugins.enigmalight.valuemax.setValue(customsettings[3])
			config.plugins.enigmalight.valuemin.setValue(customsettings[4])
			config.plugins.enigmalight.saturationmin.setValue(customsettings[5])
			config.plugins.enigmalight.saturationmax.setValue(customsettings[6])
			config.plugins.enigmalight.gamma.setValue(customsettings[7])
			config.plugins.enigmalight.threshold.setValue(customsettings[8])
			config.plugins.enigmalight.autospeed.setValue(customsettings[9])

			if self.controller.lightsEnabled:
				self.controller.writeSettings()

		except:
			from traceback import format_exc
			log("Error: " + format_exc(),self)
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				showMessage(self._session,_("Can't get settings from profile...", "W", timeout = 10))
			except:
				pass
Example #3
0
	def saveCustom(self,profilenr):
		try:
			log("",self)
			fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "wb")
			fo.write(str(config.plugins.enigmalight.saturation.value)+"|")
			fo.write(str(config.plugins.enigmalight.value.value)+"|")
			fo.write(str(config.plugins.enigmalight.speed.value)+"|")
			fo.write(str(config.plugins.enigmalight.valuemax.value)+"|")
			fo.write(str(config.plugins.enigmalight.valuemin.value)+"|")
			fo.write(str(config.plugins.enigmalight.saturationmin.value)+"|")
			fo.write(str(config.plugins.enigmalight.saturationmax.value)+"|")
			fo.write(str(config.plugins.enigmalight.gamma.value)+"|")
			fo.write(str(config.plugins.enigmalight.threshold.value)+"|")
			fo.write(str(config.plugins.enigmalight.autospeed.value))

			fo.close();
			
		except:
			from traceback import format_exc
			log("Error:" +format_exc(),self)
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				showMessage(self._session,_("Can't write settings to profile...", "W", timeout = 10))
			except:
				pass
Example #4
0
	def saveCustom(self,profilenr):
		try:
			log("",self)
			fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "wb")
			fo.write(str(config.plugins.enigmalight.saturation.value)+"|")
			fo.write(str(config.plugins.enigmalight.value.value)+"|")
			fo.write(str(config.plugins.enigmalight.speed.value)+"|")
			fo.write(str(config.plugins.enigmalight.valuemax.value)+"|")
			fo.write(str(config.plugins.enigmalight.valuemin.value)+"|")
			fo.write(str(config.plugins.enigmalight.saturationmin.value)+"|")
			fo.write(str(config.plugins.enigmalight.saturationmax.value)+"|")
			fo.write(str(config.plugins.enigmalight.gamma.value)+"|")
			fo.write(str(config.plugins.enigmalight.threshold.value)+"|")
			fo.write(str(config.plugins.enigmalight.autospeed.value))

			fo.close();
			
		except:
			from traceback import format_exc
			log("Error:" +format_exc(),self)
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				showMessage(self._session,_("Can't write settings to profile...", "W", timeout = 10))
			except:
				pass
Example #5
0
	def readInfo(self):
		#log("",self)

		try:
			self.serverstate = self.sockClass.getServerState()

			self.current_mode = str(self.sockClass.getMode())
			self.current_fps = str(self.sockClass.getFPS())
			self.current_resolution = str(self.sockClass.getRes())

			if self.current_mode == "0" and self.serverstate:
				self.connectedAddres = self.sockClass.getConnectedAddress()
			else:
				self.connectedAddres = None
		except:
			self.current_fps = "0"
			self.current_resolution = "0x0"
			self.current_mode = "Off"
			self.current_cpu = "0"

			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #6
0
    def readInfo(self):
        #log("",self)

        try:
            self.serverstate = self.sockClass.getServerState()

            self.current_mode = str(self.sockClass.getMode())
            self.current_fps = str(self.sockClass.getFPS())
            self.current_resolution = str(self.sockClass.getRes())

            if self.current_mode == "0" and self.serverstate:
                self.connectedAddres = self.sockClass.getConnectedAddress()
            else:
                self.connectedAddres = None
        except:
            self.current_fps = "0"
            self.current_resolution = "0x0"
            self.current_mode = "Off"
            self.current_cpu = "0"

            from traceback import format_exc
            log("", self, "Error: " + format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
            except:
                pass
Example #7
0
def Autostart(reason, session=None, **kwargs):

	try:
		if reason == 0:
			Prepare()

			if config.plugins.enigmalight.autostart.getValue() != str(0):
				log("",None,"plugin::Autostart(reason, session=None, **kwargs)) > Autostart enigmalight..")
				
				if config.plugins.enigmalight.autostart.getValue() == str(1):				
					controller.Control("start", "server")
				elif config.plugins.enigmalight.autostart.getValue() == str(2):				
					controller.Control("start", "dynamic")
				elif config.plugins.enigmalight.autostart.getValue() == str(3):				
					controller.Control("start", "moodlamp")
			
			if config.plugins.enigmalight.remote_server.getValue():
				controller.StartServer()
			else:
				controller.StopServer()
	except:
		from traceback import format_exc
		log("",None,"plugin::Autostart()) > Error: " +format_exc())
		try:
			open(getCrashFilePath(),"w").write(format_exc())
		except:
			pass
Example #8
0
    def finishLayout(self):

        log("", self, "Finisch layout....")

        try:

            self["txt_green"].setText(_("Turn lights on"))
            self["txt_red"].setText(_("Lights off"))
            self["txt_blue"].setText(_("Switch to dynamic mode"))
            self["txt_yellow"].setText(_("Switch to moodlamp mode"))

            self["txt_check"].setText(_("Busy...."))

            self.mainMenuList = []

            self.mainMenuList.append(
                (_("Settings"), "EL_Screen_Settings", "settingsEntry"))
            self.mainMenuList.append(
                (_("Tuning"), "EL_Screen_Tuning", "tuningEntry"))
            self.mainMenuList.append(
                (_("Moodlamp"), "EL_Screen_Moodlamp", "moodlampEntry"))
            self.mainMenuList.append(
                (_("Config Editor"), "EL_Screen_ConfigEditor", "editorEntry"))
            self.mainMenuList.append(
                (_("Box Info & About"), "EL_Screen_About", "aboutEntry"))
            self.mainMenuList.append(
                (_("Help"), "EL_Screen_Help", "helpEntry"))

            # now that our mainMenuList is populated we set the list element
            self["menu"].setList(self.mainMenuList)

            # save the mainMenuList for later usage
            self.menu_main_list = self["menu"].list

            self.hideOnOff()
            self.controller.setScreen(self)

            self.refreshMenu()

            if not config.plugins.enigmalight.showstatusbar.getValue():
                self["statusbar"].hide()
                self["txt_statusbar"].hide()
                self["txt_statusbar_info"].hide()
            else:
                self["statusbar"].show()
                self["txt_statusbar"].show()
                self["txt_statusbar_info"].show()

            log("", self, "Layout Finisched!")

        except:
            from traceback import format_exc
            log("Error:", format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
            except:
                pass
Example #9
0
 def left(self):
     log("", self)
     try:
         self.refreshOrientationHorMenu(-1)
     except:
         from traceback import format_exc
         log("Error:", format_exc())
         try:
             open(getCrashFilePath(), "w").write(format_exc())
         except:
             pass
Example #10
0
def sessionstart(reason, **kwargs):
	try:
		if reason == 0:
			timer.setSession(kwargs["session"])
			controller.setGlobalSession(kwargs["session"])
	except:
		from traceback import format_exc
		log("",None,"plugin::sessionstart() > Error: " +format_exc())
		try:
			open(getCrashFilePath(),"w").write(format_exc())
		except:
			pass
Example #11
0
def sessionstart(reason, **kwargs):

	try:
	    if reason == 0:
	        timer.setSession(kwargs["session"])
	        controller.setGlobalSession(kwargs["session"])
	except:
		from traceback import format_exc
		log("",None,"plugin::sessionstart() > Error: " +format_exc())
		try:
			open(getCrashFilePath(),"w").write(format_exc())
		except:
			pass
Example #12
0
	def checkForUpdate(self,controller):
		
		self.controller = controller

		log("",self,"Check for update....")

		self.controller.setStatusBarInfo(_("Check for update.."))

		if testInetConnectivity():
			self.url = config.plugins.enigmalight.url.value + config.plugins.enigmalight.updatexml.value
			log("",self,"Checking URL: " + self.url) 
			try:
				f = urllib2.urlopen(self.url)
				html = f.read()
				dom = parseString(html)
				update = dom.getElementsByTagName("update")[0]
				version = update.getElementsByTagName("version")[0]

				remoteversion = version.childNodes[0].data
				urls = update.getElementsByTagName("url")

				currentversion = getVersion()
				currentbeta = currentversion[-2:]
				remotebeta = remoteversion[-2:]

				self.remoteurl = ""
				for url in urls:
				    self.remoteurl = url.childNodes[0].data

				#print("""Version: %s - URL: %s""" % (remoteversion, self.remoteurl))
				if currentbeta < remotebeta:
					self.latestVersion = remoteversion
					self.controller.setStatusBarInfo(_("New update available !!"))
					#if self.session != None:
					self.session.openWithCallback(self.startUpdate, MessageBox,_("Your current Version is " + str(currentversion) + "\nUpdate to " + str(remoteversion) + " found!\n\nDo you want to update now?"), MessageBox.TYPE_YESNO)
				else:
					self.controller.setStatusBarInfo(_("No update available.."))
					#if self.session != None:
					showMessage(self.session, _("No update available.."), "I")
			except:
				from traceback import format_exc
				log("",self,"Error: " +format_exc())
				try:
					log("",self,"Could not download HTTP Page")
					open(getCrashFilePath(),"w").write(format_exc())
				except:
					pass
				
		else:
			self.controller.setStatusBarInfo(_("No Internetconnection.."))
			self.session.openWithCallback(self.close, MessageBox,_("No internet connection available or curl is not installed!"), MessageBox.TYPE_INFO)
Example #13
0
    def checkIfRunningFinisched(self, control, callback=None):
        log("", self)
        log("", self, "control[command] = " + str(control['command']))
        log("", self, "control[value] = " + str(control['value']))
        log("", self,
            "control[startcommand] = " + str(control['startcommand']))
        log("", self, "callback = " + str(callback))

        pid = self.sockClass.getCommand("get pidnr")
        log("", self, "pid = " + str(pid))

        checkResult = False

        try:
            if pid is None:

                #Check if engimalight is running
                #it it's not running, then start it.
                if control['value'] != "stop" and control[
                        'value'] != "sleep" and control['value'] != "network":
                    log("", self,
                        "[/usr/bin/enigmalight] not running, Starting..")

                    checkResult = True
                    self.startConsole = Console()
                    self.startConsole.ePopen(str(control['startcommand']),
                                             self.DoControl,
                                             [checkResult, control, callback])

                #If network mode is used
                elif control['command'] == "network":
                    #connect client with host
                    log("", self, "network")
            else:
                #Enigmalight is already running
                log(
                    "", self,
                    "[/usr/bin/enigmalight] already running with pid " +
                    str(pid))
                self.DoControl(None, None, [checkResult, control, callback])
        except:
            from traceback import format_exc
            log("", self, "Error: " + format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
            except:
                pass
Example #14
0
	def setStatusBarInfo(self,info):
		log("",self)
		try:
			if self.currentScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,_("Info: ["+ info +"]"))
				pass
			#clear info
			self.clearStatusInfo = 2
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
Example #15
0
	def setStatusBarInfo(self,info):
		log("",self)
		try:
			if self.currentScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,_("Info: ["+ info +"]"))
				pass
			#clear info
			self.clearStatusInfo = 2
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
Example #16
0
def EnigmaLight_MainMenu(*args, **kwargs):
	try:
		log("",None,"plugin::EnigmaLight_MainMenu() > MainMenu..")
		import EL_MainMenu

		log("",None,"plugin::EnigmaLight_MainMenu() > Set Instances..")
		EL_MainMenu.TIMER_INSTANCE = timer
		EL_MainMenu.CONTROLLER_INSTANCE = controller

		return EL_MainMenu.EL_Screen_MainMenu(*args, **kwargs)
	except:
		from traceback import format_exc
		log("",None,"plugin::EnigmaLight_MainMenu() > Error: " +format_exc())
		try:
			open(getCrashFilePath(),"w").write(format_exc())
		except:
			pass
Example #17
0
def Plugins(**kwargs):
	try:
		myList = [PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=sessionstart),
	    PluginDescriptor(name=_('EnigmaLight'), description=_('TV backlight'), where=PluginDescriptor.WHERE_PLUGINMENU, icon='button.png', needsRestart = False, fnc=main),
	    PluginDescriptor(name=_('EnigmaLight | on/off'), description=_('TV backlight'), where=PluginDescriptor.WHERE_EXTENSIONSMENU, icon='button.png', needsRestart = False, fnc=controller.Toggle),
	    PluginDescriptor(name=_('EnigmaLight | Settings'), description=_('Enigmalight GUI'), where=PluginDescriptor.WHERE_EXTENSIONSMENU, icon='button.png', needsRestart = False, fnc=main),
	    PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = Autostart)]
	    #PluginDescriptor(name=_('EnigmaLight | Switch Mode'), description=_('TV backlight'), where=PluginDescriptor.WHERE_EXTENSIONSMENU, icon='button.png', needsRestart = False, fnc=LightToggle)]
	except:
		from traceback import format_exc
		log("",None,"plugin::Plugins(**kwargs) > Error: " +format_exc())
		try:
			open(getCrashFilePath(),"w").write(format_exc())
		except:
			pass

	return myList
Example #18
0
	def getCpu(self):
		#log("",self)
		try:
			cpu = commands.getstatusoutput('top -n1 | grep "enigmalight" | awk \'{print $7}\'')
			cpu_split = str(cpu).split("'")
			cpu = cpu_split[1][:3]#remove new line and other stuff
			cpu = cpu.replace("\\","")
			#print ("[EnigmaLight] Cpu usage [" + cpu + "]")
			self.current_cpu = cpu
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
Example #19
0
	def getCpu(self):
		#log("",self)
		try:
			cpu = commands.getstatusoutput('top -n1 | grep "enigmalight" | awk \'{print $7}\'')
			cpu_split = str(cpu).split("'")
			cpu = cpu_split[1][:3]#remove new line and other stuff
			cpu = cpu.replace("\\","")
			#print ("[EnigmaLight] Cpu usage [" + cpu + "]")
			self.current_cpu = cpu
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
Example #20
0
	def killEnigmalightNow(self, values = None, callback = None):
		log("",self)

		try:
			self.checkConsole = Console()
			command = "killall -9 enigmalight"

			#set callback from saved callback
			if callback == None and self.callback != None:
				callback = self.callback
				self.callback = None

			self.checkConsole.ePopen(command, self.killEnigmalightFinisched, [values, callback])
		except:
			from traceback import format_exc
			log("Error:",format_exc() )
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #21
0
	def killEnigmalightNow(self, values = None, callback = None):
		log("",self)

		try:
			self.checkConsole = Console()
			command = "killall -9 enigmalight"

			#set callback from saved callback
			if callback == None and self.callback != None:
				callback = self.callback
				self.callback = None

			self.checkConsole.ePopen(command, self.killEnigmalightFinisched, [values, callback])
		except:
			from traceback import format_exc
			log("Error:",format_exc() )
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #22
0
	def checkIfRunningFinisched(self, control, callback = None):
		log("",self)
		log("",self,"control[command] = " + str(control['command']))
		log("",self,"control[value] = " + str(control['value']))
		log("",self,"control[startcommand] = " + str(control['startcommand']))
		log("",self,"callback = " + str(callback))

		pid = self.sockClass.getCommand("get pidnr")
		log("",self,"pid = " + str(pid))

		checkResult = False

		try:
			if pid is None:

				#Check if engimalight is running
				#it it's not running, then start it.
				if control['value'] != "stop" and control['value'] != "sleep" and control['value'] != "network":
					log("",self,"[/usr/bin/enigmalight] not running, Starting..")

					checkResult = True
					self.startConsole = Console()
					self.startConsole.ePopen(str(control['startcommand']), self.DoControl, [checkResult, control, callback])
				
				#If network mode is used
				elif control['command'] == "network":
					#connect client with host
					log("",self,"network")
			else:
				#Enigmalight is already running
				log("",self,"[/usr/bin/enigmalight] already running with pid " + str(pid))
				self.DoControl(None, None, [checkResult, control, callback])
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #23
0
from EL_Control import Controller
from EL_Timer import ELightTimer
from EL_About import EL_Screen_About

m_session = None

## Start timer thread
timer = ELightTimer()
timer.start()

## Start controller thread
controller = Controller()
controller.start()

#remove old files
rmFile(getCrashFilePath())
rmFile("/tmp/enigmalight_gui.log")

#check if enigmalight is pointed to good OE Version, if not then make the link
checkSymbolic()

#===============================================================================
# main
# Actions to take place when starting the plugin over extensions
#===============================================================================
#noinspection PyUnusedLocal
def main(session, **kwargs):
	log("",None,"plugin::sessionstart()")
	session.open(EnigmaLight_MainMenu)
	
def sessionstart(reason, **kwargs):
Example #24
0
	def __init__(self, session):
		try:
			log("",self)
			Screen.__init__(self, session)
			HelpableScreen.__init__(self)
			
			self.cfglist = []
			ConfigListScreen.__init__(self, self.cfglist, session, on_change = self._changed)
			
			self._session = session
			self._hasChanged = False

			self.controller = None
			self.selected = None

			self.aspect = getAspect()
			self.old_service = self.session.nav.getCurrentlyPlayingServiceReference()	
			
			# Disable OSD Transparency
			try:
				self.can_osd_alpha = open("/proc/stb/video/alpha", "r") and True or False
			except:
				self.can_osd_alpha = False
			
			if config.plugins.enigmalight.sampleBackground.getValue() == True:
				self.showBackground()
			
			self["txt_green"] = Label()
			self["btn_green"] = Pixmap()

			self["statusbar"] = Pixmap()
			self["txt_statusbar"] = Label()
			self["txt_statusbar_info"] = Label()

			self["help"] = StaticText()
			
			self["setupActions"] = ActionMap(["SetupActions", "ColorActions", "EL_Settings"],
			{
				"green": self.keySave,
				"red": self.keyCancel,
				"cancel": self.keyCancel,
				"ok": self.ok,
				"left": self.keyLeft,
				"right": self.keyRight,
				"bouquet_up":	self.keyBouquetUp,
				"bouquet_down":	self.keyBouquetDown,
				"jumpNextMark":	self.keyNext,
				"jumpPreviousMark": self.keyPrev,
			}, -2)

			self["txt_green"].setText(_("Save"))

			self.createSetup()
			
			self.onLayoutFinish.append(self.finishLayout)

		except:
			from traceback import format_exc
			log("",self,"Error:" + format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #25
0
	def run(self):
		log("",self,"ControlThread: Running...")
		
		checkLoop = 4 # check every 2 sec for cpu usage
		loopCount = 0

		while(self.thread_running):

			#Check connection
			self.sockClass.checkConnection()

			#if not connected then connect with it.
			if self.sockClass.connectedWithEnigmalight():
				self.readInfo() #get runninginfo				
			else:
				self.lightsEnabled = False
				self.current_fps = "0"
				self.current_resolution = "0x0"
				self.current_mode = "Off"
				self.current_cpu = "0"

			#when checkloop is 2 then getcpu
			
		 	if(loopCount == checkLoop):		 		
		 		#self.getCpu()
		 		loopCount = 0
		 	else:
		 		loopCount += 1
		 	

		 	#check mode
		 	if config.plugins.enigmalight.network_onoff.value:
		 		ext = "Daemon %s:%s" %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getText()))
		 	elif config.plugins.enigmalight.type.value == "WifiLight": 
		 		ext = "Local [Wifilight] %s:%s" %(str(config.plugins.enigmalight.wifilight_ip.getText()),str(config.plugins.enigmalight.wifilight_port.getText()))
		 	else:
		 		ext = "Local"
		 	

		 	

			if(self.current_mode == "0" and not self.serverstate):
				mode = _("[Server] Idle")
				self.lightsEnabled = False
			elif(self.current_mode == "0" and self.serverstate):
				mode = _("[Server] Client connected (%s)" %(self.connectedAddres))
				self.lightsEnabled = False
			elif(self.current_mode == "1"):
				mode = _("[Moodlamp] %s | Static color" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "2"):
				mode = _("[Dynamic] %s | %s") %(ext,self.current_resolution)
				self.lightsEnabled = True
			elif(self.current_mode == "3"):
				mode = _("[Moodlamp] %s | RGBtest" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "4"):
				mode = _("[Moodlamp] %s | ColorFader" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "5"):
				mode = _("[Moodlamp] %s | Rainbow" %(ext))
				self.lightsEnabled = True
			else:
				mode = "Off"
				self.lightsEnabled = False
			

			if self.currentScreen != None and self.mainScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.showButtons)

			#Set StatusBar text
			if not self.lightsEnabled and not self.sockClass.connected:
				status = _("Not Running")
				mode   = "Off"
			elif self.lightsEnabled and self.sockClass.connected:
				status = _("LightsOn")
			elif not self.lightsEnabled and self.sockClass.connected:
				status = _("LightsOff")
			

			#Statusbar
			if self.currentScreen != None:
				stContent = _("Status: %s | Current mode: %s | FPS: %s") %(status,mode,self.current_fps)
				try:
					#self.currentScreen.handleFromThread("setStatusBarTxt",stContent)
					self.currentScreen.handleFromThread(self.currentScreen.setStatusBarTxt,stContent)
				except:
					from traceback import format_exc
					log("",self,"Error: "+format_exc())
					try:
						open(getCrashFilePath(),"w").write(format_exc())
						if config.plugins.enigmalight.message_error_onoff.value:
							showError(self.session, (format_exc()), "E")
					except:
						pass

				#clear info
				if self.clearStatusInfo != None and self.clearStatusInfo == loopCount:
					try:
						#self.currentScreen.handleFromThread("setStatusBarInfo","")
						self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,"")
						#clear info
						self.clearStatusInfo = None
					except:
						from traceback import format_exc
						log("",self,"Error: "+format_exc())
						try:
							open(getCrashFilePath(),"w").write(format_exc())
							if config.plugins.enigmalight.message_error_onoff.value:
								showError(self.session, (format_exc()), "E")
						except:
							pass

			time.sleep(0.5)

		log("ControlThread: exit...")
		self.thread_running = False
Example #26
0
	def changeValue(self, currentoption):
		log("",self)
		color = None
		value = str(currentoption.getValue())
		text  = str(currentoption.getText())
		
		self.setStatusBarInfo("changeValue")

		try:

			if self.lightsEnabled == True:
				if currentoption == config.plugins.enigmalight.mode:
					if text == _("Moodlamp"):
						if self.current_mode == "2" or self.current_mode != None:
							self.writeMoodlamp()

					elif text == _("Dynamic") and self.current_mode != "2":
						self.writeDynamic()

				elif currentoption == config.plugins.enigmalight.moodlamp_mode:  #Change mode only when mode is set to moodlamp
					if self.current_mode != "2" and self.current_mode != None:				
						self.writeMoodlamp()

				#elif currentoption == config.plugins.enigmalight.presets: #send all setting
				#	self.sendAll()
					
				elif currentoption == config.plugins.enigmalight.moodlamp_static_color_r or currentoption == config.plugins.enigmalight.moodlamp_static_color_g or currentoption == config.plugins.enigmalight.moodlamp_static_color_b or currentoption == config.plugins.enigmalight.moodlamp_fader_brightness or currentoption == config.plugins.enigmalight.adjustr or currentoption == config.plugins.enigmalight.adjustg or currentoption == config.plugins.enigmalight.adjustb or currentoption == config.plugins.enigmalight.use_live_adjust:
					
					data = self.writeAdjust()
					
					#data +="set color_sequence " + str(config.plugins.enigmalight.color_sequence.getValue()) + "\n"

					if self.current_mode != "2" and self.current_mode != None:
						color = self.getColor()
											
						data +="set static_color " + str(color) + "\n"
						data +="set moodlamp_brightness" + str(config.plugins.enigmalight.moodlamp_fader_brightness.getValue()) + "\n"

					self.sockClass.setCommand(data)					

				elif currentoption == config.plugins.enigmalight.saturation:
					data ="set saturation "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.saturationmin:
					data ="set saturationmin "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.saturationmax:
					data ="set saturationmax "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.value:
					data ="set value "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.valuemin:
					data ="set valuemin "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.valuemax:
					data ="set valuemax "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.speed:
					data ="set speed "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.delay:
					data ="set delay "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.autospeed:
					data ="set autospeed "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.interval:
					data ="set interval "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.gamma:
					data ="set gamma "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.m_3dmode:
					data ="set 3dmode "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.interpolation:
					data ="set saturation "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.blackbar_h:
					data ="set blackbar_h "+ str(value) + "\n"
					data +="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.blackbar_v:
					data ="set blackbar_v "+ str(value) + "\n"
					data +="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)					
				elif currentoption == config.plugins.enigmalight.blackbar_f:
					data ="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.threshold:
					data ="set threshold "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.cluster:
					data ="set cluster "+ str(value) + "\n"
					self.sockClass.setCommand(data)

		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
Example #27
0
	def DoControl(self, result, retval, extra_args = None):
		log("",self)
		(checkResult, control, callback) = extra_args
		ret = 0
		error = False

		commandResult = str(result)

		if checkResult:
			#sleep one sec before do next step.
			time.sleep(1)
			if commandResult.find("ERROR:") != -1:
				self.showResult(str(result))
				error = True

		if error is False:
			try:
			
				if control['value'] == "stop":
					
					self.setStatusBarInfo(_("Stop lights.."))

					if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
						#Switch to server
						log("",self,"config.plugins.enigmalight.server.value is true, Start server")
						data = "set mode 0\n"
						ret = self.sockClass.setCommand(data)

					else:
						#kill enigmalight
						data = "set mode stop\n"
						self.sockClass.setCommand(data)
					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights disabled."),"I")
				
				elif control['value'] == "dynamic":

					self.setStatusBarInfo(_("Start lights.."))

					ret = self.controlMode()		

					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled."),"I")

				elif control['value'] == "configtest":

					self.setStatusBarInfo(_("Change mode"))

					data = "set mode 3\n"
					ret = self.sockClass.setCommand(data) #3 test

					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled, mode[test]"),"I")

				elif control['value'] == "server":

					self.setStatusBarInfo(_("Change mode"))

					data = "set mode 0\n"
					ret = self.sockClass.setCommand(data)

				elif control['value'] == "moodlamp":

					self.setStatusBarInfo(_("Change mode"))

					ret = self.writeMoodlamp()
					
					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled, mode[%s]") %(str(config.plugins.enigmalight.moodlamp_mode.getText())),"I")
						
				elif control['value'] == "sleep":
					
					if config.plugins.enigmalight.standbymode.value == str(1):
						#Start Moodlamp
						ret = self.writeMoodlamp()

					elif config.plugins.enigmalight.standbymode.value == str(0):

						if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
							#Switch to server
							log("",self,"config.plugins.enigmalight.server.value is true, Start server")
							data = "set mode 0\n"
							ret = self.sockClass.setCommand(data)
						else:
							#disable lights
							data = "set mode stop\n"
							ret = self.sockClass.setCommand(data)


				elif control['value'] == "wakeup":
					ret = self.controlMode()


				if self.currentScreen != None and self.mainScreen != None:
					self.currentScreen.handleFromThread(self.currentScreen.showButtons)


				#Send all values
				if ret == 1:
					if control['value'] == "dynamic" or control['value'] == "restart" or control['value'] == "wakeup":
						self.sendAll(True)

				if control['value'] != "stop" and control['value'] != "sleep":
					self.writeSettings()

				return ret

			except:
				from traceback import format_exc
				log("",self,"Error: "+format_exc())
				try:
					open(getCrashFilePath(),"w").write(format_exc())
					if config.plugins.enigmalight.message_error_onoff.value:
						showError(self.session, (format_exc()), "E")
				except:
					pass
Example #28
0
    def DoControl(self, result, retval, extra_args=None):
        log("", self)
        (checkResult, control, callback) = extra_args
        ret = 0
        error = False

        commandResult = str(result)

        if checkResult:
            #sleep one sec before do next step.
            time.sleep(1)
            if commandResult.find("ERROR:") != -1:
                self.showResult(str(result))
                error = True

        if error is False:
            try:

                if control['value'] == "stop":

                    self.setStatusBarInfo(_("Stop lights.."))

                    if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
                        #Switch to server
                        log(
                            "", self,
                            "config.plugins.enigmalight.server.value is true, Start server"
                        )
                        data = "set mode 0\n"
                        ret = self.sockClass.setCommand(data)

                    else:
                        #kill enigmalight
                        data = "set mode stop\n"
                        self.sockClass.setCommand(data)
                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights disabled."), "I")

                elif control['value'] == "dynamic":

                    self.setStatusBarInfo(_("Start lights.."))

                    ret = self.controlMode()

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights enabled."), "I")

                elif control['value'] == "configtest":

                    self.setStatusBarInfo(_("Change mode"))

                    data = "set mode 3\n"
                    ret = self.sockClass.setCommand(data)  #3 test

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights enabled, mode[test]"),
                                    "I")

                elif control['value'] == "server":

                    self.setStatusBarInfo(_("Change mode"))

                    data = "set mode 0\n"
                    ret = self.sockClass.setCommand(data)

                elif control['value'] == "moodlamp":

                    self.setStatusBarInfo(_("Change mode"))

                    ret = self.writeMoodlamp()

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(
                            self.session,
                            _("Control: Lights enabled, mode[%s]") %
                            (str(config.plugins.enigmalight.moodlamp_mode.
                                 getText())), "I")

                elif control['value'] == "sleep":

                    if config.plugins.enigmalight.standbymode.value == str(1):
                        #Start Moodlamp
                        ret = self.writeMoodlamp()

                    elif config.plugins.enigmalight.standbymode.value == str(
                            0):

                        if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
                            #Switch to server
                            log(
                                "", self,
                                "config.plugins.enigmalight.server.value is true, Start server"
                            )
                            data = "set mode 0\n"
                            ret = self.sockClass.setCommand(data)
                        else:
                            #disable lights
                            data = "set mode stop\n"
                            ret = self.sockClass.setCommand(data)

                elif control['value'] == "wakeup":
                    ret = self.controlMode()

                if self.currentScreen != None and self.mainScreen != None:
                    self.currentScreen.handleFromThread(
                        self.currentScreen.showButtons)

                #Send all values
                if ret == 1:
                    if control['value'] == "dynamic" or control[
                            'value'] == "restart" or control[
                                'value'] == "wakeup":
                        self.sendAll(True)

                if control['value'] != "stop" and control['value'] != "sleep":
                    self.writeSettings()

                return ret

            except:
                from traceback import format_exc
                log("", self, "Error: " + format_exc())
                try:
                    open(getCrashFilePath(), "w").write(format_exc())
                    if config.plugins.enigmalight.message_error_onoff.value:
                        showError(self.session, (format_exc()), "E")
                except:
                    pass
Example #29
0
    def run(self):
        log("", self, "ControlThread: Running...")

        checkLoop = 4  # check every 2 sec for cpu usage
        loopCount = 0

        while (self.thread_running):

            #Check connection
            self.sockClass.checkConnection()

            #if not connected then connect with it.
            if self.sockClass.connectedWithEnigmalight():
                self.readInfo()  #get runninginfo
            else:
                self.lightsEnabled = False
                self.current_fps = "0"
                self.current_resolution = "0x0"
                self.current_mode = "Off"
                self.current_cpu = "0"

            #when checkloop is 2 then getcpu

            if (loopCount == checkLoop):
                #self.getCpu()
                loopCount = 0
            else:
                loopCount += 1

        #check mode
            if config.plugins.enigmalight.network_onoff.value:
                ext = "Daemon %s:%s" % (
                    str(config.plugins.enigmalight.address.getText()),
                    str(config.plugins.enigmalight.port.getText()))
            elif config.plugins.enigmalight.type.value == "WifiLight":
                ext = "Local [Wifilight] %s:%s" % (
                    str(config.plugins.enigmalight.wifilight_ip.getText()),
                    str(config.plugins.enigmalight.wifilight_port.getText()))
            else:
                ext = "Local"

            if (self.current_mode == "0" and not self.serverstate):
                mode = _("[Server] Idle")
                self.lightsEnabled = False
            elif (self.current_mode == "0" and self.serverstate):
                mode = _("[Server] Client connected (%s)" %
                         (self.connectedAddres))
                self.lightsEnabled = False
            elif (self.current_mode == "1"):
                mode = _("[Moodlamp] %s | Static color" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "2"):
                mode = _("[Dynamic] %s | %s") % (ext, self.current_resolution)
                self.lightsEnabled = True
            elif (self.current_mode == "3"):
                mode = _("[Moodlamp] %s | RGBtest" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "4"):
                mode = _("[Moodlamp] %s | ColorFader" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "5"):
                mode = _("[Moodlamp] %s | Rainbow" % (ext))
                self.lightsEnabled = True
            else:
                mode = "Off"
                self.lightsEnabled = False

            if self.currentScreen != None and self.mainScreen != None:
                self.currentScreen.handleFromThread(
                    self.currentScreen.showButtons)

            #Set StatusBar text
            if not self.lightsEnabled and not self.sockClass.connected:
                status = _("Not Running")
                mode = "Off"
            elif self.lightsEnabled and self.sockClass.connected:
                status = _("LightsOn")
            elif not self.lightsEnabled and self.sockClass.connected:
                status = _("LightsOff")

            #Statusbar
            if self.currentScreen != None:
                stContent = _("Status: %s | Current mode: %s | FPS: %s") % (
                    status, mode, self.current_fps)
                try:
                    #self.currentScreen.handleFromThread("setStatusBarTxt",stContent)
                    self.currentScreen.handleFromThread(
                        self.currentScreen.setStatusBarTxt, stContent)
                except:
                    from traceback import format_exc
                    log("", self, "Error: " + format_exc())
                    try:
                        open(getCrashFilePath(), "w").write(format_exc())
                        if config.plugins.enigmalight.message_error_onoff.value:
                            showError(self.session, (format_exc()), "E")
                    except:
                        pass

                #clear info
                if self.clearStatusInfo != None and self.clearStatusInfo == loopCount:
                    try:
                        #self.currentScreen.handleFromThread("setStatusBarInfo","")
                        self.currentScreen.handleFromThread(
                            self.currentScreen.setStatusBarInfo, "")
                        #clear info
                        self.clearStatusInfo = None
                    except:
                        from traceback import format_exc
                        log("", self, "Error: " + format_exc())
                        try:
                            open(getCrashFilePath(), "w").write(format_exc())
                            if config.plugins.enigmalight.message_error_onoff.value:
                                showError(self.session, (format_exc()), "E")
                        except:
                            pass

            time.sleep(0.5)

        log("ControlThread: exit...")
        self.thread_running = False
Example #30
0
	def __init__(self, session):
		try:
			Screen.__init__(self, session)
			
			self.cfglist = []
			ConfigListScreen.__init__(self, self.cfglist, session, on_change = self.changedEntry)
			self._session = session
			
			self.controller = None

			#globals
			self.createfile = False		
			self.controller = None
			self.devicepath = None

			self.begin 		= None
			self.floor 		= None
			self.seqq  		= None
			self.leds_top 	= None
			self.leds_right = None
			self.leds_left 	= None
			self.leds_bottom = None
			self.leds_bottom_left = None
			self.leds_bottom_right = None
			self.leds_bottom_center = None
			self.channels 	= None
			self.total		= None
			self.current 	= None
			self.selected 	= None

			self["infoblock"] 		= Label()
			self["btn_greenText"] 	= Label()
			self["btn_yellowText"] 	= Label()

			self["btn_yellow"] 		= Pixmap()
			self["btn_green"] 		= Pixmap()
			self["pic_leftb"] 		= Pixmap()
			self["pic_leftt"] 		= Pixmap()
			self["pic_topl"] 		= Pixmap()
			self["pic_topr"] 		= Pixmap()
			self["pic_rightt"] 		= Pixmap()
			self["pic_rightb"] 		= Pixmap()
			self["pic_botr"] 		= Pixmap()
			self["pic_botml"] 		= Pixmap()
			self["pic_botmr"] 		= Pixmap()
			self["pic_botl"]		= Pixmap()   
			self["pic_floor"] 		= Pixmap()

			self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
			{
				"cancel":	self.keyCancel,
				"green":	self.keyGreen,
				"yellow":	self.keyYellow,
				"ok":		self.keyOk,
			}, -2)
			
			self.onLayoutFinish.append(self.finishLayout)
		except:
			from traceback import format_exc
			log("",self,"Error:" + format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
			except:
				pass
Example #31
0
    def changeValue(self, currentoption):
        log("", self)
        color = None
        value = str(currentoption.getValue())
        text = str(currentoption.getText())

        self.setStatusBarInfo("changeValue")

        try:

            if self.lightsEnabled == True:
                if currentoption == config.plugins.enigmalight.mode:
                    if text == _("Moodlamp"):
                        if self.current_mode == "2" or self.current_mode != None:
                            self.writeMoodlamp()

                    elif text == _("Dynamic") and self.current_mode != "2":
                        self.writeDynamic()

                elif currentoption == config.plugins.enigmalight.moodlamp_mode:  #Change mode only when mode is set to moodlamp
                    if self.current_mode != "2" and self.current_mode != None:
                        self.writeMoodlamp()

                #elif currentoption == config.plugins.enigmalight.presets: #send all setting
                #	self.sendAll()

                elif currentoption == config.plugins.enigmalight.moodlamp_static_color_r or currentoption == config.plugins.enigmalight.moodlamp_static_color_g or currentoption == config.plugins.enigmalight.moodlamp_static_color_b or currentoption == config.plugins.enigmalight.moodlamp_fader_brightness or currentoption == config.plugins.enigmalight.adjustr or currentoption == config.plugins.enigmalight.adjustg or currentoption == config.plugins.enigmalight.adjustb or currentoption == config.plugins.enigmalight.use_live_adjust:

                    data = self.writeAdjust()

                    #data +="set color_sequence " + str(config.plugins.enigmalight.color_sequence.getValue()) + "\n"

                    if self.current_mode != "2" and self.current_mode != None:
                        color = self.getColor()

                        data += "set static_color " + str(color) + "\n"
                        data += "set moodlamp_brightness" + str(
                            config.plugins.enigmalight.
                            moodlamp_fader_brightness.getValue()) + "\n"

                    self.sockClass.setCommand(data)

                elif currentoption == config.plugins.enigmalight.saturation:
                    data = "set saturation " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.saturationmin:
                    data = "set saturationmin " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.saturationmax:
                    data = "set saturationmax " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.value:
                    data = "set value " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.valuemin:
                    data = "set valuemin " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.valuemax:
                    data = "set valuemax " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.speed:
                    data = "set speed " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.delay:
                    data = "set delay " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.autospeed:
                    data = "set autospeed " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.interval:
                    data = "set interval " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.gamma:
                    data = "set gamma " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.m_3dmode:
                    data = "set 3dmode " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.interpolation:
                    data = "set saturation " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_h:
                    data = "set blackbar_h " + str(value) + "\n"
                    data += "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_v:
                    data = "set blackbar_v " + str(value) + "\n"
                    data += "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_f:
                    data = "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.threshold:
                    data = "set threshold " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.cluster:
                    data = "set cluster " + str(value) + "\n"
                    self.sockClass.setCommand(data)

        except:
            from traceback import format_exc
            log("", self, "Error: " + format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
                if config.plugins.enigmalight.message_error_onoff.value:
                    showError(self.session, (format_exc()), "E")
            except:
                pass
Example #32
0
    def __init__(self, session, allowOveride=True):

        try:
            log("", self, "Menu Opened succesfull..")

            #check if enigmalight is pointed to good OE Version, if not then make the link
            checkSymbolic()

            Screen.__init__(self, session)
            self.session = session

            #Set screen
            self.currentScreen = self

            #Set controller and session
            self.controller = CONTROLLER_INSTANCE
            self.controller.setSession(self.session)
            self.controller.setMainScreen(True)

            #Timer class
            self.timer_class = TIMER_INSTANCE
            TIMER_INSTANCE.setController(CONTROLLER_INSTANCE)

            #Set horizontal menu items
            self.setHorMenuElements(depth=2)
            self.translateNames()

            # Menu
            self["menu"] = List(enableWrapAround=True)

            # Buttons
            self["txt_green"] = Label()
            self["btn_green"] = Pixmap()
            self["txt_red"] = Label()
            self["btn_red"] = Pixmap()
            self["txt_blue"] = Label()
            self["btn_blue"] = Pixmap()
            self["txt_yellow"] = Label()
            self["btn_yellow"] = Pixmap()
            self["txt_check"] = Label()

            self["statusbar"] = Pixmap()
            self["txt_statusbar"] = Label()
            self["txt_statusbar_info"] = Label()

            self["actions"] = HelpableActionMap(
                self, "EL_MainMenuActions", {
                    "ok": (self.okbuttonClick, ""),
                    "left": (self.left, ""),
                    "right": (self.right, ""),
                    "up": (self.up, ""),
                    "down": (self.down, ""),
                    "cancel": (self.cancel, ""),
                    "green": (self.keyGreen, ""),
                    "red": (self.keyRed, ""),
                    "blue": (self.keyBlue, ""),
                    "yellow": (self.keyYellow, ""),
                    "key_0": (self.key0, ""),
                }, -2)

            self.onLayoutFinish.append(self.finishLayout)

        except:
            from traceback import format_exc
            log("Error:", format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
            except:
                pass
Example #33
0
    def __init__(self, session):
        try:
            log("", self)
            Screen.__init__(self, session)
            HelpableScreen.__init__(self)

            self.cfglist = []
            ConfigListScreen.__init__(self,
                                      self.cfglist,
                                      session,
                                      on_change=self._changed)

            self._session = session
            self._hasChanged = False

            self.controller = None
            self.selected = None

            self.aspect = getAspect()
            self.old_service = self.session.nav.getCurrentlyPlayingServiceReference(
            )

            # Disable OSD Transparency
            try:
                self.can_osd_alpha = open("/proc/stb/video/alpha",
                                          "r") and True or False
            except:
                self.can_osd_alpha = False

            if config.plugins.enigmalight.sampleBackground.getValue() == True:
                self.showBackground()

            self["txt_green"] = Label()
            self["btn_green"] = Pixmap()

            self["statusbar"] = Pixmap()
            self["txt_statusbar"] = Label()
            self["txt_statusbar_info"] = Label()

            self["help"] = StaticText()

            self["setupActions"] = ActionMap(
                ["SetupActions", "ColorActions", "EL_Settings"], {
                    "green": self.keySave,
                    "red": self.keyCancel,
                    "cancel": self.keyCancel,
                    "ok": self.ok,
                    "left": self.keyLeft,
                    "right": self.keyRight,
                    "bouquet_up": self.keyBouquetUp,
                    "bouquet_down": self.keyBouquetDown,
                    "jumpNextMark": self.keyNext,
                    "jumpPreviousMark": self.keyPrev,
                }, -2)

            self["txt_green"].setText(_("Save"))

            self.createSetup()

            self.onLayoutFinish.append(self.finishLayout)

        except:
            from traceback import format_exc
            log("", self, "Error:" + format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
            except:
                pass
Example #34
0
	def BuildConfig(self,message):

		#print("[Boblight] BuildConfig() ...")
		
		#
		# Set default values
		#
		
		if self.createfile:
			postfix		 = ""
			type			= ""
			blacklevel	  = str(config.plugins.enigmalight.blacklevel.value[0])+"."+str(config.plugins.enigmalight.blacklevel.value[1])
			interval		= "interval  	20000\n"
			delayafteropen  = ""
			
		#
		# Set sections and depth
		#
		
		leds_bottom	 = config.plugins.enigmalight.lights_bottom.value
		leds_top	 = config.plugins.enigmalight.lights_top.value
		leds_left	 = config.plugins.enigmalight.lights_left.value
		leds_right	 = config.plugins.enigmalight.lights_right.value
		scanl		 = config.plugins.enigmalight.scanl.value
		scanr		 = config.plugins.enigmalight.scanr.value
		scant		 = config.plugins.enigmalight.scant.value
		scanb		 = config.plugins.enigmalight.scanb.value
		
		#
		# Bottom values, for tv's with floorstand.
		#
		
		leds_bottom_center = config.plugins.enigmalight.lights_bottom_center.value
		leds_bottom_left   = config.plugins.enigmalight.lights_bottom_left.value
		leds_bottom_right  = config.plugins.enigmalight.lights_bottom_right.value
		leds_bottom_total  = (leds_bottom_left + leds_bottom_right + leds_bottom_center)
		
		#
		# Total channels
		#
		
		channels		= (leds_top + leds_left + leds_right + leds_bottom)*3

		#
		# Floorstand calculation
		#
		
		if config.plugins.enigmalight.floorstand.value == str(2):
			#print("[Boblight] Clockwise")
			#print("[Boblight] Set floorstand to true")
			
			channels	= (leds_top + leds_left + leds_right + leds_bottom_total - leds_bottom_center)*3
			#print("[Boblight] Channels: "+str(channels))
			
			# total step
			hScanStep	= 100 / leds_bottom_total;			 # 100 / 20 lights = 5
			hScan_center = (hScanStep*leds_bottom_center)	   # total center hscan // floorstand //  emptyplaces*hScanStep = ... 50
			hScan_right  = (hScanStep*leds_bottom_right)		# total right hscan /// light rights*hScanStep = ... 25
				
			hScanCurrent = 0 + (hScan_center - hScan_right);	# 25 
				
			hScanBottom_left  = hScanCurrent;				   # = 25 is plus
			hScanBottom_right = 100							 # = 25 + 50 = 75 is min
			
			# debug
			#print("[Boblight] hScanBottom_left:"+str(hScanBottom_left)+" hScanBottom_right:"+str(hScanBottom_right))
				
			if config.plugins.enigmalight.clockwise.value == str(2):   #backwards
				#print("[Boblight] Backwards")
				#print("[Boblight] Set floorstand to true")
			
				channels	= (leds_top + leds_left + leds_right + leds_bottom_total - leds_bottom_center)*3
				#print("[Boblight] channels:"+str(channels))

				#total step
				hScanStep	= 100 / leds_bottom_total;				  # 100 / 20 lights = 5
				hScan_center = (hScanStep*leds_bottom_center)			# total center hscan // floorstand //  emptyplaces*hScanStep = ... 50
				hScan_left   = (hScanStep*leds_bottom_left)			  # total left hscan /// light left*hScanStep = ... 25
				hScan_right  = (hScanStep*leds_bottom_right)
				
				hScanCurrent = (hScan_center + hScan_left);		 # 75
					
				hScanBottom_left  = 0.0;							  # = 75
				hScanBottom_right = hScanCurrent;				   # = 75 + 50 = 25

				#print("[Boblight] hScanBottom_left:"+str(hScanBottom_left)+" hScanBottom_right:"+str(hScanBottom_right))
		
		elif self.begin == "bottom-right" or self.begin == "bottom-middle-right" or self.begin == "bottom-middle-left" or self.begin == "bottom-left":
			leds_bottom_right = leds_bottom/2;
			leds_bottom_left = leds_bottom/2;
						
			if config.plugins.enigmalight.clockwise.value == str(2):
				
				hScanStep	= 100 / leds_bottom;
				hScan_left   = (hScanStep*leds_bottom)			  # total left hscan /// light left*hScanStep = ... 25
				hScan_right  = (hScanStep*leds_bottom)
				
				hScanCurrent = (hScan_left);		 # 75
					
				hScanBottom_left  = 0.0;							  # = 75
				hScanBottom_right = hScanCurrent;				   # = 75 + 50 = 25
			elif config.plugins.enigmalight.clockwise.value == str(1):
				hScanStep	= 100 / leds_bottom;
				hScan_left   = (hScanStep*leds_bottom)			  # total left hscan /// light left*hScanStep = ... 25
				hScan_right  = (hScanStep*leds_bottom)
				
				hScanCurrent = (hScan_right);		 # 75
					
				hScanBottom_left  = hScanCurrent;							  # = 75
				hScanBottom_right = 100.0;				   # = 75 + 50 = 25
		#
		# Atmolight need 4 channels more.
		#
		
		if config.plugins.enigmalight.type.value == "Atmolight":
			channels += 4
		
						  
		total_lights = channels / 3;
		
		if self.createfile:
			#
			# Set some vars
			#
			
			colorr = ""
			colorg = ""
			colorb = ""
			
			if config.plugins.enigmalight.color_order.value == "1":
				colorr = "0000FF"
				colorg = "00FF00"
				colorb = "FF0000"
			if config.plugins.enigmalight.color_order.value == "0":
				colorr = "FF0000"
				colorg = "00FF00"
				colorb = "0000FF"
			if config.plugins.enigmalight.color_order.value == "2":
				colorr = "00FF00"
				colorg = "0000FF"
				colorb = "FF0000"
			
			#
			# Set prefix, type and interval
			#
			
			if config.plugins.enigmalight.type.value == "Lightpack":
				type	= "lightpack\n"
				interval= "interval  	20000\n"
				prefix  = "\n"
			if config.plugins.enigmalight.type.value == "Oktolight":
				type	= "karate\n"
				interval= "interval  	16000\n"
				prefix  = "\n"
			if config.plugins.enigmalight.type.value == "Karatelight":
				type	= "karate\n"
				interval= "interval  	16000\n"
				prefix  = "\n"
			if config.plugins.enigmalight.type.value == "Atmolight":
				type	= "atmo\n"
				prefix  = "prefix		FF\n"
				interval= "interval  	16000\n"
				prefix  = "\n"
			if config.plugins.enigmalight.type.value == "Adalight/Momo":
				type	= "momo\n"
				interval= "interval  	20000\n"
				#delayafteropen = "delayafteropen  1000000\n"
				prefix  = "\n"		
				
				#
				# Prefix calculation [This only works for arduino boards]
				#
				
				os.system("/home/elight-addons/prefix "+str(total_lights)+" > /tmp/prefix.txt")
		
				fo = open("/tmp/prefix.txt", "r")
				reading = fo.read(1000)
				fo.close()
				
				# remove tmpfile
				os.system("rm /tmp/prefix.txt")
		
				reading = reading.split("LEDS:  ")
				prefix = "prefix		"+str(reading[1]);	
				#print("[Boblight] Reading prefixfile for "+str(total_lights)+" leds: "+prefix)
			
			if config.plugins.enigmalight.type.value == "iBelight":
				type	= "ibelight\n"
				interval= "interval  	20000\n"
				prefix  = "\n"
			if config.plugins.enigmalight.type.value == "Sedulight 5A A0 A5":
				prefix  = "prefix		5A A0\n"
				postfix = "postfix		A5\n"
				type	= "momo\n"
				interval= "interval		10000\n"
				delayafteropen = "delayafteropen		1000000\n"
			if config.plugins.enigmalight.type.value == "Sedulight 5A A1 A5":
				prefix  = "prefix		5A A1\n"
				postfix = "postfix		A5\n"
				type	= "momo\n"
				interval= "interval		10000\n"
				delayafteropen = "delayafteropen		1000000\n"
			if config.plugins.enigmalight.type.value == "Sedulight 5A A2 A5":
				prefix  = "prefix		5A A2\n"
				postfix = "postfix		A5\n"
				type	= "momo\n"
				interval= "interval		10000\n"
				delayafteropen = "delayafteropen		1000000\n"
			if config.plugins.enigmalight.type.value == "Sedulight 5A B0 A5":
				prefix  = "prefix		5A B0\n"
				postfix = "postfix		A5\n"
				type	= "momo\n"
				interval= "interval		10000\n"
				delayafteropen = "delayafteropen		1000000\n"
				channels = "768"


			#
			# set the name			
			#
			
			name = "ambilight"			
	
		#
		# Create file
		#
		
		if self.createfile:

			fo = None

			fo = open("/tmp/enigmalight.conf.new", "wb")

			fo.write("[global]\n")
			fo.write("interface	127.0.0.1\n")
			fo.write("port		19333\n")
			fo.write("\n")
			
			fo.write("[device]\n")

			if config.plugins.enigmalight.type.value == "WifiLight":
				name = "wifilight"
				fo.write("name		"+name+"\n")

				fo.write("output		python  /home/elight-addons/wifilight/wifilight.py\n")
				fo.write("type		popen\n")
				fo.write("interval	100000\n")
				fo.write("channels	3\n")
			else:
				fo.write("name		"+name+"\n")
				fo.write("output		"+config.plugins.enigmalight.output.value+"\n")
				fo.write("type		"+type)
				fo.write(interval)
				fo.write(prefix)
				fo.write(postfix)
				fo.write("channels	"+str(channels)+"\n")
			
			if config.plugins.enigmalight.type.value != "iBelight" and config.plugins.enigmalight.type.value != "Lightpack":
				fo.write("rate		"+str(config.plugins.enigmalight.rate.value)+"\n")
			
			fo.write("debug		off\n")
			fo.write(delayafteropen)
			fo.write("\n")
			
			fo.write("[color]\n")
			fo.write("name		red\n")
			fo.write("rgb		"+colorr+"\n")		
			fo.write("gamma		"+str(config.plugins.enigmalight.config_r_gamma.value[0])+"."+str(config.plugins.enigmalight.config_r_gamma.value[1])+"\n")
			fo.write("adjust		"+str(config.plugins.enigmalight.config_r_adjust.value[0])+"."+str(config.plugins.enigmalight.config_r_adjust.value[1])+"\n")
			fo.write("blacklevel	"+str(config.plugins.enigmalight.config_r_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_r_blacklevel.value[1])+"\n")
			fo.write("\n")
			
			fo.write("[color]\n")
			fo.write("name		green\n")
			fo.write("rgb		"+colorg+"\n")
			fo.write("gamma		"+str(config.plugins.enigmalight.config_g_gamma.value[0])+"."+str(config.plugins.enigmalight.config_g_gamma.value[1])+"\n")
			fo.write("adjust		"+str(config.plugins.enigmalight.config_g_adjust.value[0])+"."+str(config.plugins.enigmalight.config_g_adjust.value[1])+"\n")
			fo.write("blacklevel	"+str(config.plugins.enigmalight.config_g_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_b_blacklevel.value[1])+"\n")
			fo.write("\n")
			
			fo.write("[color]\n")
			fo.write("name		blue\n")
			fo.write("rgb		"+colorb+"\n")
			fo.write("gamma		"+str(config.plugins.enigmalight.config_b_gamma.value[0])+"."+str(config.plugins.enigmalight.config_b_gamma.value[1])+"\n")
			fo.write("adjust		"+str(config.plugins.enigmalight.config_b_adjust.value[0])+"."+str(config.plugins.enigmalight.config_b_adjust.value[1])+"\n")
			fo.write("blacklevel	"+str(config.plugins.enigmalight.config_b_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_b_blacklevel.value[1])+"\n")
			fo.write("\n")
		
		#
		# begin to create lights section
		#

		# Set lightCount to 1
		lightCount   = 1
		channelCount = 1
		
		# Atmolight need to start @ 4
		if config.plugins.enigmalight.type.value == "Atmolight":
			channelCount = 4
		
		# Set v and h to 0
		vScanCurrent = 0
		hScanCurrent = 0
		
		#
		# Set the section order
		#
		
		if self.begin == "left-bottom" or self.begin == "left-top":
			if config.plugins.enigmalight.clockwise.value == str(1):
				order = "left,top,right,bottom" # Clockwise
			else:
				order = "left,bottom,right,top" # Backwards
				
			if config.plugins.enigmalight.floorstand.value == str(2):
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "left,top,right,bottom-right,bottom-center,bottom-left" # Clockwise
				else:
					order = "left,bottom-left,bottom-center,bottom-right,right,top" # Backwards
		
		if self.begin == "top-left" or self.begin == "top-right":
			if config.plugins.enigmalight.clockwise.value == str(1):
				order = "top,right,bottom,left" # Clockwise
			else:
				order = "top,left,bottom,right" # Backwards
				
			if config.plugins.enigmalight.floorstand.value == str(2):
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "top,right,bottom-right,bottom-center,bottom-left,left" # Clockwise
				else:
					order = "top,left,bottom-left,bottom-center,bottom-right,right" # Backwards
		 
		if self.begin == "right-top" or self.begin == "right-bottom":
			if config.plugins.enigmalight.clockwise.value == str(1):
				order = "right,bottom,left,top" # Clockwise
			else:
				order = "right,top,left,bottom" # Backwards
			
			if config.plugins.enigmalight.floorstand.value == str(2):
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "right,bottom-right,bottom-center,bottom-left,left,top" # Clockwise
				else:
					order = "right,top,left,bottom-left,bottom-center,bottom-right" # Backwards
		 
		if self.begin == "bottom-right" or self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right" or self.begin == "bottom-left":
			
			if self.begin == "bottom-middle-left":
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "bottom-left,left,top,right,bottom-right" # Clockwise
				else:
					order = "bottom-right,right,top,left,bottom-left" # Backwards
			else:
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "bottom,left,top,right" # Clockwise
				else:
					order = "bottom,right,top,left" # Backwards
						
			if config.plugins.enigmalight.floorstand.value == str(2):
				if config.plugins.enigmalight.clockwise.value == str(1):
					order = "bottom-center,bottom-left,left,top,right,bottom-right" # Clockwise
				else:
					order = "bottom-center,bottom-right,right,top,left,bottom-left" # Backwards

		
		# Split the orderarray	   
		order = order.split(",")
		
		# Debug
		#print("[Boblight] order   = "+str(order))
		#print("[Boblight] begincount = "+config.plugins.enigmalight.begincount.value)

		# 100 0 100 0 0 100 0 100 clockwards
		# 0 100 100 0 100 0 0 100 backwards

		#
		# order loop
		#
		
		totalCount = 1
		for section in order:

			if section == "left":
				lights = leds_left
				vScanCurrent = 100.00 # From LEFT-bottom to LEFT-top	   # Clockwise
				if config.plugins.enigmalight.clockwise.value == str(2): 
					vScanCurrent = 0.00 # From LEFT-top to LEFT-bottom	 # Backwards
				
			if section == "top":
				lights = leds_top
				hScanCurrent = 0.00 # From TOP-left to TOP-right		   # Clockwise
				if config.plugins.enigmalight.clockwise.value == str(2): 
					hScanCurrent = 100.00 # From TOP-right to TOP-left	 # Backwards

			if section == "right":
				lights = leds_right
				vScanCurrent = 0.00 # From RIGHT-top to RIGHT-bottom	   # Clockwise
				if config.plugins.enigmalight.clockwise.value == str(2): 
					vScanCurrent = 100.00 # From RIGHT-bottom to RIGHT-top # Backwards

			if section == "bottom":
				lights = leds_bottom
				hScanCurrent = 100.00 # From BOTTOM-right to BOTTOM-left   # Clockwise
				if config.plugins.enigmalight.clockwise.value == str(2): 
					hScanCurrent = 0.00 # From BOTTOM-left to BOTTOM-right # Backwards
			
			if section == "bottom-right":
				lights = leds_bottom_right
				hScanCurrent = float(hScanBottom_right)
				if config.plugins.enigmalight.clockwise.value == str(2): 
					hScanCurrent = float(hScanBottom_right)
					
			if section == "bottom-left":
				lights = leds_bottom_left
				hScanCurrent = float(hScanBottom_left)
				if config.plugins.enigmalight.clockwise.value == str(2): 
					hScanCurrent = float(hScanBottom_left)
			
			'''###################  Bottom Center  ####################'''
			   
			
			if self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right":
				if section == "bottom":
					lights = leds_bottom
					lights = lights/2; # we start at middle so we need to deceide it.
					hScanCurrent = 50
					
				if section == "bottom-left":
					lights = leds_bottom_left
					hScanCurrent = hScanBottom_left 
					
				if section == "bottom-right":
					lights = leds_bottom_right
					hScanCurrent = hScanBottom_right 
				
			'''########################################################'''
		
			#
			# Set start value
			#
		
			if section == "left" and self.begin   == "left-bottom":
				vScanCurrent = 100.00  # Start @ LEFT-bottom
						
			if section == "left" and self.begin   == "left-top":
				vScanCurrent = 0.00	# Start @ LEFT-top

			if section == "top" and self.begin	== "top-left":
				hScanCurrent = 0.00	# Start @ TOP-left
						
			if section == "top" and self.begin	== "top-right":
				hScanCurrent = 100.00  # Start @ TOP-right
						
			if section == "right" and self.begin  == "right-bottom":
				vScanCurrent = 100.00  # Start @ RIGHT-bottom
						
			if section == "right" and self.begin  == "right-top":
				vScanCurrent = 0.00	# Start @ RIGHT-top
					
			if section == "bottom" and self.begin == "bottom-left":
				hScanCurrent = 0.00	# Start @ BOTTOM-left
						
			if section == "bottom" and self.begin == "bottom-right":
				hScanCurrent = 100.00  # Start @ BOTTOM-right
			
			
			lightCount = 1 #lights counter
			
			# Atmolight need to start @ 4
			if config.plugins.enigmalight.type.value == "Atmolight":
				lightCount = 4
			
			# Empty places for floorstand option
			if section == "bottom-center":
				lights = 0; #Set lights to 0, we want not into loop.
		
			# Debug
			##print("[Boblight] Overlap			   :  "+str(overlap))
			#print("[Boblight] Start section		 :  "+str(section))
			#print("[Boblight] Start lights		  :  "+str(lights))
			#print("[Boblight] Start HscanCurrent	:  "+str(hScanCurrent))
			#print("[Boblight] Start VscanCurrent	:  "+str(vScanCurrent))
			
			#
			# check if section contains more then 0 lights
			#
			
			if lights > 0:
				
				# Steps
				vScanStep  = 100.00 / lights;
				hScanStep  = 100.00 / lights;
				
				# Debug
				#print("[Boblight] vScanStep  100/"+str(lights)+" :  "+str(vScanStep))
				#print("[Boblight] hScanStep  100/"+str(lights)+" :  "+str(hScanStep))
				
				# Set other step for floorstand option
				if config.plugins.enigmalight.floorstand.value == str(2):
					if section == "bottom-left" or section == "bottom-right" or section == "bottom-center":
						hScanStep  = 100.00 / leds_bottom_total; 
				elif self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right":					
					if section == "bottom-left" or section == "bottom-right":
						hScanStep  = 100.00 / leds_bottom; 
						
				# Loop
				while(lightCount <= lights):
					
					if section == "right" or section == "top":
						vScanEnd	 = vScanCurrent
						hScanEnd	 = hScanCurrent
						
						if config.plugins.enigmalight.clockwise.value == str(2): #backwards
							vScanStart   = vScanCurrent - vScanStep
							hScanStart   = hScanCurrent - hScanStep
						else:
							vScanStart   = vScanCurrent + vScanStep
							hScanStart   = hScanCurrent + hScanStep
						
						vScanCurrent = vScanStart
						hScanCurrent = hScanStart

					if section == "left" or section == "bottom" or section == "bottom-left" or section == "bottom-right":
						vScanStart   = vScanCurrent
						hScanStart   = hScanCurrent
						
						if config.plugins.enigmalight.clockwise.value == str(2): #backwards
							vScanEnd	 = vScanCurrent + vScanStep
							hScanEnd	 = hScanCurrent + hScanStep
							if section == "bottom-right" and self.begin == "bottom-middle":
								hScanEnd	 = hScanCurrent - hScanStep
						else:
							vScanEnd	 = vScanCurrent - vScanStep
							hScanEnd	 = hScanCurrent - hScanStep
						
						vScanCurrent = vScanEnd
						hScanCurrent = hScanEnd
					
					if self.createfile:
						fo.write("\n")
						fo.write("\n")
					
					
					# Light name must be 3 chars
					s = str(totalCount)
					s += "XX"
					
					length  = len(s)
					mini	= length -3
					
					if length is 4 or length > 4:
						s = s[:-mini]										
					
					if self.createfile:
						fo.write("[light]\n")
						fo.write("position	 "+str(section)+"\n")
						fo.write("name		 "+str(s)+"\n")

						fo.write("color		 red	 "+name+" "+str(channelCount)+"\n")
						channelCount += 1;

						fo.write("color		 green   "+name+" "+str(channelCount)+"\n")
						channelCount += 1;

						fo.write("color		 blue	"+name+" "+str(channelCount)+"\n")
						channelCount += 1;
					
					# Swap end and start if it's clockwise
					if config.plugins.enigmalight.clockwise.value == str(1):
						v = vScanEnd;vScanEnd = vScanStart;vScanStart = v;
						h = hScanEnd;hScanEnd = hScanStart;hScanStart = h;

					# Set hscan and vscan
					if section == "right":
						vs = abs(round(vScanStart,2))
						ve = abs(round(vScanEnd,2))
						hd = 100.00 - scanr
						if self.createfile:
							fo.write("hscan		 "+str(hd)+" 100 \n")
							fo.write("vscan		 "+str(vs)+" "+str(ve)+"\n")
						
						#step = i * (300 / config.plugins.enigmalight.lights_right.value)
						#self.c.fill(390, vs*2, 5, 5, RGB(000,000,255))
						#print "step-right %s" %(str(vs*2))	
				
						# Debug
						#print("[Boblight] vScanStart  :  "+str(vs))
						#print("[Boblight] vScanEnd	:  "+str(ve))
					
					if section == "bottom" or section == "bottom-left" or section == "bottom-right":
						hs = abs(round(hScanStart,2))
						he = abs(round(hScanEnd,2))
						vd = 100.00 - scanb
						
						if self.createfile:
							fo.write("hscan		 "+str(hs)+" "+str(he)+"\n")
							fo.write("vscan		 "+str(vd)+" 100\n")
						
						# Debug
						#print("[Boblight] hScanStart  :  "+str(hs))
						#print("[Boblight] hScanEnd	:  "+str(he))

					if section == "top":
						hs = abs(round(hScanStart,2))
						he = abs(round(hScanEnd,2))	   
						vd = scant
						
						if self.createfile:
							fo.write("hscan		 "+str(hs)+" "+str(he)+"\n")
							fo.write("vscan		 0 "+str(vd)+"\n")
						
						#self.c.fill(hs*4, 0, 5, 5, RGB(255,000,000))
						#print "step-top %s" %(str(hs*4))
						
						# Debug
						#print("[Boblight] hScanStart  :  "+str(hs))
						#print("[Boblight] hScanEnd	:  "+str(he))
					
					if section == "left":
						vs = abs(round(vScanStart,2))
						ve = abs(round(vScanEnd,2))
						hd = scanl
						
						if self.createfile:
							fo.write("hscan		 0 "+str(hd)+"\n")
							fo.write("vscan		 "+str(vs)+" "+str(ve)+"\n")
						
						#self.c.fill(0, vs*2, 5, 5, RGB(000,255,000))
						#print "step-left %s" %(str(vs*2))
						
						# Debug
						#print("[Boblight] vScanStart  :  "+str(vs))
						#print("[Boblight] vScanEnd	:  "+str(ve))
						
					lightCount  += 1; # Counter for sections
					totalCount  += 1;
			   
				# End loop
		
		#self.c.flush()

		if config.plugins.enigmalight.type.value == "WifiLight":
			try:
				fowifi = open("/home/elight-addons/wifilight/wifilight.conf", "wb")
				fowifi.write(str(config.plugins.enigmalight.wifilight_ip.getText())+"|")
				fowifi.write(str(config.plugins.enigmalight.wifilight_port.getText()))
				fowifi.close();
				
			except:
				from traceback import format_exc
				log("Error:" +format_exc(),self)
				try:
					open(getCrashFilePath(),"w").write(format_exc())
					showMessage(self._session,_("Can't write settings to /home/elight-addons/wifilight/wifilight.conf...", "W", timeout = 10))
				except:
					pass
		
		fo.close();
		
		if self.test:
			#kill enigmalight and start the test
			self.controller.killEnigmalight(None,self.doTest)	
		else:
			self.MovetoEtc(True,True)