Introduction

Documentation Status Discord Build Status

CircuitPython driver for the CAP1188 8-Key Capacitive Touch Sensor Breakout.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

See usage examples in the examples folder.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Building locally

Zip release files

To build this library locally you’ll need to install the circuitpython-build-tools package.

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

Once installed, make sure you are in the virtual environment:

source .env/bin/activate

Then run the build:

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-cap1188 --library_location .

Sphinx documentation

Sphinx is used to build the documentation based on rST files and comments in the code. First, install dependencies (feel free to reuse the virtual environment from above):

python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme

Now, once you have the virtual environment activated:

cd docs
sphinx-build -E -W -b html . _build/html

This will output the documentation to docs/_build/html. Open the index.html in your browser to view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to locally verify it will pass.

Table of Contents

Simple test

Ensure your device works with this simple test.

examples/cap1188_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import board
import busio

# I2C setup
from adafruit_cap1188.i2c import CAP1188_I2C
i2c = busio.I2C(board.SCL, board.SDA)
cap = CAP1188_I2C(i2c)

# SPI setup
# from digitalio import DigitalInOut, Direction
# from adafruit_cap1188.spi import CAP1188_SPI
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
# cs = DigitalInOut(board.D5)
# cap = CAP1188_SPI(spi, cs)

while True:
    for i in range(1, 9):
        if cap[i].value:
            print("Pin {} touched!".format(i))

adafruit_cap1188.cap1188

CircuitPython driver for the CAP1188 8-Key Capacitive Touch Sensor Breakout.

  • Author(s): Carter Nelson

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_cap1188.cap1188.CAP1188

CAP1188 driver base, must be extended for I2C/SPI interfacing.

delta_count(pin)

Return the 8 bit delta count value for the channel.

recalibrate()

Perform a self recalibration on all the pins.

recalibrate_pins(mask)

Recalibrate pins specified by bit mask.

touched()

Return 8 bit value representing touch state of all pins.

touched_pins

A tuple of touched state for all pins.

class adafruit_cap1188.cap1188.CAP1188_Channel(cap1188, pin)

Helper class to represent a touch channel on the CAP1188. Not meant to be used directly.

raw_value

The raw touch measurement.

recalibrate()

Perform a self recalibration.

value

Whether the pin is being touched or not.

adafruit_cap1188.i2c

CircuitPython I2C driver for the CAP1188 8-Key Capacitive Touch Sensor Breakout.

  • Author(s): Carter Nelson

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_cap1188.i2c.CAP1188_I2C(i2c, address=41)

Driver for the CAP1188 connected over I2C.

adafruit_cap1188.spi

CircuitPython SPI driver for the CAP1188 8-Key Capacitive Touch Sensor Breakout.

  • Author(s): Carter Nelson

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_cap1188.spi.CAP1188_SPI(spi, cs)

Driver for the CAP1188 connected over SPI.

Indices and tables