fivdi / pigpio

Fast GPIO, PWM, servo control, state change notification and interrupt handling with Node.js on the Raspberry Pi
MIT License
948 stars 89 forks source link

Digital Pulse #89

Closed louisvangeldrop closed 4 years ago

louisvangeldrop commented 5 years ago

Espruino.com supports the following digitalPulse function:

Call type: function digitalPulse(pin, value, time) Parameters pin - The pin to use

value - Whether to pulse high (true) or low (false)

time - A time in milliseconds, or an array of times (in which case a square wave will be output starting with a pulse of 'value')

Description Pulse the pin with the value for the given time in milliseconds. It uses a hardware timer to produce accurate pulses, and returns immediately (before the pulse has finished). Use digitalPulse(A0,1,0) to wait until a previous pulse has finished.

eg. digitalPulse(A0,1,5); pulses A0 high for 5ms. digitalPulse(A0,1,[5,2,4]); pulses A0 high for 5ms, low for 2ms, and high for 4ms

Note: if you didn't call pinMode beforehand then this function will also reset pin's state to "output"

digitalPulse is for SHORT pulses that need to be very accurate. If you're doing anything over a few milliseconds, use setTimeout instead.

My question is: how do I get the same functionality using piGpio?

fivdi commented 5 years ago

If the pigpio Node.js module provided bindings for the Waves functions available in the pigpio C library then I think this would be possible. However, the pigpio Node.js module doesn't provide bindings for the Waves functions available in the pigpio C library.

This is a duplicate of #38

louisvangeldrop commented 5 years ago

I will have a look at pigpio-client. The package supports the Wave functionality

fivdi commented 4 years ago

Closing in favour of #38