Converting battery status to int (C++)

Hey all
i am trying to take the battery status, convert it into an int (possibly by trimming the output and parsing the percentile) and then displaying it in my C++ application. The problem i have is i cant seem to figure out how to read the battery state within haiku. does any one know of any ‘acpi’ type commands available in haiku or where the battery status applet gets its data from even.

Any help would be greatly appreciated!

The low level stuff its done here:

The ioctrl interface might not be stable (is not a public api), so you probably want to use this interface:

Thats for the info, but by the looks of it i will have to compile my applications along side Haiku itself and include the power status headers and so on, i wish there was an interface i could just access from the shell and then pump the data back to my application for processing.

If thats the only way so be it but compiling Haiku every time i make a change to my app might get a little tedious hahah

Thanks for the help :slight_smile:

Why not write a simple app or device driver that will supply the needed info continuously? The code in zero.c in the Haiku trunk should make it easy to get started.

Ah thats a good idea, if an interface isn’t available i can just create my own, thanks ill give it a whirl

Please don’t do it too much continuously. Calling too much often an ACPI object or method will hit performance, as it could involve trigger then wait for an interrupt. And in the case of ACPI battery status, it will.

So, please, cache last battery status and refresh it at a low frequency, around few Hz only.