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

Feature Request: provide a millis function #24

Closed
dvberkel opened this issue Jan 7, 2017 · 2 comments
Closed

Feature Request: provide a millis function #24

dvberkel opened this issue Jan 7, 2017 · 2 comments

Comments

@dvberkel
Copy link

dvberkel commented Jan 7, 2017

I was working on a project fully expecting to be able to call millis, a function that

the number of milliseconds since the Arduino board began running the current program.

Unfortunately the code does not compile because

error: 'millis' was not declared in this scope

It would be great if the millis function would be provided as a function.

@dvberkel
Copy link
Author

dvberkel commented Jan 7, 2017

I have studied the code base a bit and I am fairly confident that this is feasible. I would like to share my thoughts on how this could be implemented, getting some feedback if it could work and how it can be improved.

As for the API, I would suggest extending the Timer.h header with

uint32_t millis(void);

The implementation in Timer.cpp would consist of a call to app_timer_cnt_get from app_timer.h, dividing the result by the APP_TIMER_CLOCK_FREQ in order to convert to milliseconds.

If this sound good, I am willing to provide a pull request implementing this feature.

@davison-sm
Copy link
Contributor

Ok, just pushed the feature. In the Board Manager you should have the option to update the Jewelbots Arduino Library to v1.0.1 which contains the function (runtime_ms). Ended up being simple, but took a bit of research to reassure myself it would work together with everything else.

A quick note that tripped me up, since the original definition is runtime since the program began that is what I implemented in the code. The timer starts as early in the bootup sequence as possible and I immediately grab a time value at that point to use as the starting point. But after it grabs that value the vibration motor calibrates and the led startup sequence goes, so the value of runtime when the code inside your setup or loop functions start may be later than would be expected.

Thanks again for your interest in Jewelbots! Please let me know if this works for you and maybe you could share a bit about what you are building on our forums (community.jewelbots.com).

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

No branches or pull requests

2 participants