D28127: Add some new battery sensors : energy_now, energy_full and power_now.

Arjen Hiemstra noreply at phabricator.kde.org
Wed Apr 1 19:29:22 BST 2020


ahiemstra added a comment.


  Good stuff. Just two small comments.
  
  Additionally, you may be interested in https://phabricator.kde.org/D28333 , which will eventually replace ksysguardd and has a better API for sensors.

INLINE COMMENTS

> acpi.c:82
> +    char name[ ACPIFILENAMELENGTHMAX ];
> +    readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name));
> +

These two lines are now repeated in all "registerX" functions. Maybe move this to initAcpiBattery and pass it to each function as a parameter?

> acpi.c:163
>      if ( maximum > 0) {
> -        state = charge * 100 / maximum;
> +        state = charge/(double)(maximum/100);/* to get 0.1% changes */
>      }

You cast to double but then store it in a float, which implies a cast to float. Probably better to just cast to float directly. (Also applies to the functions below.)

REPOSITORY
  R106 KSysguard

REVISION DETAIL
  https://phabricator.kde.org/D28127

To: jjorge, #plasma, davidedmundson, ahiemstra
Cc: plasma-devel, Orage, LeGast00n, The-Feren-OS-Dev, cblack, jraleigh, zachus, fbampaloukas, GB_2, ragreen, ZrenBot, ngraham, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, ahiemstra, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20200401/62c3f514/attachment-0001.html>


More information about the Plasma-devel mailing list