battery_cycles 0.1.0

Count battery discharge cycles using the Full Equivalent Cycle (FEC) method.
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented1 out of 5 items with examples
  • Size
  • Source code size: 7.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 297.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • felixwatts/battery_cycles
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • felixwatts

Battery Cycles

Count battery discharge cycles using the Full Equivalent Cycle (FEC) method.

Usage

use std::time::Duration;
use battery_cycles::BatteryCycleCounter;

let battery_capacity_ah = 10.0;
let initial_cycle_count = 0.0;

let mut battery_cycle_counter = BatteryCycleCounter::new(battery_capacity_ah, initial_cycle_count, None);

// Repeatedly update the BatteryCycleCounter with the current discharge current
for _ in 0..10 {
    // Some time passes
    // The shorter the time between updates the more accurately the cycles will be tracked
    std::thread::sleep(Duration::from_secs_f32(1.0));

    // Measure the current discharge current of your battery somehow
    // a positive number means it's discharging, a negative number means its charging
    let battery_discharge_current_a = 0.42;

    // Repeatedly update the BatteryCycleCounter with the current discharge current
    battery_cycle_counter.update(battery_discharge_current_a, None);
}

// Get the current equivalent cycle count via the `cycle_count` method
let cycle_count = battery_cycle_counter.cycle_count();
println!("The battery has completed {cycle_count} equivalent cycles.");