Comments (3)
I plan to migrate to const generics when they're ready. That's what I wanted from the start, but had to settle for the associated const. I need to play with some code to understand more fully where the sticking point is. I haven't had a chance to use Rust for some time, so I'm a bit .... wait for it .... rusty :).
Thank you for your interest in the crate and I look forward to working with you to find a solution.
from embedded-time.
Then
fn try_now
should return the current ticks / Instant pretending it being a monotonic timer, and that is its only purpose?
That is correct. In this case to get the current tick value, it's triggering a linked capture and reading the two registers of a concatenated hardware timer on the nRF52.
Knowing the clock at compile time (especially out of the perspective of a library author) is a rare exception.
Setting aside the context of library author for a sec, in my experience, clock speed is always known at compile time. At the very least, it is known what it will be after startup configuration. It's been a while since I've been in Rust, but for a library, can't the user of the library define a const value that is used in the clock implementation?
from embedded-time.
Setting aside the context of library author for a sec, in my experience, clock speed is always known at compile time. At the very least, it is known what it will be after startup configuration. It's been a while since I've been in Rust, but for a library, can't the user of the library define a const value that is used in the clock implementation?
Yeah, this is something I have though about as well. I think the problem right now is, that the SCALING_FACTOR is set via a associated const, which means that only one clock per timer is possible (which might be okay for a user, but is not for a library author). So I guess a better solution could, that the SCALING_FACTOR is parametrized with const generics.
iml<const SCALING_FACTOR: time::fraction::Fraction> time::Clock<SCALING_FACTOR> for SysClock {
// ...
}
But this example, as written above, is not possible, as of the current min-const-generics
implantation. So it might have to be dumped down to compile. So leveraging the fact, that the scaling factor is known at compile time to reduce overhead is definitely a great thing to thrive for, but it lacks flexibility right now (because of lacking const generics features - or because it is not dynamically configurable) to be used in a library.
from embedded-time.
Related Issues (20)
- remove generic Timer struct's State parameter HOT 5
- smarter macros for defining intra-unit conversions HOT 3
- `FixedPoint::integer` is by value, `Generic::integer` is not HOT 4
- New release with the latest update and fixes HOT 4
- [Proposal] std-powered Clock implementation for tests HOT 5
- optimize generic Duration usage
- change other integer-returning functions to return by value rather than reference HOT 1
- add checked_add and checked_sub to FixedPoint
- add multiplication of Rate by Duration types and vice-versa
- add suffix abbreviations to Format implementation
- Duration type conversions are difficult to use in practice HOT 1
- How to get the number of elapsed milliseconds as integer from a clock? HOT 1
- Remaining/Elapsed timer calculation for generic clock HOT 2
- Calculating ratios is awkward and fragile
- Comparison of sub-second duration::Generic is broken
- Test suite assumes that tests run one at a time rather than in parallel
- Async support
- How to get an instance of `Clock`?
- Expose Timer's Expiration Time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embedded-time.