Skip to content

Added individual getSensitivity() and Documentation for the Reference Page #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 254 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
# MCHPTouch library

## Methods

### `QtouchClass()`

Constructor, make the instance of the object.

Already accessible by using `TOUCH` object

#### Syntax

```
QtouchClass TOUCH;
```

#### See also

* [begin()](#begin)
* [poll()](#poll)


### `begin()`

Initializes Qtouch sensors

#### Returns
`true` in success, `false` if it fails.

#### Syntax

```
TOUCH.begin()
```

#### Example

```
#include <Arduino_MCHPTouch.h>

void setup()
{
if(TOUCH.begin()){
// Everything OK
}else{
// Failure
}
}

void loop() {}
```

#### See also

* [poll()](#attached)
* [read()](#read)

### `available()`

Checks for new values availability

#### Syntax

```
TOUCH.available();
```

#### Returns
0 on no data, 1 on measure availability

### `poll()`

Polls the qotuch sensors for new measure.

#### Syntax

```
TOUCH.poll();
```

#### See also

* [available()](#available)
* [read()](#read)

### `read()`

Querys the Qtouch and returns new touch measure.

##### Syntax

```
TOUCH.read(sensor_id)
```
#### Parameters

* sensor_id : Sensor identificator

##### Returns
0 - not activated
1 - activated
-1 - not found

#### Example

```
#include "Arduino_MCHPTouch.h"

void setup()
{
Serial.begin(9600);

// Qtouch initialization
if (!TOUCH.begin())
{
Serial.println("Error in sensors initialization!");
while (1);
}
Serial.println("Touch initialization Done!");
}

void loop()
{
// polling the sensor for new measure
TOUCH.poll();

// Checks if new data are available
if (TOUCH.available())
{
//reads senseors
Serial.print("Sensor 1 status: ");
Serial.println(TOUCH.read(0));
Serial.print("Sensor 2 status: ");
Serial.println(TOUCH.read(1));
Serial.print("Sensor 3 status: ");
Serial.println(TOUCH.read(2));
Serial.print("Sensor 4 status: ");
Serial.println(TOUCH.read(3));
Serial.print("Sensor 5 status: ");
Serial.println(TOUCH.read(4));
Serial.println();
}
delay(100);
}
```

#### See also

* [read()](#read)
* [poll()](#poll)


### `setSensorsSensitivity()`

Sets all the sensors sensitivity value, or to a specific sensor's.

#### Syntax

```
TOUCH.setSensorSensitivty()
//TOUCH.setSensorSensitivty(btn_Channel, newSens)
```

#### Parameters

* (optional) btn_channel : sensor's number, to change only that sensitivity
* newSens : new sensitivity from 3 to 100

#### See also

* [getSensorsSensitivity()](#getSensorsSensitivity)
* [setSensorsHysteresis()](#setSensorsHysteresis)

### `getSensorsSensitivity()`

Querys the Qtouch and returns the configured Sensitivity, or from a specific sensor's
#### Syntax

```
TOUCH.getSensorsSensitivity()
```

#### Parameters

* (optional) btn_channel : sensor's number, to get only that sensitivity

#### See also

* [setSensorsSensitivity()](#setSensorsSensitivity)

### `setSensorsSensitivity()`

Sets all the sensors sensitivity value, or to a specific sensor's.

#### Syntax

```
TOUCH.setSensorSensitivty()
//TOUCH.setSensorSensitivty(btn_Channel, newSens)
```

#### Parameters

* (optional) btn_channel : sensor's number, to change only that sensitivity
* newSens : new sensitivity from 3 to 100

#### See also

* [getSensorsSensitivity()](#getSensorsSensitivity)
* [setSensorsHysteresis()](#setSensorsHysteresis)


### `getSensorsHysteresis()`

Querys the Qtouch and returns the configured hysteresis

#### Syntax

```
TOUCH.getSensorsHysteresis()
```

#### Returns

Hysteresis

#### See also

* [setSensorsSensitivity()](#setSensorsSensitivity)


### `setSensorsHysteresis()`

Querys the Qtouch and returns the configured hysteresis

#### Syntax

```
TOUCH.setSensorsHysteresis(newHyst)
```

#### Parameteres

newHyst:
- HYST_50
- HYST_25
- HYST_12_5
- HYST_6_25
- MAX_HYST

#### See also

* [getSensorsHysteresis()](#getSensorsHysteresis)
* [setSensorsSensitivity()](#setSensorsSensitivity)
31 changes: 31 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Arduino_MCHPTouch

This library allows you to read touch sensors values from the [Arduino MKR](https://store.arduino.cc/arduino-mkr-wifi-1010) boards and the [Arduino Nano 33 IoT](https://store.arduino.cc/arduino-nano-33-iot). Touch sensing is a hardware capability of the SAMD21 processor.

This library allows to configure and read capacitive touch sensors, using MicroChip Technology ([Qtouch](https://www.microchip.com/en-us/development-tools-tools-and-software/libraries-code-examples-and-more/qtouch-tools))

With this you will be able to configure the sensing of the capacitive pad by changing the distance of reading.
Also it allows to get the values with an easy and handy way.

See the bundled [examples](examples/) for usage and visit the [Microchip Developer](https://microchipdeveloper.com/touch:start) website to learn more about touch sensing.


To use this library:

```
#include <Arduino_MCHPTouch.h>
```

## Circuit

[Arduino MKR](https://store.arduino.cc/arduino-mkr-wifi-1010)
[Arduino Nano 33 IoT](https://store.arduino.cc/arduino-nano-33-iot)


## License

This library is a wrapper around the MCHPTouch library by Microchip, which is bundled in binary form in this distribution in agreement with Microchip.

> Microchip Technology Inc., provides the Microchip Touch Library software subject to the license terms contained at the link below.  By using the Microchip Touch Library, you acknowledge and agree to the terms of the license contained at the link below. [Microchip Touch Library License Agreement](Microchip%20Touch%20Library%20License%20Agreement%20-%20Arduino%20082420.pdf)

The Arduino_MCHPTouch wrapper library is distributed under the terms of the MPL-2.0 license.
13 changes: 13 additions & 0 deletions src/Arduino_MCHPTouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ unsigned int QtouchClass::getSensorsSensitivity()
return getSensitivity();
}

/*******************************************************************************
* Function Name : getSensorsSensitivity
* Description : Querys the Qtouch and returns the configured Sensitivity
* value from a specific sensor
* Input : btn_channel - sensor's number
* Return : The Sensitivity value
*******************************************************************************/

unsigned int QtouchClass::getSensorsSensitivity(unsigned int btn_channel)
{
return getSensitivity(unsigned int btn_channel);
}

/*******************************************************************************
* Function Name : getSensorsHysteresis
* Description : Querys the Qtouch and returns the configured hysteresis
Expand Down
4 changes: 4 additions & 0 deletions src/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,7 @@ hysteresis_t getHysteresis() {
unsigned int getSensitivity() {
return _sensitivity;
}

unsigned int getSensitivity(unsigned int btn_channel) {
return _sensitivity_ch[btn_channel];
}