Skip to content

Commit 294b026

Browse files
committed
Automatically set a default threshold for touchio.TouchIn channels
1 parent 539aaf0 commit 294b026

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ports/nrf/common-hal/touchio/TouchIn.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self,
7777
const mcu_pin_obj_t *pin) {
7878
self->pin = pin;
7979
claim_pin(pin);
80+
81+
self->threshold = get_raw_reading(self) * 1.05 + 100;
8082
}
8183

8284
bool common_hal_touchio_touchin_deinited(touchio_touchin_obj_t* self) {
@@ -108,6 +110,7 @@ uint16_t common_hal_touchio_touchin_get_threshold(touchio_touchin_obj_t *self) {
108110
return self->threshold;
109111
}
110112

111-
void common_hal_touchio_touchin_set_threshold(touchio_touchin_obj_t *self, uint16_t new_threshold) {
113+
void common_hal_touchio_touchin_set_threshold(touchio_touchin_obj_t *self,
114+
uint16_t new_threshold) {
112115
self->threshold = new_threshold;
113116
}

0 commit comments

Comments
 (0)