3

I am fond of making a program which will be used for laptops in order to keep a max charging threshold for the battery. It is well known that preventing laptop battery from getting to the maximum or lowest level increases life of the battery. Is there some API that can collaborate with and at first get the battery % level and later if this level is >= from a set level to close the connection with the battery and use AC only?

Thanks in advance.

bokarinho
  • 193
  • 1
  • 1
  • 6

1 Answers1

1

As far as I know there is no single API you could use for all latops. There are such utilities / undocumented APIs for Lenovo ThinkPad laptops for example.

What you would have to do is collect enough of those undocumented / unsupported APIs from multiple vendors and pack them with your application.

Here is the ThinkPad specific one TP_SMAPI. It is open source too: github.com/evgeni/tp_smapi so you could see how to communicate with the firmware on the battery if you look through the source. This is an example of how it's used from terminal while installed:

$ echo 40 | sudo tee /sys/devices/platform/smapi/BAT0/start_charge_thresh
$ echo 80 | sudo tee /sys/devices/platform/smapi/BAT0/stop_charge_thresh

For windows there are already applications for exactly that, usually by your laptop vendor.

nana
  • 4,426
  • 1
  • 34
  • 48