Source code for CAP1203
#!/usr/bin/python
__author__ = "D.Qendri"
__copyright__ = "Copyright 2015 Sensorian"
__license__ = "GPL V3"
__version__ = "1.0"
import sys
import time
import smbus
from ctypes import *
CAP1203ADDR  = 0x28					#Capacitive sensor address
CAP = CDLL("./libCAP.so")
[docs]class CAP1203(object):
	'''Capacitive touch controller. Class for CAP1203 touch sensor.'''
	MAIN_CTRL_REG = 0x00
	SENSOR_INPUTS = 0x03
	
	def  __init__(self):
		"""
		Configure sensor for capacitive touch.
		
		
		:param none: 
		:returns: none 
		"""
		self._address = CAP1203ADDR	
		CAP.I2C_Initialize()
		CAP.CAP1203_Initialize()
		
[docs]	def  activeMode(self):
		"""
		Set the capacitive controller in active mode.
		
		
		:param none: 
		:returns: none
		"""
		CAP.CAP1203_ActiveMode()
		 
[docs]	def  standbyMode(self):
		"""
		Set the capacitive controller in standby mode.
		
		
		:param none: 
		:returns: none
		"""
		CAP.CAP1203_StandbyMode()
		 
[docs]	def  deepSleep(self):
		"""
		Put the capacitive controller in deep sleep mode.
		
		
		:param none: 
		:returns: none
		"""
		CAP.CAP1203_DeepSleep()		
 
[docs]	def resumeFromDeepSleep(self):
		"""
		Take the capacitive controller out of deep sleep mode.
		
		
		:param none: 
		:returns: none
		"""
		CAP1203_ResumeFromDeepSleep()
 
[docs]	def multitouchEvent(self):
		"""
		Return true if a multi-touch event happened.
		
		
		:param none: 
		:returns: true if a multi-touch event happened 
		"""
		return CAP.CAP1203_MultitouchEvent()
		
 
[docs]	def getStatusReg(self):
		"""Read the status register.
		
		
		:param none: 
		:returns: status - Contents of status register
		"""
		status = CAP.CAP1203_Read(GEN_STATUS);
		return status;
 
[docs]	def  enableInterrupt(self,pin):
		"""
		Enable the interrupt mode.
		
		
		:param pin: Enables interrupt on the specific pin
		:returns: none
		"""
		CAP.CAP1203_EnableInterrupt(pin)
		 
[docs]	def  setSensitivity(self,sensitivity):
		"""
		Configure the sensitivity of the controller.
		
		
		:param sensitivity: 
		:returns: none
		"""
		CAP.CAP1203_SetSensitivity(sensitivity)
		 
[docs]	def  checkSensorStatus(self):
		"""
		Check the current sensor status.
		
		
		:param none: 
		:returns: status - Current chip status
		"""
		CAP.CAP1203_CheckSensorStatus()
		 
[docs]	def  clearInterrupt(self):
		"""
		Clear any active interrupts.
		
		
		:param none: 
		:returns: none
		"""
		CAP.CAP1203_ClearInterrupt()
		 
[docs]	def  readID(self):
		"""
		Read the sensor manufacturer ID.
		
		
		:param none: 
		:returns: id - Sensor ID as a number
		"""
		id = CAP.CAP1203_ReadID()
		return id
 
[docs]	def  write(self,address,reg,data):
		"""
		Write a byte to the register.
		
		
		:param address: Sensor address
		:param reg: Register address to write to.
		:param data: Data to be written on byte sized register.
		:returns: none
		"""
		return CAP.CAP1203_Write(address,reg,data)
		 
[docs]	def  read(self,address,reg):
		"""
		Read the contents of the register.
		
		
		:param address: Sensor address
		:param reg: Register address to read from.
		:returns: data - Data content of register address
		"""
		return CAP.CAP1203_Read(address,reg)