Qwiic_CAP1203_Py  2.0.0
Python for SFE Qwiic CAP1203
Loading...
Searching...
No Matches
qwiic_cap1203.QwiicCAP1203 Class Reference
Inheritance diagram for qwiic_cap1203.QwiicCAP1203:

Public Member Functions

def __init__ (self, address=None, i2c_driver=None)
 Constructor. More...
 
def is_connected (self)
 Determines if this device is connected. More...
 
def begin (self)
 Initializes this device with default parameters. More...
 
def check_main_control (self)
 Control the primary power state of the device. More...
 
def check_status (self)
 Checks inputs in the general status register to ensure program is set up correctly. More...
 
def clear_interrupt (self)
 Clears the interrupt (INT) bit by writing a logic 0 to it. More...
 
def set_interrupt_disabled (self)
 This disables all the interrupts, so the alert LED will not turn on when a sensor is touched. More...
 
def set_interrupt_enabled (self)
 This turns on all the interrupts, so the alert LED turns on when any sensor is touched. More...
 
def is_interrupt_enabled (self)
 Returns state of intterupt pin. More...
 
def set_sensitivity (self, sensitivity)
 Sensitivity calibrated for SparkFun Capacitive Touch Slider. More...
 
def get_sensitivity (self)
 Returns the sensitivity multiplier for current sensitivity settings (pg. More...
 
def is_left_touched (self)
 Checks if touch input detected on left sensor (pad 1). More...
 
def is_middle_touched (self)
 Checks if touch input detected on left sensor (pad 2). More...
 
def is_right_touched (self)
 Checks if touch input detected on left sensor (pad 3). More...
 
def is_touched (self)
 Checks if touch input detected on any sensor. More...
 
def is_right_swipe_pulled (self)
 Checks if a right swipe occured on the board. More...
 
def is_left_swipe_pulled (self)
 Checks if a left swipe occured on the board. More...
 
def set_power_button_pad (self, pad)
 Sets a specific pad to act as a power button. More...
 
def get_power_button_pad (self)
 Returns which capacitive touch pad is currently set to act as a power button. More...
 
def set_power_button_time (self, input_time)
 Configure the length of time that the designated power button must indicate a touch before an interrupt is generated and the power status indicator is set. More...
 
def get_power_button_time (self)
 Returns the length of the time designated time power button must indicate a touch before an interrupt is generated. More...
 
def set_power_button_enabled (self)
 Enables power button in active state. More...
 
def set_power_button_disabled (self)
 Disables power button in active state. More...
 
def is_power_button_enabled (self)
 Returns state of power button. More...
 
def is_power_button_touched (self)
 Once the power button has been held for designated time, an interrupt is generated and PWR bit is set in the General Status Register. More...
 
def millis (self)
 Get the current time in milliseconds. More...
 

Public Attributes

 address
 

Static Public Attributes

 device_name = _DEFAULT_NAME
 
 available_addresses = _AVAILABLE_I2C_ADDRESS
 
int MAIN_CONTROL = 0x00
 
int GENERAL_STATUS = 0x02
 
int SENSOR_INPUT_STATUS = 0x03
 
int NOISE_FLAG_STATUS = 0x0A
 
int SENSOR_INPUT_1_DELTA_COUNT = 0x10
 
int SENSOR_INPUT_2_DELTA_COUNT = 0X11
 
int SENSOR_INPUT_3_DELTA_COUNT = 0X12
 
int SENSITIVITY_CONTROL = 0x1F
 
int CONFIG = 0x20
 
int SENSOR_INPUT_ENABLE = 0x21
 
int SENSOR_INPUT_CONFIG = 0x22
 
int SENSOR_INPUT_CONFIG_2 = 0x23
 
int AVERAGING_AND_SAMPLE_CONFIG = 0x24
 
int CALIBRATION_ACTIVATE_AND_STATUS = 0x26
 
int INTERRUPT_ENABLE = 0x27
 
int REPEAT_RATE_ENABLE = 0x28
 
int MULTIPLE_TOUCH_CONFIG = 0x2A
 
int MULTIPLE_TOUCH_PATTERN_CONFIG = 0x2B
 
int MULTIPLE_TOUCH_PATTERN = 0x2D
 
int BASE_COUNT_OUT = 0x2E
 
int RECALIBRATION_CONFIG = 0x2F
 
int SENSOR_1_INPUT_THRESH = 0x30
 
int SENSOR_2_INPUT_THRESH = 0x31
 
int SENSOR_3_INPUT_THRESH = 0x32
 
int SENSOR_INPUT_NOISE_THRESH = 0x38
 
int STANDBY_CHANNEL = 0x40
 
int STANDBY_CONFIG = 0x41
 
int STANDBY_SENSITIVITY = 0x42
 
int STANDBY_THRESH = 0x43
 
int CONFIG_2 = 0x44
 
int SENSOR_INPUT_1_BASE_COUNT = 0x50
 
int SENSOR_INPUT_2_BASE_COUNT = 0x51
 
int SENSOR_INPUT_3_BASE_COUNT = 0x52
 
int POWER_BUTTON = 0x60
 
int POWER_BUTTON_CONFIG = 0x61
 
int SENSOR_INPUT_1_CALIBRATION = 0xB1
 
int SENSOR_INPUT_2_CALIBRATION = 0xB2
 
int SENSOR_INPUT_3_CALIBRATION = 0xB3
 
int SENSOR_INPUT_CALIBRATION_LSB_1 = 0xB9
 
int PROD_ID = 0xFD
 
int MANUFACTURE_ID = 0xFE
 
int REVISION = 0xFF
 
int PROD_ID_VALUE = 0x6D
 
int OFF = 0x00
 
int ON = 0x01
 
int PWR_CS1 = 0x00
 
int PWR_CS2 = 0x01
 
int PWR_CS3 = 0x02
 
int PAD_LEFT = PWR_CS1
 
int PAD_MIDDLE = PWR_CS2
 
int PAD_RIGHT = PWR_CS3
 
int PWR_TIME_280_MS = 0x00
 
int PWR_TIME_560_MS = 0x01
 
int PWR_TIME_1120_MS = 0x02
 
int PWR_TIME_2240_MS = 0x03
 
int SENSITIVITY_128X = 0x00
 
int SENSITIVITY_64X = 0x01
 
int SENSITIVITY_32X = 0x02
 
int SENSITIVITY_16X = 0x03
 
int SENSITIVITY_8X = 0x04
 
int SENSITIVITY_4X = 0x05
 
int SENSITIVITY_2X = 0x06
 
int SENSITIVITY_1X = 0x07
 

Properties

 connected = property(is_connected)
 

Constructor & Destructor Documentation

◆ __init__()

def qwiic_cap1203.QwiicCAP1203.__init__ (   self,
  address = None,
  i2c_driver = None 
)

Constructor.

Parameters
int,optionaladdress: The I2C address to use for the device If not provided, the default address is used
I2CDriver,optionali2c_driver: An existing i2c driver object If not provided, a driver object is created

Member Function Documentation

◆ begin()

def qwiic_cap1203.QwiicCAP1203.begin (   self)

Initializes this device with default parameters.

Returns
bool Returns True if successful, otherwise False

◆ check_main_control()

def qwiic_cap1203.QwiicCAP1203.check_main_control (   self)

Control the primary power state of the device.

See data sheet on Main Control Register (pg. 22).

Returns
int Main Control Register value

◆ check_status()

def qwiic_cap1203.QwiicCAP1203.check_status (   self)

Checks inputs in the general status register to ensure program is set up correctly.

See data sheet on Status Registers (pg. 23).

Returns
int General Status Register value

◆ clear_interrupt()

def qwiic_cap1203.QwiicCAP1203.clear_interrupt (   self)

Clears the interrupt (INT) bit by writing a logic 0 to it.

This bit must be cleared in order to detec a new capacitive touch input. See datasheet on Main Control Register (pg. 22).

◆ get_power_button_pad()

def qwiic_cap1203.QwiicCAP1203.get_power_button_pad (   self)

Returns which capacitive touch pad is currently set to act as a power button.

Add 1 to return value so value matches pad number. See data sheet on Power Button (pg. 44) REG VALUE PAD 0x00 1 0x01 2 0x02 3

Returns
int Pad number set as power button

◆ get_power_button_time()

def qwiic_cap1203.QwiicCAP1203.get_power_button_time (   self)

Returns the length of the time designated time power button must indicate a touch before an interrupt is generated.

See data sheet on Power Button Time (pg. 44) REG VALUE TIME 0x00 280 MS 0x01 560 MS 0x02 1120 MS 0x03 2240 MS

Returns
int Time in milliseconds

◆ get_sensitivity()

def qwiic_cap1203.QwiicCAP1203.get_sensitivity (   self)

Returns the sensitivity multiplier for current sensitivity settings (pg.

25).

Returns
int Sensitivity multiplier

◆ is_connected()

def qwiic_cap1203.QwiicCAP1203.is_connected (   self)

Determines if this device is connected.

Returns
bool True if connected, otherwise False

◆ is_interrupt_enabled()

def qwiic_cap1203.QwiicCAP1203.is_interrupt_enabled (   self)

Returns state of intterupt pin.

Returns true if all interrupts enabled (0x07), otherwise returns false. When the interrupts are enabled, the LED on the CAP1203 Touch Slider Board turns on when it detects a touch (pg. 33).

Returns
bool True if enabled, otherwise False

◆ is_left_swipe_pulled()

def qwiic_cap1203.QwiicCAP1203.is_left_swipe_pulled (   self)

Checks if a left swipe occured on the board.

This method takes up all functionality due to implementation of while loop with millis().

Returns
bool True if left swipe occured, otherwise False

◆ is_left_touched()

def qwiic_cap1203.QwiicCAP1203.is_left_touched (   self)

Checks if touch input detected on left sensor (pad 1).

Need to clear interrupt pin after touch occurs. See datasheet on Sensor Interrupt Status Reg (pg.23).

Returns
bool True if left sensor is touched, otherwise False

◆ is_middle_touched()

def qwiic_cap1203.QwiicCAP1203.is_middle_touched (   self)

Checks if touch input detected on left sensor (pad 2).

Need to clear interrupt pin after touch occurs. See datasheet on Sensor Interrupt Status Reg (pg.23).

Returns
bool True if middle sensor is touched, otherwise False

◆ is_power_button_enabled()

def qwiic_cap1203.QwiicCAP1203.is_power_button_enabled (   self)

Returns state of power button.

Returns true if enabled (reg. value is 0x01), otherwise returns false. Power button must be ENABLED to use. See data sheet on Power Button Configuration Register (pg. 43-44).

Returns
bool True if enabled, otherwise False

◆ is_power_button_touched()

def qwiic_cap1203.QwiicCAP1203.is_power_button_touched (   self)

Once the power button has been held for designated time, an interrupt is generated and PWR bit is set in the General Status Register.

See data sheet on Power Button (pg. 16), Power Button Register (pg. 43), and Power Button Configuration Register (pg. 43).

Returns
bool True if power button is touched, otherwise False

◆ is_right_swipe_pulled()

def qwiic_cap1203.QwiicCAP1203.is_right_swipe_pulled (   self)

Checks if a right swipe occured on the board.

This method takes up all functionality due to implementation of while loop with millis().

Returns
bool True if right swipe occured, otherwise False

◆ is_right_touched()

def qwiic_cap1203.QwiicCAP1203.is_right_touched (   self)

Checks if touch input detected on left sensor (pad 3).

Need to clear interrupt pin after touch occurs. See datasheet on Sensor Interrupt Status Reg (pg.23).

Returns
bool True if right sensor is touched, otherwise False

◆ is_touched()

def qwiic_cap1203.QwiicCAP1203.is_touched (   self)

Checks if touch input detected on any sensor.

Need to clear interrupt pin after touch occurs. See datasheet on Sensor Interrupt Status (pg.23).

Returns
bool True if any sensor is touched, otherwise False

◆ millis()

def qwiic_cap1203.QwiicCAP1203.millis (   self)

Get the current time in milliseconds.

Returns
int Current time in milliseconds

◆ set_interrupt_disabled()

def qwiic_cap1203.QwiicCAP1203.set_interrupt_disabled (   self)

This disables all the interrupts, so the alert LED will not turn on when a sensor is touched.

Set on default in begin function See data sheet on Interrupt Enable Register (pg. 33).

◆ set_interrupt_enabled()

def qwiic_cap1203.QwiicCAP1203.set_interrupt_enabled (   self)

This turns on all the interrupts, so the alert LED turns on when any sensor is touched.

See data sheet on Interrupt Enable Register (pg. 33).

◆ set_power_button_disabled()

def qwiic_cap1203.QwiicCAP1203.set_power_button_disabled (   self)

Disables power button in active state.

See data sheet on Power Button Configuration Register (pg. 43-44)

◆ set_power_button_enabled()

def qwiic_cap1203.QwiicCAP1203.set_power_button_enabled (   self)

Enables power button in active state.

See data sheet on Power Button Configuration Register (pg. 43-44)

◆ set_power_button_pad()

def qwiic_cap1203.QwiicCAP1203.set_power_button_pad (   self,
  pad 
)

Sets a specific pad to act as a power button.

Function takes in which pad to set as power button. See datasheet on Power Button (pg. 16).

Parameters
intpad: Pad to be set as power button
Returns
bool True if successful, otherwise False

◆ set_power_button_time()

def qwiic_cap1203.QwiicCAP1203.set_power_button_time (   self,
  input_time 
)

Configure the length of time that the designated power button must indicate a touch before an interrupt is generated and the power status indicator is set.

See data sheet on Power Button Configuration Register (pg. 43).

Possible inputs (represent time in ms): 280, 560, 1120, 2240

Parameters
intinput_time: Power button input time
Returns
bool True if successful, otherwise False

◆ set_sensitivity()

def qwiic_cap1203.QwiicCAP1203.set_sensitivity (   self,
  sensitivity 
)

Sensitivity calibrated for SparkFun Capacitive Touch Slider.

You may want to change sensitivity settings if creating your own capacitive touch pads. See datasheet on Sensitivity Control Register (pg. 25).

Parameters
intsensitivity: Sensitivity multiplier

Member Data Documentation

◆ address

qwiic_cap1203.QwiicCAP1203.address

◆ available_addresses

qwiic_cap1203.QwiicCAP1203.available_addresses = _AVAILABLE_I2C_ADDRESS
static

◆ AVERAGING_AND_SAMPLE_CONFIG

int qwiic_cap1203.QwiicCAP1203.AVERAGING_AND_SAMPLE_CONFIG = 0x24
static

◆ BASE_COUNT_OUT

int qwiic_cap1203.QwiicCAP1203.BASE_COUNT_OUT = 0x2E
static

◆ CALIBRATION_ACTIVATE_AND_STATUS

int qwiic_cap1203.QwiicCAP1203.CALIBRATION_ACTIVATE_AND_STATUS = 0x26
static

◆ CONFIG

int qwiic_cap1203.QwiicCAP1203.CONFIG = 0x20
static

◆ CONFIG_2

int qwiic_cap1203.QwiicCAP1203.CONFIG_2 = 0x44
static

◆ device_name

qwiic_cap1203.QwiicCAP1203.device_name = _DEFAULT_NAME
static

◆ GENERAL_STATUS

int qwiic_cap1203.QwiicCAP1203.GENERAL_STATUS = 0x02
static

◆ INTERRUPT_ENABLE

int qwiic_cap1203.QwiicCAP1203.INTERRUPT_ENABLE = 0x27
static

◆ MAIN_CONTROL

int qwiic_cap1203.QwiicCAP1203.MAIN_CONTROL = 0x00
static

◆ MANUFACTURE_ID

int qwiic_cap1203.QwiicCAP1203.MANUFACTURE_ID = 0xFE
static

◆ MULTIPLE_TOUCH_CONFIG

int qwiic_cap1203.QwiicCAP1203.MULTIPLE_TOUCH_CONFIG = 0x2A
static

◆ MULTIPLE_TOUCH_PATTERN

int qwiic_cap1203.QwiicCAP1203.MULTIPLE_TOUCH_PATTERN = 0x2D
static

◆ MULTIPLE_TOUCH_PATTERN_CONFIG

int qwiic_cap1203.QwiicCAP1203.MULTIPLE_TOUCH_PATTERN_CONFIG = 0x2B
static

◆ NOISE_FLAG_STATUS

int qwiic_cap1203.QwiicCAP1203.NOISE_FLAG_STATUS = 0x0A
static

◆ OFF

int qwiic_cap1203.QwiicCAP1203.OFF = 0x00
static

◆ ON

int qwiic_cap1203.QwiicCAP1203.ON = 0x01
static

◆ PAD_LEFT

int qwiic_cap1203.QwiicCAP1203.PAD_LEFT = PWR_CS1
static

◆ PAD_MIDDLE

int qwiic_cap1203.QwiicCAP1203.PAD_MIDDLE = PWR_CS2
static

◆ PAD_RIGHT

int qwiic_cap1203.QwiicCAP1203.PAD_RIGHT = PWR_CS3
static

◆ POWER_BUTTON

int qwiic_cap1203.QwiicCAP1203.POWER_BUTTON = 0x60
static

◆ POWER_BUTTON_CONFIG

int qwiic_cap1203.QwiicCAP1203.POWER_BUTTON_CONFIG = 0x61
static

◆ PROD_ID

int qwiic_cap1203.QwiicCAP1203.PROD_ID = 0xFD
static

◆ PROD_ID_VALUE

int qwiic_cap1203.QwiicCAP1203.PROD_ID_VALUE = 0x6D
static

◆ PWR_CS1

int qwiic_cap1203.QwiicCAP1203.PWR_CS1 = 0x00
static

◆ PWR_CS2

int qwiic_cap1203.QwiicCAP1203.PWR_CS2 = 0x01
static

◆ PWR_CS3

int qwiic_cap1203.QwiicCAP1203.PWR_CS3 = 0x02
static

◆ PWR_TIME_1120_MS

int qwiic_cap1203.QwiicCAP1203.PWR_TIME_1120_MS = 0x02
static

◆ PWR_TIME_2240_MS

int qwiic_cap1203.QwiicCAP1203.PWR_TIME_2240_MS = 0x03
static

◆ PWR_TIME_280_MS

int qwiic_cap1203.QwiicCAP1203.PWR_TIME_280_MS = 0x00
static

◆ PWR_TIME_560_MS

int qwiic_cap1203.QwiicCAP1203.PWR_TIME_560_MS = 0x01
static

◆ RECALIBRATION_CONFIG

int qwiic_cap1203.QwiicCAP1203.RECALIBRATION_CONFIG = 0x2F
static

◆ REPEAT_RATE_ENABLE

int qwiic_cap1203.QwiicCAP1203.REPEAT_RATE_ENABLE = 0x28
static

◆ REVISION

int qwiic_cap1203.QwiicCAP1203.REVISION = 0xFF
static

◆ SENSITIVITY_128X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_128X = 0x00
static

◆ SENSITIVITY_16X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_16X = 0x03
static

◆ SENSITIVITY_1X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_1X = 0x07
static

◆ SENSITIVITY_2X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_2X = 0x06
static

◆ SENSITIVITY_32X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_32X = 0x02
static

◆ SENSITIVITY_4X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_4X = 0x05
static

◆ SENSITIVITY_64X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_64X = 0x01
static

◆ SENSITIVITY_8X

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_8X = 0x04
static

◆ SENSITIVITY_CONTROL

int qwiic_cap1203.QwiicCAP1203.SENSITIVITY_CONTROL = 0x1F
static

◆ SENSOR_1_INPUT_THRESH

int qwiic_cap1203.QwiicCAP1203.SENSOR_1_INPUT_THRESH = 0x30
static

◆ SENSOR_2_INPUT_THRESH

int qwiic_cap1203.QwiicCAP1203.SENSOR_2_INPUT_THRESH = 0x31
static

◆ SENSOR_3_INPUT_THRESH

int qwiic_cap1203.QwiicCAP1203.SENSOR_3_INPUT_THRESH = 0x32
static

◆ SENSOR_INPUT_1_BASE_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_1_BASE_COUNT = 0x50
static

◆ SENSOR_INPUT_1_CALIBRATION

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_1_CALIBRATION = 0xB1
static

◆ SENSOR_INPUT_1_DELTA_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_1_DELTA_COUNT = 0x10
static

◆ SENSOR_INPUT_2_BASE_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_2_BASE_COUNT = 0x51
static

◆ SENSOR_INPUT_2_CALIBRATION

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_2_CALIBRATION = 0xB2
static

◆ SENSOR_INPUT_2_DELTA_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_2_DELTA_COUNT = 0X11
static

◆ SENSOR_INPUT_3_BASE_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_3_BASE_COUNT = 0x52
static

◆ SENSOR_INPUT_3_CALIBRATION

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_3_CALIBRATION = 0xB3
static

◆ SENSOR_INPUT_3_DELTA_COUNT

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_3_DELTA_COUNT = 0X12
static

◆ SENSOR_INPUT_CALIBRATION_LSB_1

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_CALIBRATION_LSB_1 = 0xB9
static

◆ SENSOR_INPUT_CONFIG

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_CONFIG = 0x22
static

◆ SENSOR_INPUT_CONFIG_2

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_CONFIG_2 = 0x23
static

◆ SENSOR_INPUT_ENABLE

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_ENABLE = 0x21
static

◆ SENSOR_INPUT_NOISE_THRESH

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_NOISE_THRESH = 0x38
static

◆ SENSOR_INPUT_STATUS

int qwiic_cap1203.QwiicCAP1203.SENSOR_INPUT_STATUS = 0x03
static

◆ STANDBY_CHANNEL

int qwiic_cap1203.QwiicCAP1203.STANDBY_CHANNEL = 0x40
static

◆ STANDBY_CONFIG

int qwiic_cap1203.QwiicCAP1203.STANDBY_CONFIG = 0x41
static

◆ STANDBY_SENSITIVITY

int qwiic_cap1203.QwiicCAP1203.STANDBY_SENSITIVITY = 0x42
static

◆ STANDBY_THRESH

int qwiic_cap1203.QwiicCAP1203.STANDBY_THRESH = 0x43
static

Property Documentation

◆ connected

qwiic_cap1203.QwiicCAP1203.connected = property(is_connected)
static

The documentation for this class was generated from the following file: