Commit e991b92d authored by Christian Kellner's avatar Christian Kellner
Browse files

Power supply: polling of batteries

parent f7da26f0
......@@ -135,6 +135,8 @@ gbb_battery_constructed(GObject *obj)
voltage_design_initialize(bat);
energy_design_initialize(bat);
gbb_battery_poll(bat);
G_OBJECT_CLASS(gbb_battery_parent_class)->constructed(obj);
}
......@@ -348,3 +350,20 @@ gbb_battery_discover()
g_list_free_full(devices, (GDestroyNotify) g_object_unref);
return supplies;
}
double
gbb_battery_poll(GbbBattery *bat)
{
GUdevDevice *dev = bat->udevice;
double new_value;
if (bat->use_charge) {
new_value = sysfs_read_double_scaled(dev, "charge_now");
new_value *= bat->voltage_desgin;
} else {
new_value = sysfs_read_double_scaled(dev, "energy_now");
}
bat->energy = new_value;
return new_value;
}
......@@ -6,6 +6,6 @@
#define GBB_TYPE_BATTERY gbb_battery_get_type()
G_DECLARE_FINAL_TYPE(GbbBattery, gbb_battery, GBB, BATTERY, GObject)
GList* gbb_battery_discover(void);
GList * gbb_battery_discover (void);
double gbb_battery_poll (GbbBattery *);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment