Skip to content
/ fugit Public

`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

korken89/fugit

Repository files navigation

fugit

crates.io docs.rs Build

A no_std time library for embedded systems that does as much as possible at compile time. Heavily inspired by C++ std::chrono.

Overview

fugit provides Duration, Instant, and Rate types for handling time in embedded applications. The library is designed around concrete types rather than traits, which allows extensive use of const fn and compile-time optimization.

When you add or compare durations with different time bases, the library generates all the necessary conversion constants at compile time. This means operations like adding milliseconds to microseconds can often happen without any runtime division, just a simple addition with a compile-time calculated multiplier.

The library supports both u32 and u64 backing storage with careful attention to code generation on embedded targets. On ARM Cortex-M3 and newer, most operations avoid pulling in soft implementations for division. Comparisons between different time bases use multiplication rather than division, and the constants are all calculated at compile time.

Extension traits provide convenient shorthand methods. Instead of manually creating Duration::<u32, 1, 1000>::from_ticks(100), you can just write 100.millis(). The methods .millis(), .secs(), .Hz(), .kHz(), and others make the code cleaner while maintaining the same performance characteristics.

Use Cases

The library is particularly well-suited for embedded HAL implementations, RTIC applications, and any embedded system where you need to work with timeouts, delays, or periodic operations. The compile-time optimization means you get readable code without sacrificing the tight instruction counts needed on microcontrollers.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

About

`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages