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

Tick utilities not implemented #58

Closed bahamut657 closed 5 years ago

bahamut657 commented 6 years ago

Hi Is it possible to add implementation of these functions needed to bootup some devices? Actually,there are no functions to retrieve these datas and process.hrtime() is a bit different get_current_tick tickDiff

fivdi commented 6 years ago

The pigpio Node.js module could be extended to provide access to the pigpio C library gpioTick function which returns the current tick. gpioTick is the pigpio C library equivalent of the pigpio Python get_current_tick function.

Unlike the the pigpio Python library the pigpio C library does not have a tickDiff function. However, it would be easy to add a tickDiff function implemented in pure JavaScript to the pigpio Node.js module. To see how to determine the difference between two ticks in JavaScript see the documentation for the alert event.

bahamut657 commented 6 years ago

This can be closed merging the Waves branch to Master

fivdi commented 6 years ago

@bahamut657 thank you for the information.

erikmav commented 6 years ago

Looking for the same functionality and see it in your Waves fork, @bahamut657 . When is that branch coming to master? If not soon I may need to create a PR with just that functionality to resolve this enhancement request.

bahamut657 commented 6 years ago

@erikma I'm working on it. I'm thinking it will available this weekend. Regards MaDPapo

erikmav commented 6 years ago

@bahamut657 I see your PR for Waves in #64, my PR #65 is mostly orthogonal except for exposing gpioTick() from pigpio.cc. I placed the getTick() and tickDiff() methods at the module level in my implementation, where yours adds to the GPIO class. Both are valid approaches and IMO should just be merged together to expose both methods for ease of use.

erikmav commented 6 years ago

@fivdi any chance of completing #65 to help resolve this issue?

fivdi commented 5 years ago

@bahamut657 @erikma Thank you for suggesting this enhancement and the pull request with the corresponding implementation. pigpio@1.2.0 which has been published on npm contains the enhancement.

erikmav commented 5 years ago

@fivdi Thanks for accepting the PR and publishing! Corresponding TypeScript definition updates in PR at https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30811 . pigpio 1.2.0 validated and placed into production in my system. pigpio-dht PR using 1.2.0 to fix repeated readings: https://github.com/depuits/pigpio-dht/pull/1