Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building for platforms other than Arduino. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

codygray
Copy link

@codygray codygray commented Jan 7, 2020

With a few minor tweaks, this library can be made more universal, so that it can be built for platforms other than Arduino. This vastly increases the usefulness of the library, without compromising any functionality.

This merge request contains the changes needed to make the library universal enough to be built for any platform with a standards-compliant C++11 compiler. These changes are as minimally-invasive as possible, and remain fully backwards-compatible (as long as ARDUINO is #defined, the original code will be used).

@codygray codygray mentioned this pull request Jan 7, 2020
@feliwir
Copy link

feliwir commented Jan 7, 2020

Would it maybe be possible to provide a millis function through a std:::function? On my STM32 chrono doesn’t work

@codygray
Copy link
Author

Would it maybe be possible to provide a millis function through a std:::function? On my STM32 chrono doesn’t work

Sure, you could modify the header file to accept an implementation in the form of a caller-specified lambda. That probably makes more sense than attempting to detect the environment with preprocessor macros, since the way of doing this tends to vary widely across different microcontrollers and development environments.

But I would certainly prefer to use the standard implementation whenever possible for simplicity and elegance, so I'm not quite sure how to merge this in alongside what I have now. Perhaps checking for C++11 support with a macro? That would work, unless your compiler reports it is C++11-compliant, yet omits support for the std::chrono libraries. And without C++11 support, you're not going to have std::function or lambda support, either.

For compatibility with these older environments, it might make more sense to just link in your own millis() function. I don't know. Open to suggestions on this.

@mikalhart
Copy link
Owner

Plan to introduce a millis() function for non-Arduino platforms using std:chrono (where it is supported). Would be grateful if someone could do a PLATFORMIO test on the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants