# Path: classes/conf.py
# class Conf:
# 	def __init__(self):
# 		self.home = os.path.expanduser('~')
# 		if 'root' in self.home:
# 			self.home = '/home/'+os.path.expanduser(os.environ["SUDO_USER"])
# 		self.conf_folder = self.home+'/.openplotter'
# 		self.data_conf = ConfigParser.SafeConfigParser()
# 		self.read()
# 
# 	def read(self):
# 		self.data_conf.read(self.conf_folder+'/openplotter.conf')
# 
# 	def write(self):
# 		with open(self.conf_folder+'/openplotter.conf', 'wb') as configfile:
# 			self.data_conf.write(configfile)
# 
# 	def get(self, section, item):
# 		result = ''
# 		try:
# 			result = self.data_conf.get(section, item)
# 		except ConfigParser.NoSectionError:
# 			self.read()
# 			try:
# 				self.data_conf.add_section(section)
# 			except ConfigParser.DuplicateSectionError: pass
# 			self.data_conf.set(section, item, '')
# 			self.write()
# 		except ConfigParser.NoOptionError:
# 			self.set(section, item, '')
# 		return result
# 
# 	def set(self, section, item, value):
# 		self.read()
# 		try:
# 			self.data_conf.set(section, item, value)
# 		except ConfigParser.NoSectionError:
# 			self.data_conf.add_section(section)
# 			self.data_conf.set(section, item, value)
# 		self.write()
# 
# 	def has_option(self, section, item):
# 		return self.data_conf.has_option(section, item)
# 
# 	def has_section(self, section):
# 		return self.data_conf.has_section(section)
# 
# 	def add_section(self, section):
# 		return self.data_conf.add_section(section)


import socket, time, math, datetime, platform, threading
	import RPi.GPIO as GPIO
	import spidev,RTIMU
from classes.conf import Conf
from pypilot.boatimu import *
	from classes.bme280 import Bme280
MCP=[]
adjust_point=[]
SignalK=''
data=conf.get('SPI', 'mcp')
try:
	temp_list=eval(data)
except:temp_list=[]
analog_=False
for ii in temp_list:
	if '.*.' in ii[2]: ii[2]=ii[2].replace('*', ii[3])
	MCP.append(ii)	
	if ii[0]==1:analog_=True	
	if ii[0]==1 and ii[4]==1:
		if not conf.has_option('SPI', 'value_'+str(ii[1])):
			temp_list=[[0,0],[1023,1023]]
			conf.set('SPI', 'value_'+str(ii[1]), str(temp_list))
			conf.read()
		
		data=conf.get('SPI', 'value_'+str(ii[1]))
		try:
			temp_list=eval(data)
		except:temp_list = []
			
		adjust_point.append(temp_list)
	else:
		adjust_point.append([])
if analog_:
	try:
		spi = spidev.SpiDev()
		spi.open(0,0)

# Path: classes/conf.py
# class Conf:
# 	def __init__(self):
# 		self.home = os.path.expanduser('~')
# 		if 'root' in self.home:
# 			self.home = '/home/'+os.path.expanduser(os.environ["SUDO_USER"])
# 		self.conf_folder = self.home+'/.openplotter'
# 		self.data_conf = ConfigParser.SafeConfigParser()
# 		self.read()
# 
# 	def read(self):
# 		self.data_conf.read(self.conf_folder+'/openplotter.conf')
# 
# 	def write(self):
# 		with open(self.conf_folder+'/openplotter.conf', 'wb') as configfile:
# 			self.data_conf.write(configfile)
# 
# 	def get(self, section, item):
# 		result = ''
# 		try:
# 			result = self.data_conf.get(section, item)
# 		except ConfigParser.NoSectionError:
# 			self.read()
# 			try:
# 				self.data_conf.add_section(section)
# 			except ConfigParser.DuplicateSectionError: pass
# 			self.data_conf.set(section, item, '')
# 			self.write()
# 		except ConfigParser.NoOptionError:
# 			self.set(section, item, '')
# 		return result
# 
# 	def set(self, section, item, value):
# 		self.read()
# 		try:
# 			self.data_conf.set(section, item, value)
# 		except ConfigParser.NoSectionError:
# 			self.data_conf.add_section(section)
# 			self.data_conf.set(section, item, value)
# 		self.write()
# 
# 	def has_option(self, section, item):
# 		return self.data_conf.has_option(section, item)
# 
# 	def has_section(self, section):
# 		return self.data_conf.has_section(section)
# 
# 	def add_section(self, section):
# 		return self.data_conf.add_section(section)


# Path: read_sensors_d.py
import socket, time, math, datetime, platform, threading
	import RPi.GPIO as GPIO
	import spidev,RTIMU
from classes.conf import Conf
from pypilot.boatimu import *
	from classes.bme280 import Bme280

MCP=[]
adjust_point=[]
SignalK=''
data=conf.get('SPI', 'mcp')
try:
	temp_list=eval(data)
except:temp_list=[]
analog_=False
for ii in temp_list:
	if '.*.' in ii[2]: ii[2]=ii[2].replace('*', ii[3])
	MCP.append(ii)	
	if ii[0]==1:analog_=True	
	if ii[0]==1 and ii[4]==1:
		if not conf.has_option('SPI', 'value_'+str(ii[1])):
			temp_list=[[0,0],[1023,1023]]
			conf.set('SPI', 'value_'+str(ii[1]), str(temp_list))
			conf.read()
		
		data=conf.get('SPI', 'value_'+str(ii[1]))
		try:
			temp_list=eval(data)
		except:temp_list = []
			
		adjust_point.append(temp_list)
	else:
		adjust_point.append([])
if analog_:
	try:
		spi = spidev.SpiDev()
		spi.open(0,0)

	except: