From 4dd02d7ac00907c82841fd664b46b4c13222b857 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:13:20 +0100 Subject: [PATCH 1/7] Added individual getSensitivity() --- src/Arduino_MCHPTouch.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Arduino_MCHPTouch.cpp b/src/Arduino_MCHPTouch.cpp index 5ccc532..8dcd620 100644 --- a/src/Arduino_MCHPTouch.cpp +++ b/src/Arduino_MCHPTouch.cpp @@ -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 From b962a597cf379352fe58d2e3eff36174a465634a Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:16:05 +0100 Subject: [PATCH 2/7] added individual getSensitivity --- src/touch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/touch.c b/src/touch.c index 3c39de8..cbfcea9 100644 --- a/src/touch.c +++ b/src/touch.c @@ -425,3 +425,7 @@ hysteresis_t getHysteresis() { unsigned int getSensitivity() { return _sensitivity; } + +unsigned int getSensitivity(unsigned int btn_channel) { + return _sensitivity_ch[btn_channel]; +} From 2d9d0f02c18ca45c5ee6c79ab2b8f2afefefafb2 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:43:11 +0100 Subject: [PATCH 3/7] Documentation for the Reference Page --- docs/api.md | 190 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/readme.md | 31 ++++++++ 2 files changed, 221 insertions(+) create mode 100644 docs/api.md create mode 100644 docs/readme.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..02d6f91 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,190 @@ +# Servo library + +## Methods + +### `QtouchClass()` + +Constructor, make the instance of the object. + +Already accessible by using `TOUCH` object + +#### Syntax + +``` +QtouchClass TOUCH; +``` + +#### See also + +* [begim()](#begin) +* [poll()](#poll) + + +### `begin()` + +Initializes Qtouch sensors + +#### Returns +`true` in success, `false` if it fails. + +#### Syntax + +``` +if(TOUCH.begin()){ + // Everything OK +}else{ + // Failure +} +``` + +#### Example + +``` +#include + +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()` + +Updates the status of each capacitive sensor, it saves the values to be used later. + +#### Syntax + +``` +TOUCH.poll(); +``` + +#### See also + +* [available()](#available) +* [read()](#read) + +### `read()` + +Gets the `sensor_id` state. + +##### Syntax + +´´´ +TOUCH.read(sensor_id) +´´´ + +##### Returns +0 - not activated +1 - activated +-1 - not found + +#### Parameters + +* sensor_id : number of the attached sensor + +#### 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()` + +#### 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) + +### `getSensorsSensitivity()` + +#### Syntax + +´´´ +TOUCH.getSensorsSensitivity() +´´´ + +#### Parameters + +* (optional) btn_channel : sensor's number, to get only that sensitivity + +#### See also + +* [setSensorsSensitivity()](#setSensorsSensitivity) \ No newline at end of file diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..60ea4a4 --- /dev/null +++ b/docs/readme.md @@ -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 +``` + +## 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. \ No newline at end of file From defc51acc537fa141a9243fc1b46d185e0b73bc3 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:46:45 +0100 Subject: [PATCH 4/7] Update api.md --- docs/api.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/docs/api.md b/docs/api.md index 02d6f91..eed6ad8 100644 --- a/docs/api.md +++ b/docs/api.md @@ -16,7 +16,7 @@ QtouchClass TOUCH; #### See also -* [begim()](#begin) +* [begin()](#begin) * [poll()](#poll) @@ -30,11 +30,7 @@ Initializes Qtouch sensors #### Syntax ``` -if(TOUCH.begin()){ - // Everything OK -}else{ - // Failure -} +TOUCH.begin() ``` #### Example @@ -93,19 +89,18 @@ Gets the `sensor_id` state. ##### Syntax -´´´ +``` TOUCH.read(sensor_id) -´´´ +``` +#### Parameters + +* sensor_id : number of the attached sensor ##### Returns 0 - not activated 1 - activated -1 - not found -#### Parameters - -* sensor_id : number of the attached sensor - #### Example ``` @@ -187,4 +182,4 @@ TOUCH.getSensorsSensitivity() #### See also -* [setSensorsSensitivity()](#setSensorsSensitivity) \ No newline at end of file +* [setSensorsSensitivity()](#setSensorsSensitivity) From c9b19faa3d4e5e451d7dced8153aa097ce3d96e8 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:55:20 +0100 Subject: [PATCH 5/7] Update api.md --- docs/api.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index eed6ad8..fdb8abd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -70,7 +70,7 @@ TOUCH.available(); ### `poll()` -Updates the status of each capacitive sensor, it saves the values to be used later. +Polls the qotuch sensors for new measure. #### Syntax @@ -85,7 +85,7 @@ TOUCH.poll(); ### `read()` -Gets the `sensor_id` state. +Querys the Qtouch and returns new touch measure. ##### Syntax @@ -94,7 +94,7 @@ TOUCH.read(sensor_id) ``` #### Parameters -* sensor_id : number of the attached sensor +* sensor_id : Sensor identificator ##### Returns 0 - not activated @@ -152,6 +152,8 @@ void loop() ### `setSensorsSensitivity()` +Sets all the sensors sensitivity value, or to a specific sensor's. + #### Syntax ´´´ @@ -167,9 +169,11 @@ TOUCH.setSensorSensitivty() #### See also * [getSensorsSensitivity()](#getSensorsSensitivity) +* [setSensorsHysteresis()](#setSensorsHysteresis) ### `getSensorsSensitivity()` +Querys the Qtouch and returns the configured Sensitivity, or from a specific sensor's #### Syntax ´´´ @@ -183,3 +187,68 @@ TOUCH.getSensorsSensitivity() #### 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) From 272ae978a0e570cde77ba57f88ef4b109757bb44 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:56:47 +0100 Subject: [PATCH 6/7] Update api.md --- docs/api.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/api.md b/docs/api.md index fdb8abd..3bab612 100644 --- a/docs/api.md +++ b/docs/api.md @@ -156,10 +156,10 @@ Sets all the sensors sensitivity value, or to a specific sensor's. #### Syntax -´´´ +``` TOUCH.setSensorSensitivty() //TOUCH.setSensorSensitivty(btn_Channel, newSens) -´´´ +``` #### Parameters @@ -176,9 +176,9 @@ TOUCH.setSensorSensitivty() Querys the Qtouch and returns the configured Sensitivity, or from a specific sensor's #### Syntax -´´´ +``` TOUCH.getSensorsSensitivity() -´´´ +``` #### Parameters @@ -194,10 +194,10 @@ Sets all the sensors sensitivity value, or to a specific sensor's. #### Syntax -´´´ +``` TOUCH.setSensorSensitivty() //TOUCH.setSensorSensitivty(btn_Channel, newSens) -´´´ +``` #### Parameters @@ -216,9 +216,9 @@ Querys the Qtouch and returns the configured hysteresis #### Syntax -´´´ +``` TOUCH.getSensorsHysteresis() -´´´ +``` #### Returns @@ -235,9 +235,9 @@ Querys the Qtouch and returns the configured hysteresis #### Syntax -´´´ +``` TOUCH.setSensorsHysteresis(newHyst) -´´´ +``` #### Parameteres From 48aa7f6df26d1106e253e12017258107ec48d708 Mon Sep 17 00:00:00 2001 From: marqdevx <11246294+marqdevx@users.noreply.github.com> Date: Fri, 29 Jan 2021 15:57:19 +0100 Subject: [PATCH 7/7] Update api.md --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 3bab612..5164de1 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,4 +1,4 @@ -# Servo library +# MCHPTouch library ## Methods