예제 #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')
예제 #2
0
	def final_method(self):

		''' 
			The method to call after all the other setting methods have been called.

			For example, in the case of the Raspberry Pi's settings module, the final writing to the config.txt can be delayed
			until all the settings have been updated in the pi_settings_dict. 

		'''

		''' This method will write the changed settings to the config.txt file. '''

		# translate the changed settings into values that can be used in the config.txt
		self.translated_changed_settings = {}
		for k, v in self.changed_settings.iteritems():

			# translate the setting if needed
			# in some cases this translation can be used to set the values for other settings and have them added
			# to the translated_changed_settings dict
			translate_method = self.pi_settings_dict.get(k,{}).get('translate', False)

			if translate_method:
				value = translate_method(v, reverse=True)
			else:
				value = v #.get('setting_value','')

			# if the setting is not to be added to the config.txt, then dont add it to the self.translated_changed_settings dict
			if k in self.not_going_to_config:
				continue

			# # if this is the other_settings_string then break up into the individual settings
			# elif k == 'other_settings_string':
			# 	for key, svalue in value.iteritems():
			# 		self.translated_changed_settings[key] = svalue

			# add the setting to the translated settings dict, this is now ready to send to the config.txt writer	
			else:
				self.translated_changed_settings[k] = value

		# transfer the remove list into the changes dict
		# this will make sure that existing settings in the config.txt that need to be removed, will be removed
		for remove_key in self.remove_list:
			self.translated_changed_settings[remove_key] = 'remove'

		# reset the remove list
		self.remove_list = []

		# start_x=1 added by default to every config.txt
		# popcornmix: I would remove start_file=start_x.elf and fixup_file=fixup_x.dat and use the shortcut start_x=1
		self.translated_changed_settings['start_x'] = 1

		# write the settings to the config.txt
		ct.apply_changes_to_configtxt(self.translated_changed_settings, self.test_config)
예제 #3
0
	def final_method(self):

		''' 
			The method to call after all the other setting methods have been called.

			For example, in the case of the Raspberry Pi's settings module, the final writing to the config.txt can be delayed
			until all the settings have been updated in the pi_settings_dict. 

		'''

		''' This method will write the changed settings to the config.txt file. '''

		# translate the changed settings into values that can be used in the config.txt
		self.translated_changed_settings = {}
		for k, v in self.changed_settings.iteritems():

			# translate the setting if needed
			# in some cases this translation can be used to set the values for other settings and have them added
			# to the translated_changed_settings dict
			translate_method = self.pi_settings_dict.get(k,{}).get('translate', False)

			if translate_method:
				value = translate_method(v, reverse=True)
			else:
				value = v #.get('setting_value','')

			# if the setting is not to be added to the config.txt, then dont add it to the self.translated_changed_settings dict
			if k in self.not_going_to_config:
				continue

			# # if this is the other_settings_string then break up into the individual settings
			# elif k == 'other_settings_string':
			# 	for key, svalue in value.iteritems():
			# 		self.translated_changed_settings[key] = svalue

			# add the setting to the translated settings dict, this is now ready to send to the config.txt writer	
			else:
				self.translated_changed_settings[k] = value

		# transfer the remove list into the changes dict
		# this will make sure that existing settings in the config.txt that need to be removed, will be removed
		for remove_key in self.remove_list:
			self.translated_changed_settings[remove_key] = 'remove'

		# reset the remove list
		self.remove_list = []

		# start_x=1 added by default to every config.txt
		# popcornmix: I would remove start_file=start_x.elf and fixup_file=fixup_x.dat and use the shortcut start_x=1
		self.translated_changed_settings['start_x'] = 1

		# write the settings to the config.txt
		ct.apply_changes_to_configtxt(self.translated_changed_settings, self.test_config)
예제 #4
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))
예제 #5
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))