Looking for information on the pulse counter module (PCNT) from the ESP-IDF

I try to use the PCNT in Mongoose os so i can count pulses and get the time between pulses. I found some source code on the https://github.com/espressif/esp-idf/tree/c77c4ccf6c43ab09fd89e7c907bf5cf2a3499e3b/examples/peripherals/pcnt

Is there anyone who has implemented this in Mongoose OS and also in Javascript?

I just recently implemented PCNT in my firmware. I had to do some trial and error to get access to pcnt.h, and I’ll document what worked for me in case others are searching.

This is applicable to my version of Mongoose OS, which is 2.18.0 (ESP-IDF 3.3).

In mos.yml, add the following under build_vars:

ESP_IDF_EXTRA_COMPONENTS: PCNT

Note that PCNT does not have its own directory like bt does, as it lives in the driver folder with a bunch of other components.

In the header where I need access to pcnt.h:

#include "driver/pcnt.h"

When implementing, be sure you are referencing the correct ESP-IDF version in the docs! The PCNT bits have changed quite a bit over the last couple of years.