Module: LitrueBatteryCalc
- Defined in:
- lib/litrue_battery_calc.rb
Class Method Summary collapse
-
.calculate_wh(voltage, amp_hours) ⇒ Object
Calculate Watt-hours from Voltage and Amp-hours.
-
.estimate_runtime(total_wh, load_watts, efficiency = 0.85) ⇒ Object
Estimate battery runtime in hours under continuous load.
Class Method Details
.calculate_wh(voltage, amp_hours) ⇒ Object
Calculate Watt-hours from Voltage and Amp-hours
5 6 7 |
# File 'lib/litrue_battery_calc.rb', line 5 def self.calculate_wh(voltage, amp_hours) voltage.to_f * amp_hours.to_f end |
.estimate_runtime(total_wh, load_watts, efficiency = 0.85) ⇒ Object
Estimate battery runtime in hours under continuous load
10 11 12 13 14 |
# File 'lib/litrue_battery_calc.rb', line 10 def self.estimate_runtime(total_wh, load_watts, efficiency = 0.85) return 0.0 if load_watts.to_f <= 0.0 (total_wh.to_f * efficiency.to_f) / load_watts.to_f end |