-
Notifications
You must be signed in to change notification settings - Fork 2k
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
event_periodic_callback: add event_periodic_callback_create() #20459
event_periodic_callback: add event_periodic_callback_create() #20459
Conversation
Do you have an example? Can you refactor some code? Reads fine, lgtm. |
I unfortunately can't since that's code by a customer, but I also want to spare your eyes. static void *_adc_thread(void *ctx)
{
(void)ctx;
while (1) {
do_measure();
send_data();
ztimer_sleep():
}
return NULL;
} If I can get them to instead do static void _adc_event(void *ctx)
{
do_measure();
send_data();
} that would be a win for everyone. |
Ah, forgot to ask for squashing 😅 |
eh but those are two distinct commits |
well....if you insist 😀 |
very convenient |
Contribution description
Creating a periodic event should be no more difficult than creating a thread, so add a
event_periodic_callback_create()
convenience functions that reduces creating and starting a periodic event to a single function.Testing procedure
Read the API to see if this is really a worthwhile improvement.
Issues/PRs references
After seeing many threads being created for simple periodic measurements, maybe this could be a remedy.