I told you the patch was bad and needed improvement. But the basic idea to get (dis)charge rate from udev is good.
S. Den 7. sep. 2012 kl. 10:01 skrev "Enlightenment SVN" <[email protected]>: > Log: > revert changes from last month to udev backend, seems to have broken things > probably fixes ticket #1304 > > > Author: discomfitor > Date: 2012-09-07 01:01:17 -0700 (Fri, 07 Sep 2012) > New Revision: 76285 > Trac: http://trac.enlightenment.org/e/changeset/76285 > > Modified: > trunk/e/src/modules/battery/e_mod_main.c > trunk/e/src/modules/battery/e_mod_udev.c > > Modified: trunk/e/src/modules/battery/e_mod_main.c > =================================================================== > --- trunk/e/src/modules/battery/e_mod_main.c 2012-09-07 07:44:20 UTC (rev > 76284) > +++ trunk/e/src/modules/battery/e_mod_main.c 2012-09-07 08:01:17 UTC (rev > 76285) > @@ -302,9 +302,10 @@ > int charging = 0; > > int batnum = 0; > + int acnum = 0; > > EINA_LIST_FOREACH(device_ac_adapters, l, ac) > - if (ac->present) have_power++; > + if (ac->present) acnum++; > > EINA_LIST_FOREACH(device_batteries, l, bat) > { > @@ -312,6 +313,7 @@ > continue; > have_battery = 1; > batnum++; > + if (bat->charging == 1) have_power = 1; > if (full == -1) full = 0; > if (bat->percent >= 0) > full += bat->percent; > > Modified: trunk/e/src/modules/battery/e_mod_udev.c > =================================================================== > --- trunk/e/src/modules/battery/e_mod_udev.c 2012-09-07 07:44:20 UTC (rev > 76284) > +++ trunk/e/src/modules/battery/e_mod_udev.c 2012-09-07 08:01:17 UTC (rev > 76285) > @@ -1,17 +1,15 @@ > #include "e.h" > #include "e_mod_main.h" > > -static void _battery_udev_event_battery(const char *syspath, > Eeze_Udev_Event event, void *data, Eeze_Udev_Watch *watch); > -static void _battery_udev_event_ac(const char *syspath, Eeze_Udev_Event > event, void *data, Eeze_Udev_Watch *watch); > -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 void _battery_udev_event_battery(const char *syspath, Eeze_Udev_Event > event, void *data, Eeze_Udev_Watch *watch); > +static void _battery_udev_event_ac(const char *syspath, Eeze_Udev_Event > event, void *data, Eeze_Udev_Watch *watch); > +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); > 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); > +static void _battery_udev_battery_update(const char *syspath, Battery *bat); > +static void _battery_udev_ac_update(const char *syspath, Ac_Adapter *ac); > > extern Eina_List *device_batteries; > extern Eina_List *device_ac_adapters; > @@ -61,9 +59,7 @@ > 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); > } > } > @@ -113,11 +109,9 @@ > } > 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); > -#endif > + bat->poll = ecore_poller_add(ECORE_POLLER_CORE, > + battery_config->poll_interval, > + _battery_udev_battery_update_poll, bat); > device_batteries = eina_list_append(device_batteries, bat); > _battery_udev_battery_update(syspath, bat); > } > @@ -161,9 +155,7 @@ > 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); > } > > @@ -184,8 +176,7 @@ > free(ac); > } > > -#if 0 > -static Eina_Bool > +static Eina_Bool > _battery_udev_battery_update_poll(void *data) > { > _battery_udev_battery_update(NULL, data); > @@ -193,8 +184,6 @@ > return EINA_TRUE; > } > > -#endif > - > #define GET_NUM(TYPE, VALUE, PROP) test = > eeze_udev_syspath_get_property(TYPE->udi, #PROP); \ > do > \ > if (test) > \ > @@ -218,9 +207,7 @@ > 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) /* only need to get these once */ > @@ -237,28 +224,19 @@ > GET_NUM(bat, last_full_charge, POWER_SUPPLY_CHARGE_FULL); > test = eeze_udev_syspath_get_property(bat->udi, "POWER_SUPPLY_ENERGY_NOW"); > if (!test) > - test = eeze_udev_syspath_get_property(bat->udi, > "POWER_SUPPLY_CHARGE_NOW"); > + { > + 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 (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; > - } > + 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) > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > enlightenment-svn mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
