<haobogu[m]>
Does embassy_time meet your requirement?
<frostie314159[m]>
Somewhat. I was looking for something entirely executor independent, like a Timer or Ticker trait.
starblue has quit [Ping timeout: 252 seconds]
starblue has joined #rust-embedded
starblue has quit [Ping timeout: 272 seconds]
starblue has joined #rust-embedded
ivmarkov[m] has joined #rust-embedded
<ivmarkov[m]>
<frostie314159[m]> "Somewhat. I was looking for..." <- `embassy-time` is executor independent, when you enable its `generic-queue` feature, but of course it still requires an alarm driver implementation in the HAL. Or alternatively, you can use the `Delay` trait from `embassy_hal_async` and live with the viral nature of the induced generic type.
<frostie314159[m]>
Ok, that sounds good, maybe I'll make a PR, which adds a second Ticker trait.
<frostie314159[m]>
Yes, just like that, however as an embedded_hal_async trait.
<JamesMunns[m]>
just wondering - what would you want the trait to do? like, exactly the same behavior?
<frostie314159[m]>
Yes, I want to be able to use tokio or async-std tickers natively, through a trait, since parts of my code run either in an embedded environment with embassy and a host environment with another async runtime.
<JamesMunns[m]>
Interesting! thanks for the context :)
<frostie314159[m]>
I'm building parts of a generic WiFi Stack and some of the lower parts can run either on the host or the embedded device.
<JamesMunns[m]>
fwiw, the reason (IMO) that there aren't any common timer traits (other than Delay), is that it turns out lots of people want to use timers in *slightly* different ways, or timers are just different in enough ways (resolution, range), or require "system level" support (like having an interrupt or two), that it's hard to capture all of that in a single "trait"
<JamesMunns[m]>
embassy-time hits a fair chunk of that (at least for async users, and users that are okay with dedicating 1 or 2 interrupts), but even then it uses some sort of tricky ways of making it happen, not just a trait.
<JamesMunns[m]>
That being said, I think you could abstract over `embassy-time` and `tokio::time` pretty reasonably with traits as you said. You will probably want to have that trait inside your project, or make it a separate crate to "prove it out" before you PR it to embassy or e-h-async.
<JamesMunns[m]>
* embassy-time hits a fair chunk of common use cases (at least for async users, and users that are okay with dedicating 1 or 2 interrupts), but even then it uses some sort of tricky ways of making it happen, not just a trait.
<JamesMunns[m]>
That being said, I think you could abstract over `embassy-time` and `tokio::time` pretty reasonably with traits as you said. You will probably want to have that trait inside your project, or make it a separate crate to "prove it out" before you PR it to embassy or e-h-async.
<frostie314159[m]>
I agree. This is probably an interesting topic to explore. That being said, the trait wouldn't require that many methods. I can only imagine three: tick reset reset_after. These should be possible on every timer implementation and are all you could possibly need.
<frostie314159[m]>
And yes I know, that last sentence sounds a bit like: "Who's ever gonna need more than 4GB of RAM".
<frostie314159[m]>
* of RAM". But for a simplistic ticker, that should be all that's necessary.
<JamesMunns[m]>
:)
<JamesMunns[m]>
people have so many uses for timers! and timers are so weird! But if you make something cool and useful definitely share it! but it is something we've been trying to find the sweet spot(s) for, for about 5-6 years now.
<frostie314159[m]>
I'll definitely give it a shot
<JamesMunns[m]>
It's certainly a domain that invites a lot of "why don't you just" questions :D
<frostie314159[m]>
I can imagine that :)
<frostie314159[m]>
Another issue, which arises is the question on future trait bounds. Should the function look like this: `
<barnabyw[m]>
active low LED? what happens if both loops have set_low?
<enaut[m]>
No way... thank you barnabyw - but why on earth does the onboard LED light up when pulled low? But OK now I know…
burrbull[m] has joined #rust-embedded
<burrbull[m]>
enaut[m]: Ask WeAct
NickStevens[m] has joined #rust-embedded
<NickStevens[m]>
<enaut[m]> "No way... thank you barnabyw..." <- Not sure if this is the reason for your board, but a lot of times LEDs are set to activate when pulled low because the microcontroller can sink more current than it's able to source.
<enaut[m]>
That that might be an interesting option for future projects.
<barnabyw[m]>
ha ha that’s one of the reasons “blink an LED” is embedded hello world rather than “light up an LED” 😁 confirms that your clocks are set up okay, and works regardless of the LED being active high or active low
<JamesMunns[m]>
<barnabyw[m]> "ha ha that’s one of the reasons..." <- and also why you use like a 25%/75% blink instead of 50%/50%, so you can confirm which level is "on" and which is "off"!
<JamesMunns[m]>
enaut ⚡️ a term to learn here is "active high" or "active low" - if the LED turns on when the voltage is low, it is usually called "active low". You see this very often, in fact I'd say I see "active low" more often than I see "active high"! Especially for things like chip selects or interrupt pins.
badrb[m] has quit [Quit: Idle timeout reached: 172800s]
<barnabyw[m]>
it’s often indicated by an overline (bar over the pin symbol)
Guest7282 has joined #rust-embedded
Guest7282 has left #rust-embedded [Error from remote client]
Guest7282 has joined #rust-embedded
kiarie404[m] has quit [Quit: Idle timeout reached: 172800s]
IlPalazzo-ojiis1 has joined #rust-embedded
IlPalazzo-ojiisa has quit [Read error: Connection reset by peer]
IlPalazzo-ojiis1 has quit [Ping timeout: 240 seconds]
IlPalazzo-ojiisa has joined #rust-embedded
Guest7282 has left #rust-embedded [Error from remote client]