Skip to content

Commit 8a524f9

Browse files
authored
Allow changing the PAD via API (#19)
1 parent 4af63cf commit 8a524f9

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

src/Arduino_MCHPTouch.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ void QtouchClass::setSensorsSensitivity(unsigned int newSens)
9898
setSensitivity(newSens);
9999
}
100100

101+
/*******************************************************************************
102+
* Function Name : setTouchPad
103+
* Description : Sets the touch's pad zero in accord with the carrier
104+
* version
105+
* Input : pad - desired pad
106+
* Return : NONE
107+
*******************************************************************************/
108+
void QtouchClass::setTouchPad(int pad)
109+
{
110+
setTouchZero(pad);
111+
}
112+
101113
/*******************************************************************************
102114
* Function Name : setSensorsSensitivity
103115
* Description : Sets a sensor sensitivity value

src/Arduino_MCHPTouch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class QtouchClass
2323
int available();
2424
int read(int sensor_id);
2525
void setSensorsSensitivity(unsigned int newSens);
26+
void setTouchPad(int pad = 0);
2627
void setSensorsSensitivity(unsigned int newSens ,unsigned int btn_channel);
2728
void setSensorsHysteresis(hysteresis_t newHyst);
2829
unsigned int getSensorsSensitivity();

src/touch.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ unsigned int _sensitivity = 50u;
9696
unsigned int _sensitivity_ch[5] = {50u , 50u, 50u, 50u, 50u};
9797

9898
hysteresis_t _hysteresis = HYST_6_25;
99-
99+
int _pad = 0;
100100
uint8_t module_error_code = 0;
101101
/*----------------------------------------------------------------------------
102102
* static variables
@@ -258,6 +258,8 @@ touch_ret_t touch_sensors_init(void)
258258

259259
touch_time.measurement_period_ms = DEF_TOUCH_MEASUREMENT_PERIOD_MS;
260260

261+
touch_config.p_selfcap_config->p_selfcap_y_nodes[0] = Y(_pad);
262+
261263
/* Initialize touch library for Self Cap operation. */
262264
touch_ret = touch_selfcap_sensors_init(&touch_config);
263265
if (touch_ret != TOUCH_SUCCESS) {
@@ -417,6 +419,10 @@ void setSensitivity(unsigned int newSens){
417419
}
418420
}
419421

422+
void setTouchZero(int pad){
423+
_pad = pad;
424+
}
425+
420426
void setSensitivityChannel(unsigned int newSens, unsigned int btn_channel){
421427
_sensitivity_ch[btn_channel] = newSens;
422428
}

src/touch_api_SAMD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ void setSensitivity(unsigned int newSens);
994994
void setSensitivityChannel(unsigned int newSens, unsigned int btn_channel);
995995
hysteresis_t getHysteresis();
996996
unsigned int getSensitivity();
997-
997+
void setTouchZero(int pad);
998998

999999
/* Acquisition module SAMD21 Sequential */
10001000

src/touch_config_samd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
/***************** Communication - Data Streamer ******************/
359359
/**********************************************************/
360360

361-
#define DEF_TOUCH_DATA_STREAMER_ENABLE 1u
361+
#define DEF_TOUCH_DATA_STREAMER_ENABLE 0u
362362
#define DATA_STREAMER_BOARD_TYPE USER_BOARD
363363

364364
#endif /* TOUCH_CONFIG_SAMD_H */

0 commit comments

Comments
 (0)