To further clarify what Kerm was saying, this is what you should run to compile it:
Code:
gcc -lm battery.c -o battery.o
_player1537 wrote:
To further clarify what Kerm was saying, this is what you should run to compile it:
Code:
gcc -lm battery.c -o battery.o
That's correct. Thank you for the point of clarification, Tanner.
Oh sorry I retried it:


Code:
Battery is currently charging.
Battery charge level is 9.658778%.
Remainging 0:8


Linux tells me it's 7.7% and 1hour 20 minutes left.

I only have 1 battery and am indeed charging.

2% is not bad, it's actually very good (or maybe what Linux tells me is wrong) Smile I just don't get the "0:8".
Well iirc he is reading the values from sysfs, so the program may be reading it differently or Kerm's program has a bug.
This program reads directly from the ACPI measurement data. The official Linux tool runs in the background, and can estimate the rate more accurately, since it keeps track of historical data. I find that on my laptop the two tools estimate very close to each other, though.
Well, but about "0:8", what does it mean? 0hours 8 minutes?
ScoutDavid wrote:
Well, but about "0:8", what does it mean? 0hours 8 minutes?
That's correct. If you want to build and improve on this, I would welcome it! You could start by changing the minutes display to %02d, which would make the minutes look like "32" or "08".
hello sir, i am now working on battery status and stuck with the output. Can you plese review this and tell me whats wrong and what correction to be done
i have used the paths as below and the output i am getting is :

#define PATH_BATT_STATE "/sys/class/power_supply/BAT1/status"
#define PATH_BATT_INFO "/sys/class/power_supply/BAT1/type"
#define BATT_READ_BUFLEN 256

Output:
Battery is currently charging.
Battery charge level is -nan%.
Remainging 0:0
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement