Pulse counting question #1374
-
I see there is a PulseCount class and that it is implemented for nrf52. It appears that this is setup for quadrature decoding and not just general counting. Does anyone know a way to use the PulseCount class for single pin counting? Setting control to null slows the system down drastically, but leaving it off throws an error. Setting the signal and control pins to the same pin doesn't appear to count anything. To be clear, I know the hardware is working because I've setup a Digital pin with onReadable counting -- this works except if I ever do Timer.delay -- then counts are missed (obviously). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
The
That's correct. There's no intention for the It doesn't appear that the The ECMA-419 Digital input doesn't provide a counter. But... the older Digital Monitor class on nRF52 does implement a count of rises and falls (based on interrupt callbacks). We don't generally recommend using the original Moddable SDK IO classes, but here it might be useful. |
Beta Was this translation helpful? Give feedback.
Thank you for the additional details.
The monitor class expects to be used with an
onChanged
callback to notify the client when the counters change. The exception happens when the monitor attempts to report the change but there is noonChanged
callback. Your code tries to do this, but uses the ECMA-419 API stye which isn't implemented by the older Monitor API. Something like this should work as you intend:The documentation for the
Monitor
class describes this correctly.