lowpassns 0.1.1

Lightweight no_std low-pass filters for embedded systems, open source and GPL-protected.
Documentation
  • Coverage
  • 85.71%
    6 out of 7 items documented0 out of 4 items with examples
  • Size
  • Source code size: 25.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 765.68 kB This is the summed size of all files generated by rustdoc for all configured targets
  • ร˜ build duration
  • this release: 52s Average build duration of successful builds.
  • all releases: 39s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jorgeandrecastro/lowpassns
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jorgeandrecastro

lowpassns

License: GPL-2.0-or-later
No Std
Maintenance

Lightweight no_std Low-Pass Filter for Embedded Systems

lowpassns is a small, efficient, and robust first-order low-pass filter crate for no_std Rust environments. Designed for embedded systems like RP2040 or STM32, it smooths sensor readings or signals in real-time while being memory- and CPU-efficient.

GPL-2.0-or-later licensed to ensure open and free usage in both hobbyist and commercial projects.


Table of Contents


๐Ÿš€ Features

  • โœ… Pure no_std: Zero standard library dependencies, perfect for bare-metal and RTOS.
  • โšก Flexible Floating-Point: Default f64, optional f32 feature for memory-constrained devices.
  • ๐Ÿ”ง Lightweight: Minimal stack usage, O(1) per update.
  • ๐Ÿ›ก๏ธ Stable & Safe: Handles zero/negative dt safely, clamps tiny dt for embedded portability.
  • ๐Ÿ“ˆ Smooth Filtering: Simple first-order low-pass behavior for sensor smoothing or signal conditioning.
  • โ›‘๏ธ Resettable State: Filter value can be reset at any time.

๐Ÿ› ๏ธ Installation

Add to your Cargo.toml:

[dependencies]
lowpassns = { git = "https://github.com/jorgeandrecastro/lowpassns.git" }


Enable f32 for constrained MCUs:

lowpassns = { git = "https://github.com/jorgeandrecastro/lowpassns.git", features = ["f32"] }

Build with optimizations:

cargo build --release

๐Ÿš€ Quickstart
use lowpassns::LowPass1;

fn main() {
    // Initial value = 0.0, time constant ฯ„ = 0.1 s
    let mut filter = LowPass1::new(0.0, 0.1);

    let dt = 0.01; // 10 ms timestep

    for i in 0..100 {
        let input = 1.0; // example sensor input
        let output = filter.update(input, dt);
        // output smoothly approaches input
    }

    filter.reset(0.0); // Reset the filter state
}
๐Ÿ“š API Reference
| Method   | Signature                                             | Description                              |
| -------- | ----------------------------------------------------- | ---------------------------------------- |
| `new`    | `LowPass1::new(initial: Float, tau: Float)`           | Creates a new low-pass filter.           |
| `update` | `update(&mut self, input: Float, dt: Float) -> Float` | Updates the filter state for a timestep. |
| `reset`  | `reset(&mut self, value: Float)`                      | Resets the filter state.                 |


Type Float = f64 (default) or f32 via feature flag.

โšก Performance & Optimization
Minimal binary size
CPU cost: constant time O(1) per update
Stack-only, zero allocations
Ideal for 100 Hz โ€“ 10 kHz control loops on MCUs
๐Ÿงช Testing

Includes tests for:

Step response stability
Zero/negative dt handling
Reset functionality

Run:

cargo test -- --nocapture
โš–๏ธ License

GPL-2.0-or-later ยฉ 2026 Jorge Andre Castro.

Free to use, modify, and distribute. Any derivative works must also be GPL-2.0-or-later.