Skip to content

Available up to 10 channels #13

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 4 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
49 changes: 47 additions & 2 deletions src/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ touch_measure_data_t *p_selfcap_measure_data = NULL;
* setHysteresis() , setSensitivity() and setSensitivityChannel before the init
*/
unsigned int _sensitivity = 50u;
unsigned int _sensitivity_ch[5] = {50u , 50u, 50u, 50u, 50u};
unsigned int _sensitivity_ch[10] = {50u , 50u, 50u, 50u, 50u, 50u , 50u, 50u, 50u, 50u};

hysteresis_t _hysteresis = HYST_6_25;

Expand Down Expand Up @@ -383,6 +383,51 @@ touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_0,
}
}

touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_5,
CHANNEL_5, NO_AKS_GROUP, _sensitivity_ch[5],
HYST_6_25, RES_1_BIT,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}

touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_6,
CHANNEL_6, NO_AKS_GROUP, _sensitivity_ch[6],
HYST_6_25, RES_1_BIT,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}

touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_7,
CHANNEL_7, NO_AKS_GROUP, _sensitivity_ch[7],
HYST_6_25, RES_1_BIT,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}

touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_8,
CHANNEL_8, NO_AKS_GROUP, _sensitivity_ch[8],
HYST_6_25, RES_1_BIT,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}

touch_ret = touch_selfcap_sensor_config(SENSOR_TYPE_KEY, CHANNEL_9,
CHANNEL_9, NO_AKS_GROUP, _sensitivity_ch[9],
HYST_6_25, RES_1_BIT,
&sensor_id);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}

return (touch_ret);
}

Expand Down Expand Up @@ -412,7 +457,7 @@ void setHysteresis(hysteresis_t newHyst){

void setSensitivity(unsigned int newSens){
_sensitivity = newSens;
for (int i = 0; i < 5; i++){
for (int i = 0; i < DEF_SELFCAP_LINES; i++){
_sensitivity_ch[i] = _sensitivity;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/touch_api_SAMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ extern "C"
/* Self capacitance method */
#define GET_SELFCAP_SENSOR_STATE(SENSOR_NUMBER) p_selfcap_measure_data-> \
p_sensor_states[(SENSOR_NUMBER / \
8)] & (1 << (SENSOR_NUMBER % 8))
16)] & (1 << (SENSOR_NUMBER % 16))
/* Mutual capacitance method */
#define GET_MUTLCAP_SENSOR_STATE(SENSOR_NUMBER) p_mutlcap_measure_data-> \
p_sensor_states[(SENSOR_NUMBER / \
8)] & (1 << (SENSOR_NUMBER % 8))
16)] & (1 << (SENSOR_NUMBER % 16))

/**
* \def GET_ROTOR_SLIDER_POSITION(ROTOR_SLIDER_NUMBER)
Expand Down Expand Up @@ -759,7 +759,7 @@ typedef struct tag_touch_measure_data_t {
/* ! Number of sensor state bytes. */
uint8_t num_sensor_states;
/* ! Pointer to Touch Status of each sensor. */
uint8_t *p_sensor_states;
uint16_t *p_sensor_states;
/* ! Length of the Rotor and Slider position values list. */
uint8_t num_rotor_slider_values;
/* ! Pointer to Rotor and Slider position values. */
Expand Down
6 changes: 3 additions & 3 deletions src/touch_config_samd.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
* the touch channel (nodes) are specified below. Touch channel numbering
* follows the order in which Y lines are specified.
*/
#define DEF_SELFCAP_LINES Y(0), Y(8), Y(9), Y(2), Y(3)
#define DEF_SELFCAP_LINES Y(0), Y(1), Y(2), Y(3), Y(4), Y(5), Y(8), Y(9), Y(14), Y(15)

/*----------------------------------------------------------------------------
* Self Cap method channel and sensor configuration.
Expand All @@ -105,7 +105,7 @@
* using 3 touch channels.
* Range: 1u to 16u.
*/
#define DEF_SELFCAP_NUM_CHANNELS (5) /* Total number of channels */
#define DEF_SELFCAP_NUM_CHANNELS (10) /* Total number of channels */

/**
* Self Cap number of Sensors.
Expand All @@ -117,7 +117,7 @@
* the number of sensors is 6 key + 1 rotor + 1 slider = 8 sensors.
* Range: 1u to 16u.
*/
#define DEF_SELFCAP_NUM_SENSORS (5) /* Total number of sensors */
#define DEF_SELFCAP_NUM_SENSORS (10) /* Total number of sensors */

/**
* Self Cap number of Rotors and Sliders.
Expand Down