Skip to content

Commit 45cf70e

Browse files
Update documentation
1 parent aafa310 commit 45cf70e

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

docs/api.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Summary
2+
3+
Members | Descriptions
4+
--------------------------------|---------------------------------------------
5+
`class ` [`CapacitiveTouch`](#class_capacitive_touch) | A user-friendly class for capacitive touch sensing.
6+
`struct ` [`CapTouchPinMapping`](#struct_cap_touch_pin_mapping) | Defines the mapping between an Arduino pin and its capacitive touch hardware settings.
7+
8+
# class `CapacitiveTouch` <a id="class_capacitive_touch" class="anchor"></a>
9+
10+
A user-friendly class for capacitive touch sensing.
11+
12+
Create an instance with: <br/>[CapacitiveTouch](#class_capacitive_touch) ct = [CapacitiveTouch(LOVE_BUTTON)](#class_capacitive_touch);
13+
14+
## Summary
15+
16+
Members | Descriptions
17+
--------------------------------|---------------------------------------------
18+
| [`CapacitiveTouch`](#class_capacitive_touch_1ac22af64579b04c74118d037b1a8715f2) | Constructs a capacitive touch sensor for the given pin. |
19+
| [`begin`](#class_capacitive_touch_1a0cce24fac4a98cecf7840ebf435a5d9c) | Initializes the sensor. |
20+
| [`read`](#class_capacitive_touch_1a5c7b56cc0ad47963fa0b97abe2909aba) | Reads the raw sensor value. |
21+
| [`isTouched`](#class_capacitive_touch_1aab0faf01526c57e1f0f57aa19919d9fa) | Checks if the sensor is touched. |
22+
| [`setThreshold`](#class_capacitive_touch_1a5f773cd9472164c698811962070f903c) | Sets the detection threshold. |
23+
| [`getThreshold`](#class_capacitive_touch_1a64a1533e5ea3109c2ff15a3abf22bbba) | Retrieves the current detection threshold. |
24+
25+
## Members
26+
27+
### `CapacitiveTouch` <a id="class_capacitive_touch_1ac22af64579b04c74118d037b1a8715f2" class="anchor"></a>
28+
29+
```cpp
30+
CapacitiveTouch(uint8_t pin)
31+
```
32+
33+
Constructs a capacitive touch sensor for the given pin.
34+
35+
#### Parameters
36+
* `pin` The Arduino pin number (such as LOVE_BUTTON).
37+
<hr />
38+
39+
### `begin` <a id="class_capacitive_touch_1a0cce24fac4a98cecf7840ebf435a5d9c" class="anchor"></a>
40+
41+
```cpp
42+
void begin()
43+
```
44+
45+
Initializes the sensor.
46+
47+
Configures the pin and initializes the CTSU/DTC hardware.
48+
<hr />
49+
50+
### `read` <a id="class_capacitive_touch_1a5c7b56cc0ad47963fa0b97abe2909aba" class="anchor"></a>
51+
52+
```cpp
53+
int read()
54+
```
55+
56+
Reads the raw sensor value.
57+
58+
Initiates a measurement cycle and returns the raw value.
59+
#### Returns
60+
int The raw sensor value.
61+
<hr />
62+
63+
### `isTouched` <a id="class_capacitive_touch_1aab0faf01526c57e1f0f57aa19919d9fa" class="anchor"></a>
64+
65+
```cpp
66+
bool isTouched()
67+
```
68+
69+
Checks if the sensor is touched.
70+
71+
Compares the raw value to the set threshold.
72+
#### Returns
73+
true if the sensor is touched, false otherwise.
74+
<hr />
75+
76+
### `setThreshold` <a id="class_capacitive_touch_1a5f773cd9472164c698811962070f903c" class="anchor"></a>
77+
78+
```cpp
79+
void setThreshold(int threshold)
80+
```
81+
82+
Sets the detection threshold.
83+
84+
#### Parameters
85+
* `threshold` The new threshold value.
86+
<hr />
87+
88+
### `getThreshold` <a id="class_capacitive_touch_1a64a1533e5ea3109c2ff15a3abf22bbba" class="anchor"></a>
89+
90+
```cpp
91+
int getThreshold()
92+
```
93+
94+
Retrieves the current detection threshold.
95+
96+
#### Returns
97+
int The current threshold value.
98+
<hr />
99+
100+
# struct `CapTouchPinMapping` <a id="struct_cap_touch_pin_mapping" class="anchor"></a>
101+
102+
Defines the mapping between an Arduino pin and its capacitive touch hardware settings.
103+
104+
Each entry includes the Arduino pin number, a flag indicating support, and additional hardware parameters needed for the CTSU.
105+
106+
## Summary
107+
108+
Members | Descriptions
109+
--------------------------------|---------------------------------------------
110+
| [`arduinoPin`](#struct_cap_touch_pin_mapping_1a8f558f88fa5298ded8cbbdd4830b4cbe) | Arduino pin number (e.g., D4, D3, A4) |
111+
| [`supported`](#struct_cap_touch_pin_mapping_1a4e27a8d3ce508ad4bfab32ef4d94e292) | True if this pin is supported for capacitive touch sensing. |
112+
| [`ts_num`](#struct_cap_touch_pin_mapping_1a64ecb7d254b91a6d02229c4b26b94f26) | Touch sensor channel number. |
113+
| [`chac_idx`](#struct_cap_touch_pin_mapping_1aff722690ee3b00afb64221eb1cde5a75) | Channel control register index. |
114+
| [`chac_val`](#struct_cap_touch_pin_mapping_1ad1a206d6af3ddf996713d18190cd2f2c) | Bit mask used to enable the sensor channel. |
115+
116+
## Members
117+
118+
### `arduinoPin` <a id="struct_cap_touch_pin_mapping_1a8f558f88fa5298ded8cbbdd4830b4cbe" class="anchor"></a>
119+
120+
```cpp
121+
uint8_t arduinoPin
122+
```
123+
124+
Arduino pin number (e.g., D4, D3, A4)
125+
126+
<hr />
127+
128+
### `supported` <a id="struct_cap_touch_pin_mapping_1a4e27a8d3ce508ad4bfab32ef4d94e292" class="anchor"></a>
129+
130+
```cpp
131+
bool supported
132+
```
133+
134+
True if this pin is supported for capacitive touch sensing.
135+
136+
<hr />
137+
138+
### `ts_num` <a id="struct_cap_touch_pin_mapping_1a64ecb7d254b91a6d02229c4b26b94f26" class="anchor"></a>
139+
140+
```cpp
141+
uint8_t ts_num
142+
```
143+
144+
Touch sensor channel number.
145+
146+
<hr />
147+
148+
### `chac_idx` <a id="struct_cap_touch_pin_mapping_1aff722690ee3b00afb64221eb1cde5a75" class="anchor"></a>
149+
150+
```cpp
151+
uint8_t chac_idx
152+
```
153+
154+
Channel control register index.
155+
156+
<hr />
157+
158+
### `chac_val` <a id="struct_cap_touch_pin_mapping_1ad1a206d6af3ddf996713d18190cd2f2c" class="anchor"></a>
159+
160+
```cpp
161+
uint8_t chac_val
162+
```
163+
164+
Bit mask used to enable the sensor channel.
165+
166+
<hr />
167+

0 commit comments

Comments
 (0)