@@ -43,9 +43,9 @@ goes outside defined bounds.
43
43
44
44
# 2. Installation and usage
45
45
46
- The drivers require a daily build of firmware or a release build >=1.15. The
47
- drivers are in the primitives package. To install copy the ` primitives `
48
- directory and its contents to the target hardware.
46
+ The drivers require firmware version >=1.15. The drivers are in the primitives
47
+ package. To install copy the ` primitives ` directory and its contents to the
48
+ target hardware.
49
49
50
50
Drivers are imported with:
51
51
``` python
@@ -332,17 +332,21 @@ API and usage are as per `Pushbutton` with the following provisos:
332
332
1 . The ` sense ` constructor arg is not supported.
333
333
2 . The ` Pin ` instance passed to the constructor must support the touch
334
334
interface. It is instantiated without args, as per the example below.
335
- 3 . There is an additional class variable ` sensitivity ` which should be a float
336
- in range 0.0..1.0. The value ` v ` returned by the touchpad is read on
337
- initialisation. The touchpad is polled and if the value drops below
338
- ` v * sensitivity ` the pad is assumed to be pressed. Default ` sensitivity ` is
339
- 0.9 but this is subject to change.
335
+ 3 . There is an additional classmethod ` threshold ` which takes an integer arg.
336
+ The arg represents the detection threshold as a percentage.
337
+
338
+ The driver determines the untouched state by periodically polling
339
+ ` machine.TouchPad.read() ` and storing its maximum value. If it reads a value
340
+ below ` maximum * threshold / 100 ` a touch is deemed to have occurred. Default
341
+ threshold is currently 80% but this is subject to change.
340
342
341
343
Example usage:
342
344
``` python
343
345
from machine import Pin
344
- from primitives import ESP32Touch
345
346
import uasyncio as asyncio
347
+ from primitives import ESP32Touch
348
+
349
+ ESP32Touch.threshold(70 ) # optional
346
350
347
351
async def main ():
348
352
tb = ESP32Touch(Pin(15 ), suppress = True )
@@ -359,6 +363,10 @@ If a touchpad is touched on initialisation no callbacks will occur even when
359
363
the pad is released. Initial button state is always ` False ` . Normal behaviour
360
364
will commence with subsequent touches.
361
365
366
+ The best threshold value depends on physical design. Directly touching a large
367
+ pad will result in a low value from ` machine.TouchPad.read() ` . A small pad
368
+ covered with an insulating film will yield a smaller change.
369
+
362
370
###### [ Contents] ( ./DRIVERS.md#1-contents )
363
371
364
372
# 5. ADC monitoring
0 commit comments