Skip to content

Commit 7644313

Browse files
authored
Added touch sensitivity for each button
* Added the feature to set each touch button sensitivity * Removed TOUCH.init() inside the updateConfig() * Allways the main begin() its going to init the buttons, instead of doing it only if there is not a Buttons.customSens
1 parent 9c69db2 commit 7644313

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/Arduino_MKRIoTCarrier.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ int MKRIoTCarrier::begin(){
4444

4545
if(!Buttons.customSens){
4646

47-
if(CARRIER_CASE){
48-
TOUCH.setSensorsSensitivity(4u);
49-
}else{
50-
TOUCH.setSensorsSensitivity(100u);
51-
}
52-
Buttons.begin(); //init buttons
47+
if(CARRIER_CASE){
48+
TOUCH.setSensorsSensitivity(5u);
49+
}else{
50+
TOUCH.setSensorsSensitivity(100u);
51+
}
5352
}
53+
Buttons.begin(); //init buttons
5454

5555
//init LEDs
5656
leds.begin();

src/Arduino_MKRIoTCarrier_Qtouch.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ MKRIoTCarrier_Qtouch::MKRIoTCarrier_Qtouch(int padIndex, MKRIoTCarrier_Qtouch_Ma
3030
bool MKRIoTCarrier_Qtouch::getTouch(){
3131
bool getState = _pManager->t_state[_padIndex];
3232
_saveToHistory(getState);
33+
3334
return(getState);
3435
}
3536

@@ -82,9 +83,17 @@ bool MKRIoTCarrier_Qtouch::onTouchChange(){
8283
}
8384
}
8485

86+
87+
void MKRIoTCarrier_Qtouch::updateConfig(int newSens){
88+
TOUCH.setSensorsSensitivityChannel(newSens, _padIndex);
89+
//TOUCH.begin();
90+
_pManager->customSens = true;
91+
}
92+
93+
8594
//Manager
8695
bool MKRIoTCarrier_Qtouch_Manager::begin(){
87-
return TOUCH.begin();
96+
return TOUCH.begin();
8897
}
8998
MKRIoTCarrier_Qtouch_Manager::MKRIoTCarrier_Qtouch_Manager(){
9099

@@ -103,6 +112,6 @@ void MKRIoTCarrier_Qtouch_Manager::update(){
103112
void MKRIoTCarrier_Qtouch_Manager::updateConfig(int newSens){
104113
TOUCH.setSensorsSensitivity(newSens);
105114
//TOUCH.setSernsorsHysteresis(newHyst);
106-
TOUCH.begin();
107-
customSens = true;
115+
//TOUCH.begin();
116+
customSens = true;
108117
}

src/Arduino_MKRIoTCarrier_Qtouch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class MKRIoTCarrier_Qtouch{
4949
bool onTouchUp();
5050
bool onTouchChange();
5151

52+
void updateConfig(int newSens);
53+
5254
private:
5355
MKRIoTCarrier_Qtouch_Manager * _pManager;
5456
int _padIndex;

0 commit comments

Comments
 (0)