Beispiel #1
0
	def run(self):

		'''
			The method that determines what happens when the item is clicked in the settings GUI.
			Usually this would be __addon__.OpenSettings(), but it could be any other script.
			This allows the creation of action buttons in the GUI, as well as allowing developers to script and skin their 
			own user interfaces.
		'''

		log(xbmcaddon.Addon("script.module.osmcsetting.pioverclock").getAddonInfo('id'))

		me = xbmcaddon.Addon(self.addonid)
		scriptPath = me.getAddonInfo('path')

		# read config file, take the parts you need

		# the location of the config file FOR TESTING ONLY
		try:								
			self.test_config = '/boot/config.txt'
			self.config_settings = ct.retrieve_settings_from_configtxt(self.test_config)

		except:
			self.test_config = '/home/plaskev/Documents/config.txt'
			self.config_settings = ct.retrieve_settings_from_configtxt(self.test_config)

		oc_keys = ['arm_freq', 'sdram_freq', 'core_freq', 'initial_turbo', 'over_voltage', 'over_voltage_sdram', 'force_turbo']

		self.setting_values = {}
		for key in oc_keys:
			if key in self.config_settings:
				self.setting_values[key] = self.config_settings[key]

		# setting_values = {'core_freq': 500, 'arm_freq': 800, 'sdram_freq': 700, 'initial_turbo': 60, 'over_voltage': 2, 'over_voltage_sdram': 6, 'force_turbo' : 0}

		xml = "new_gui_720.xml" if xbmcgui.Window(10000).getProperty("SkinHeight") == '720' else "new_gui.xml"

		self.GUI = overclock_gui(xml, scriptPath, 'Default', setting_values=self.setting_values, model=self.pimodel)

		self.GUI.doModal()

		self.new_settings = self.GUI.snapshot()
		log('self.new_settings')
		log(self.new_settings)
		log('self.setting_values')
		log(self.setting_values)

		ct.apply_changes_to_configtxt(self.new_settings, self.test_config)

		del self.GUI

		for k, s in self.new_settings.iteritems():
			if s != self.setting_values.get(k, 'no setting available'):
				self.reboot_required

		# dialog to notify the user they should restart for changes to take effect
		ok = DIALOG.notification(lang(32107), lang(32108))

		log('END')
Beispiel #2
0
	def populate_pi_settings_dict(self):

		'''
			Populates the setting_value in the pi_settings_dict.
		'''

		# # this is the method to use if you are populating the dict from the settings.xml
		# latest_settings = self.settings_retriever_xml()

		# but I am going to set up my own process in addition to the xml one, I will be reading some
		# settings from the config.txt, and getting the rest from the settings.xml
		self.config_settings = ct.retrieve_settings_from_configtxt(self.test_config)

		log('Config settings received from the parser: %s' % self.config_settings)

		# cycle through the pi_settings_dict dict, and populate with the settings values
		for key in self.pi_settings_dict.keys():

			# if the value of the setting is to be assigned by another setting, then just ignore it here
			# note: this will mean that the other setting will have to populate both the settings_dict and the settings.xml
			if key in self.values_set_elsewhere:
				continue

			# grab the translate method (if there is one)
			translate_method = self.pi_settings_dict.get(key,{}).get('translate',{})

			# if the key is in the config.txt
			if key in self.config_settings:

				setting_value = self.config_settings[key]

			elif key == 'config_hdmi_boost' and 'hdmi_boost' in self.config_settings:
				# this key was changed, here we will bring in the old key from the config.txt and use it to populate the UI

				setting_value = self.config_settings['hdmi_boost']

			else:
				# if the key ISNT in the config.txt then set the value from the default stored in 
				# the pi_settings_dict dict

				setting_value = self.pi_settings_dict[key].get('default','')

			# get the setting value, translate it if needed
			if translate_method:
				try:
					setting_value = translate_method(setting_value)
				except:
					log('Setting translation failed for %s, using default value' % key)
					log(traceback.format_exc())
					setting_value = self.pi_settings_dict[key].get('default','')

			# if default is setting_value, then the setting has been set in the translation so ignore it
			if setting_value not in self.not_going_to_config:
				self.pi_settings_dict[key]['setting_value'] = setting_value

			# also set the value in the settings.xml
			self.me.setSetting(key, str(setting_value))
Beispiel #3
0
	def populate_pi_settings_dict(self):

		'''
			Populates the setting_value in the pi_settings_dict.
		'''

		# # this is the method to use if you are populating the dict from the settings.xml
		# latest_settings = self.settings_retriever_xml()

		# but I am going to set up my own process in addition to the xml one, I will be reading some
		# settings from the config.txt, and getting the rest from the settings.xml
		self.config_settings = ct.retrieve_settings_from_configtxt(self.test_config)

		log('Config settings received from the parser: %s' % self.config_settings)

		# cycle through the pi_settings_dict dict, and populate with the settings values
		for key in self.pi_settings_dict.keys():

			# if the value of the setting is to be assigned by another setting, then just ignore it here
			# note: this will mean that the other setting will have to populate both the settings_dict and the settings.xml
			if key in self.values_set_elsewhere:
				continue

			# grab the translate method (if there is one)
			translate_method = self.pi_settings_dict.get(key,{}).get('translate',{})

			# if the key is in the config.txt
			if key in self.config_settings:

				setting_value = self.config_settings[key]

			else:
				# if the key ISNT in the config.txt then set the value from the default stored in 
				# the pi_settings_dict dict

				setting_value = self.pi_settings_dict[key].get('default','')

			# get the setting value, translate it if needed
			if translate_method:
				setting_value = translate_method(setting_value)

			# if default is setting_value, then the setting has been set in the translation so ignore it
			if setting_value not in self.not_going_to_config:
				self.pi_settings_dict[key]['setting_value'] = setting_value

			# also set the value in the settings.xml
			self.me.setSetting(key, str(setting_value))