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

Authored by jjorge on Mar 18 2020, 2:41 PM.

Details

Summary

Depending on hardware, Linux kernel exports battery state in
different files. Previously only charge_now, charge_full and current_now
were available in ksysguard. With this commit all are selectable.

While we have now screens with more than 1000 pixels height,
a percentage with 100 steps will show a ladder. This commit also
make the created graphs nicer by giving 1000 steps.

Diff Detail

Repository
R106 KSysguard
Branch
AddSysBatteryInfo (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 23873
Build 23891: arc lint + arc unit
jjorge created this revision.Mar 18 2020, 2:41 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 18 2020, 2:41 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
jjorge requested review of this revision.Mar 18 2020, 2:41 PM

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.

ksysguardd/Linux/acpi.c
82

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

163

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.)

ahiemstra requested changes to this revision.Apr 1 2020, 6:29 PM
This revision now requires changes to proceed.Apr 1 2020, 6:29 PM
jjorge updated this revision to Diff 79321.Apr 4 2020, 4:36 PM
  • Follow ahiemstra suggestions :
    • cast to float directly
    • move 2 repeated lines to initAcpiBattery
ahiemstra added inline comments.Apr 6 2020, 12:59 PM
ksysguardd/Linux/acpi.c
103

Uhm, this should be const char *name right? I don't really see how this can work otherwise.

jjorge updated this revision to Diff 79629.Apr 8 2020, 8:53 AM
  • fix pointer
jjorge added a comment.Apr 8 2020, 8:54 AM

Hem, you are right, I missed it because I was testing old binary.

anthonyfieroni added inline comments.
ksysguardd/Linux/acpi.c
163

(float)(var_int/var_int) does not what you want, it should be ((float)var_int / var_int)

195

ditto

227

ditto

259

ditto

jjorge updated this revision to Diff 79653.Apr 8 2020, 4:33 PM
  • Oops fix bad named functions
jjorge updated this revision to Diff 79655.Apr 8 2020, 4:41 PM

I should learn to better use arc...

  • typo
jjorge updated this revision to Diff 79665.Apr 8 2020, 6:56 PM
  • A better cast to float

I have finished my corrections. Is it nice now? Thanks.

ahiemstra accepted this revision.Apr 14 2020, 9:23 AM

Seems fine to me now. You didn't have a developer account right?

This revision is now accepted and ready to land.Apr 14 2020, 9:23 AM

Seems fine to me now. You didn't have a developer account right?

Yes, I don't.

This revision was automatically updated to reflect the committed changes.

I've landed this for you.

Keep up the great work!