summaryrefslogtreecommitdiff
path: root/docs/esp32
diff options
context:
space:
mode:
Diffstat (limited to 'docs/esp32')
-rw-r--r--docs/esp32/quickref.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst
index 7127cc402..2c667a0f0 100644
--- a/docs/esp32/quickref.rst
+++ b/docs/esp32/quickref.rst
@@ -587,6 +587,21 @@ Use the :ref:`esp32.PCNT <esp32.PCNT>` class::
The PCNT hardware supports monitoring multiple pins in a single unit to
implement quadrature decoding or up/down signal counters.
+See the :ref:`machine.Counter <machine.Counter>` and
+:ref:`machine.Encoder <machine.Encoder>` classes for simpler abstractions of
+common pulse counting applications::
+
+ from machine import Pin, Counter
+
+ counter = Counter(0, Pin(2)) # create a counter as above and start it
+ count = counter.value() # read the count as an arbitrary precision signed integer
+
+ encoder = Encoder(0, Pin(12), Pin(14)) # create an encoder and begin counting
+ count = encoder.value() # read the count as an arbitrary precision signed integer
+
+Note that the id passed to these ``Counter()`` and ``Encoder()`` objects must be
+a PCNT id.
+
Software SPI bus
----------------