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.
Installing from PyPI¶
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:
pip3 install adafruit-circuitpython-cap1188
To install system-wide (this may be required in some cases):
sudo pip3 install adafruit-circuitpython-cap1188
To install in a virtual environment in your current project:
mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-cap1188
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.
Documentation¶
For information on building library documentation, please check out this guide.
Table of Contents¶
Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
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:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
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.
-
sensitivity
¶ The sensitvity of touch detections. Range is 1 (least) to 128 (most).
-
threshold_values
()¶ Return tuple of touch threshold values for all channels.
-
thresholds
¶ Touch threshold value for all channels.
-
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.
-
threshold
¶ The touch threshold value.
-
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:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
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:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
-
class
adafruit_cap1188.spi.
CAP1188_SPI
(spi, cs)¶ Driver for the CAP1188 connected over SPI.