You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I think it would be nice to add a DelayUntil utility to delays. In this way, we can have actual periodic tasks, regardless of the time consumed by a task when executing. To do so, we would need to add the following methods to delays:
getTick(&self) → X (I'm not sure which the return value should be): it returns the current internal clock tick value.
delayUntilMs(&mut self, baseline_tick: X, ms: u16): it waits the given amount of milliseconds FROM THE BASELINE.
delayUntilUs(&mut self, baseline_tick: X, us: u32): it waits the given amount of microseconds FROM THE BASELINE.
With that, we could do something like this:
let tick = timer.getTick();// tick now represents the timedo_stuff();// this takes time...
timer.delayUntilMs(tick,1_000);// we wait one second starting from before we triggered do_stuff
Thus, we would not delay for one second, but 1 second SINCE WE CAPTURED THE BASELINE.
What do you think? Is there anything I'm missing that makes this a bad idea?
The text was updated successfully, but these errors were encountered:
Maybe it is better to implement this feature in the cortex-m crate, so more HALs would benefit from it. I opened this issue in the cortex_m GitHub repo.
Hi! I think it would be nice to add a
DelayUntil
utility to delays. In this way, we can have actual periodic tasks, regardless of the time consumed by a task when executing. To do so, we would need to add the following methods to delays:getTick(&self) → X
(I'm not sure which the return value should be): it returns the current internal clock tick value.delayUntilMs(&mut self, baseline_tick: X, ms: u16)
: it waits the given amount of milliseconds FROM THE BASELINE.delayUntilUs(&mut self, baseline_tick: X, us: u32)
: it waits the given amount of microseconds FROM THE BASELINE.With that, we could do something like this:
Thus, we would not delay for one second, but 1 second SINCE WE CAPTURED THE BASELINE.
What do you think? Is there anything I'm missing that makes this a bad idea?
The text was updated successfully, but these errors were encountered: