forked from enlightenment/enlightenment
add testing patch from seb (sdATtango.flipp.net) to improve udev battery monitoring; report any bugs to trac
SVN revision: 74921
This commit is contained in:
parent
21df8f0a2f
commit
10ec75e35a
|
@ -7,7 +7,9 @@ static void _battery_udev_battery_add(const char *syspath);
|
|||
static void _battery_udev_ac_add(const char *syspath);
|
||||
static void _battery_udev_battery_del(const char *syspath);
|
||||
static void _battery_udev_ac_del(const char *syspath);
|
||||
#if 0
|
||||
static Eina_Bool _battery_udev_battery_update_poll(void *data);
|
||||
#endif
|
||||
static void _battery_udev_battery_update(const char *syspath, Battery *bat);
|
||||
static void _battery_udev_ac_update(const char *syspath, Ac_Adapter *ac);
|
||||
|
||||
|
@ -59,7 +61,9 @@ _battery_udev_stop(void)
|
|||
eina_stringshare_del(bat->technology);
|
||||
eina_stringshare_del(bat->model);
|
||||
eina_stringshare_del(bat->vendor);
|
||||
#if 0
|
||||
ecore_poller_del(bat->poll);
|
||||
#endif
|
||||
free(bat);
|
||||
}
|
||||
}
|
||||
|
@ -110,9 +114,11 @@ _battery_udev_battery_add(const char *syspath)
|
|||
}
|
||||
bat->last_update = ecore_time_get();
|
||||
bat->udi = eina_stringshare_add(syspath);
|
||||
#if 0
|
||||
bat->poll = ecore_poller_add(ECORE_POLLER_CORE,
|
||||
battery_config->poll_interval,
|
||||
_battery_udev_battery_update_poll, bat);
|
||||
battery_config->poll_interval,
|
||||
_battery_udev_battery_update_poll, bat);
|
||||
#endif
|
||||
device_batteries = eina_list_append(device_batteries, bat);
|
||||
_battery_udev_battery_update(syspath, bat);
|
||||
}
|
||||
|
@ -156,7 +162,9 @@ _battery_udev_battery_del(const char *syspath)
|
|||
eina_stringshare_del(bat->technology);
|
||||
eina_stringshare_del(bat->model);
|
||||
eina_stringshare_del(bat->vendor);
|
||||
#if 0
|
||||
ecore_poller_del(bat->poll);
|
||||
#endif
|
||||
free(bat);
|
||||
}
|
||||
|
||||
|
@ -177,6 +185,7 @@ _battery_udev_ac_del(const char *syspath)
|
|||
free(ac);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static Eina_Bool
|
||||
_battery_udev_battery_update_poll(void *data)
|
||||
{
|
||||
|
@ -184,6 +193,7 @@ _battery_udev_battery_update_poll(void *data)
|
|||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define GET_NUM(TYPE, VALUE, PROP) test = eeze_udev_syspath_get_property(TYPE->udi, #PROP); \
|
||||
do \
|
||||
|
@ -207,7 +217,9 @@ _battery_udev_battery_update(const char *syspath, Battery *bat)
|
|||
return _battery_udev_battery_add(syspath);
|
||||
}
|
||||
/* update the poller interval */
|
||||
#if 0
|
||||
ecore_poller_poller_interval_set(bat->poll, battery_config->poll_interval);
|
||||
#endif
|
||||
|
||||
GET_NUM(bat, present, POWER_SUPPLY_PRESENT);
|
||||
if (!bat->got_prop)
|
||||
|
@ -225,18 +237,30 @@ _battery_udev_battery_update(const char *syspath, Battery *bat)
|
|||
test = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_ENERGY_NOW");
|
||||
if (!test)
|
||||
{
|
||||
eina_stringshare_del(test);
|
||||
eina_stringshare_del(test);
|
||||
test = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_CHARGE_NOW");
|
||||
}
|
||||
if (test)
|
||||
{
|
||||
const char *rate;
|
||||
|
||||
rate = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_POWER_NOW");
|
||||
if (!rate)
|
||||
rate = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_CURRENT_NOW");
|
||||
|
||||
charge = strtod(test, NULL);
|
||||
eina_stringshare_del(test);
|
||||
t = ecore_time_get();
|
||||
if ((bat->got_prop) && (charge != bat->current_charge))
|
||||
bat->charge_rate = ((charge - bat->current_charge) / (t - bat->last_update));
|
||||
bat->last_update = t;
|
||||
if (rate)
|
||||
{
|
||||
bat->charge_rate = -strtod(rate, NULL) / 3600.0;
|
||||
eina_stringshare_del(rate);
|
||||
}
|
||||
else if ((bat->got_prop) && (charge != bat->current_charge))
|
||||
{
|
||||
bat->charge_rate = ((charge - bat->current_charge) / (t - bat->last_update));
|
||||
bat->last_update = t;
|
||||
}
|
||||
bat->current_charge = charge;
|
||||
bat->percent = 100 * (bat->current_charge / bat->last_full_charge);
|
||||
if (bat->got_prop)
|
||||
|
|
Loading…
Reference in New Issue