use danwi::f64::{
QuantityExt,
constants::{V, W, mA, mV, mW},
types::Volt,
};
fn adc_counts_to_voltage(count: u16) -> Volt {
let v_ref = 3.3.V();
v_ref * (count as f64 / 4096.0)
}
fn main() {
let v = adc_counts_to_voltage(2048);
println!("{:.3}", v.display_as(V)); println!("{:.3}", v.display_as(mV));
let shunt = 0.1.Ohm();
let i = 50.0.mV() / shunt;
println!("{:.3}", i.display_as(mA));
let dissipation = i * i * shunt;
println!("{:.3}", dissipation.display_as(mW));
let p = 12.0.V() * 0.5.A();
println!("{:.3}", p.display_as(W));
let v_in = 5.0.V();
let r_top = 2.2.kOhm();
let r_bottom = 3.3.kOhm();
let v_out = v_in * (r_bottom / (r_top + r_bottom));
println!("{:.3}", v_out.display_as(V)); }