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

Newtype fugit Rate, Instant and Duration #3083

Merged
merged 4 commits into from
Feb 4, 2025
Merged

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Jan 31, 2025

Closes #2923

skip-changelog because of embassy/wifi updates.

@bugadani bugadani force-pushed the time branch 5 times, most recently from 7878da0 to a1f9a4a Compare February 3, 2025 10:25
esp-hal/src/i2c/master/mod.rs Outdated Show resolved Hide resolved
esp-hal-embassy/src/time_driver.rs Outdated Show resolved Hide resolved
@bugadani bugadani force-pushed the time branch 5 times, most recently from e204b06 to 728dd66 Compare February 3, 2025 12:26
@bugadani bugadani force-pushed the time branch 2 times, most recently from a5747a0 to ab9491f Compare February 3, 2025 14:54
@bugadani bugadani added the skip-changelog No changelog modification needed label Feb 3, 2025
@bugadani bugadani marked this pull request as ready for review February 3, 2025 16:26
esp-hal/src/time.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

We could consider a From<core::time::Duration> impl but not necessarily in this PR (it's already big enough)

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks for taking care of the impl @bugadani!

The only thing left to do now is bikeshed megahertz, I've offered my opinion, and a few alternatives.

esp-hal/MIGRATING-0.23.md Show resolved Hide resolved
@Ben-PH
Copy link

Ben-PH commented Feb 4, 2025

fugit forces the exclusive choice of u32 or u64. this creates frustrations when wanting to interface with other crates that use usize, or some other int-len.

Awhile ago, I ran into this issue, and it's a pain.

I would recommend something that bases itself more on using the typenum crate, so as to clear out this potential issue.

I've been doing some work on this recently, but it's unfinished and unrefined, but it certainly serves well as a PoC.

@MabezDev
Copy link
Member

MabezDev commented Feb 4, 2025

fugit forces the exclusive choice of u32 or u64. this creates frustrations when wanting to interface with other crates that use usize, or some other int-len.

This PR implements this plan: #2923 (comment) where we've chosen fixed backing types for our implementation, so no need to worry about that here :).

I would recommend something that bases itself more on using the typenum crate, so as to clear out this potential issue.

I'd like to avoid using typenum where possible, slow compile times and too many generics.

@bugadani
Copy link
Contributor Author

bugadani commented Feb 4, 2025

Awhile ago, I ran into this issue, and it's a pain.

What's your use case?

@Ben-PH
Copy link

Ben-PH commented Feb 4, 2025

Use case was ages ago, so I forget the details, but the key issues is that there were incompatable types embedded into const generics, and just made the whole thing messy.

I'd like to avoid using typenum where possible, slow compile times and too many generics.

Noted. What do you plan to do for the cases where the types chosen for the const generics cause headaches?

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MabezDev
Copy link
Member

MabezDev commented Feb 4, 2025

Noted. What do you plan to do for the cases where the types chosen for the const generics cause headaches?

In general, we're trying to avoid generics (even the const kind) in the public API, and instead to the type checking in the constructor then convert the driver to a "concrete" type.

@MabezDev MabezDev added this pull request to the merge queue Feb 4, 2025
Merged via the queue into esp-rs:main with commit 8c69e8c Feb 4, 2025
27 checks passed
@bugadani bugadani deleted the time branch February 4, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A time/rate solution
5 participants