Wrong conversion for mAh to mWh
Richard Hughes
hughsient at gmail.com
Tue May 2 12:39:54 PDT 2006
in hald/linux/acpi.c:
...
if (reporting_unit && strcmp (reporting_unit, "mAh") == 0) {
voltage_design = hal_device_property_get_int (d,
"battery.voltage.design");
/* If design voltage is unknown, use 1mV. */
if (voltage_design <= 0)
voltage_design = 1;
/* scale by factor battery.voltage.design */
hal_device_property_set_int (d, "battery.charge_level.design",
reporting_design * voltage_design);
hal_device_property_set_int (d, "battery.charge_level.warning",
reporting_warning * voltage_design);
hal_device_property_set_int (d, "battery.charge_level.low",
reporting_low * voltage_design);
hal_device_property_set_int (d, "battery.charge_level.granularity_1",
reporting_gran1 * voltage_design);
hal_device_property_set_int (d, "battery.charge_level.granularity_2",
reporting_gran2 * voltage_design);
/* set unit */
hal_device_property_set_string (d, "battery.charge_level.unit",
"mWh"); /* not mAh! */
}
this is wrong IMO.
You have battery.voltage.design in mV (11100)
You have battery.reporting.rate in mAh (2187)
We are currently multiplying to give:
mWh = mAh * mV
when we should be doing:
mWh = mAh * ( mV / 1000)
Is this sane or have I been revising too hard?
There's some more details here, showing a laptop consuming nearly 30kW of power!
http://bugzilla.gnome.org/show_bug.cgi?id=340403
Richard.
More information about the hal
mailing list