Adafruit Library
CPlay_CapacitiveSensor.h
1 /*
2  CapacitiveSense.h v.04 - Capacitive Sensing Library for 'duino / Wiring
3  https://github.com/PaulStoffregen/CapacitiveSensor
4  http://www.pjrc.com/teensy/td_libs_CapacitiveSensor.html
5  http://playground.arduino.cc/Main/CapacitiveSensor
6  Copyright (c) 2008 Paul Bagder All rights reserved.
7  Version 05 by Paul Stoffregen - Support non-AVR board: Teensy 3.x, Arduino Due
8  Version 04 by Paul Stoffregen - Arduino 1.0 compatibility, issue 146 fix
9  vim: set ts=4:
10 */
11 
12 // ensure this library description is only included once
13 #ifndef CapacitiveSensor_h
14 #define CapacitiveSensor_h
15 
16 #if ARDUINO >= 100
17 #include "Arduino.h"
18 #else
19 #include "WProgram.h"
20 #endif
21 
22 #if defined(ARDUINO_NRF52840_CIRCUITPLAY)
23 #define RwReg uint32_t
24 #elif defined(__AVR__)
25 typedef volatile uint8_t RwReg;
26 #endif
27 
28 
29 /**************************************************************************/
33 /**************************************************************************/
35 {
36  // user-accessible "public" interface
37  public:
38  // methods
39  CPlay_CapacitiveSensor(uint8_t sendPin = 0, uint8_t receivePin = 0);
40  long capacitiveSensorRaw(uint8_t samples);
41  long capacitiveSensor(uint8_t samples);
42  void set_CS_Timeout_Millis(unsigned long timeout_millis);
43  void reset_CS_AutoCal();
44  void set_CS_AutocaL_Millis(unsigned long autoCal_millis);
45  // library-accessible "private" interface
46  private:
47  // variables
48  int error;
49  unsigned long leastTotal;
50  unsigned int loopTimingFactor;
51  unsigned long CS_Timeout_Millis;
52  unsigned long CS_AutocaL_Millis;
53  unsigned long lastCal;
54  unsigned long total;
55  uint8_t _sendPin, _receivePin;
56  volatile RwReg *send_outport, *recv_outport, *recv_inport, *recv_direction;
57  RwReg send_mask, recv_mask;
58 
59  // methods
60  int SenseOneCycle(void);
61 };
62 
63 #endif
long capacitiveSensor(uint8_t samples)
get a capacitive sensor reading
Definition: CPlay_CapacitiveSensor.cpp:95
long capacitiveSensorRaw(uint8_t samples)
get a raw sensor reading
Definition: CPlay_CapacitiveSensor.cpp:150
CPlay_CapacitiveSensor(uint8_t sendPin=0, uint8_t receivePin=0)
Function that handles the creation and setup of instances.
Definition: CPlay_CapacitiveSensor.cpp:29
Class that stores state and functions for the capacitive sensor on CircuitPlayground boards...
Definition: CPlay_CapacitiveSensor.h:34
void set_CS_Timeout_Millis(unsigned long timeout_millis)
set the sensor timeout
Definition: CPlay_CapacitiveSensor.cpp:188
void reset_CS_AutoCal()
reset the auto calibration
Definition: CPlay_CapacitiveSensor.cpp:168
void set_CS_AutocaL_Millis(unsigned long autoCal_millis)
set the auto-calibration time
Definition: CPlay_CapacitiveSensor.cpp:178