diff options
| author | Nick Moore <nick@zoic.org> | 2019-01-28 18:22:57 +1100 |
|---|---|---|
| committer | Nick Moore <nick@zoic.org> | 2019-01-28 18:22:57 +1100 |
| commit | 294b026aca2dfbcef3f8abae9054d6f04c60a61f (patch) | |
| tree | 05ba1bffa43c64eb4f6af0e33b7e6453bf584020 | |
| parent | 539aaf08b52a79a72d4516aa8d8b21cf370f903c (diff) | |
Automatically set a default threshold for touchio.TouchIn channels
| -rw-r--r-- | ports/nrf/common-hal/touchio/TouchIn.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ports/nrf/common-hal/touchio/TouchIn.c b/ports/nrf/common-hal/touchio/TouchIn.c index 5d8d640e0..ba50b17b0 100644 --- a/ports/nrf/common-hal/touchio/TouchIn.c +++ b/ports/nrf/common-hal/touchio/TouchIn.c @@ -77,6 +77,8 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, const mcu_pin_obj_t *pin) { self->pin = pin; claim_pin(pin); + + self->threshold = get_raw_reading(self) * 1.05 + 100; } 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) { return self->threshold; } -void common_hal_touchio_touchin_set_threshold(touchio_touchin_obj_t *self, uint16_t new_threshold) { +void common_hal_touchio_touchin_set_threshold(touchio_touchin_obj_t *self, + uint16_t new_threshold) { self->threshold = new_threshold; } |
