Making libraries work for Photon AND Core?

For my photon based project I used the following 2 community libraries:

I ended up in forking both and had to do only a few changes to make them work on the Photon. Now I am looking for a possibility to make these changes in a way that the same library works on a photon and on a core. Once that is done I want submit a Pull Request to get the changes back into the original repository.
What I am looking for is some hints how to accomplish that. From my point of view I only need a preprocessor macro to distinguish between the 2 platforms. Do such macros exist ? Am I on the right track ?

Any input is appreciated.
Take care

You can look here

But if you use digitalReadFast() pinReadFast(), digitalWriteFast(), pinSetFast() and pinResetFast() instead of the hardware specific alternatives you may even get away without these.

@ScruffR, I believe the command is pinReadFast(). That’s my doing! :flushed: I’m going to post a PR to rename digitalReadFast() or add digitalReadFast() which makes more sense IMO. Or simply, you could also add a `#define digitalReadFast(pin) pinReadFast(pin) to any app. :smile:

Note that these are ONLY available on the Core and Photon firmware versions 0.4.6 and later.

1 Like

Doh’, should have double checked :blush: - thanks Paul for setting that right.

Yes, it would make more sense if the naming went in line with the standard functions.

But about the versions I think the version when it was introduced on Photon is 0.4.3 (pinReadFast 0.4.4) and for the Core 0.4.5 (at least Web IDE does build with these versions).

@ScruffR, it is only fully on both Core and Photon as of 0.4.6 so that’s why I said that :wink: