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
Is it possible to port it to run on the wasm platform?
wasm in browser don't support Instant::now().
If this interface is defined, it will be able to run on the wasm platform #2 (comment)
That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄
As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much. This issue is kind of the same to the one in embedded_hal crate, they also struggle to define one generic enough trait...
Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.
That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄
As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much.
Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.
Actually, we don't rely on absolute time, we only need to rely on the relative time since the Button was new, so we can actually just use core::time::Duration instead of Instant.
I tried to file a draft PR to change this, but noticed that the State enum and raw_state function are public, which means some incompatible changes have occurred to the public API.
Activity
maxwase commentedon May 19, 2024
That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄
As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much. This issue is kind of the same to the one in
embedded_halcrate, they also struggle to define one generic enough trait...Could you please share an example on how you would like to use this crate on WASM platform and how you would implement
Instanton it if it misses one? That would help to consider needed aspects for the trait.zhangzqs commentedon May 19, 2024
Actually, we don't rely on absolute time, we only need to rely on the relative time since the Button was new, so we can actually just use core::time::Duration instead of Instant.
zhangzqs commentedon May 19, 2024
I tried to file a draft PR to change this, but noticed that the State enum and raw_state function are public, which means some incompatible changes have occurred to the public API.
https://github.com/maxwase/button-driver/pull/9/files
maxwase commentedon May 20, 2024
It would be great if you could try to implement your use case using #10
zhangzqs commentedon Jul 5, 2024
Yes, now it works for my use case, and I added an example running on the browser wasm.
#16