I would like to make a program that gives the user the option to stop charging at a battery level of 80% (or any other configurable percentage).
I was under the impression that I could do this by setting the power management ChargeInhibit flag to 1 using IOPMAssertionCreateWithName (from the IOKit library). Setting this flag is no problem (pmset shows that it is enabled by my test application), but the system seems to simply ignore this and still continues charging to the full 100%...
The part in my code that is related to my question is as follows.
So any ideas on how this can be done?
The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
I was under the impression that I could do this by setting the power management ChargeInhibit flag to 1 using IOPMAssertionCreateWithName (from the IOKit library). Setting this flag is no problem (pmset shows that it is enabled by my test application), but the system seems to simply ignore this and still continues charging to the full 100%...
The part in my code that is related to my question is as follows.
Code:
#define kIOPMAssertionTypeInhibitCharging CFSTR("ChargeInhibit")
#define kIOPMChargeInhibitAssertion kIOPMAssertionTypeInhibitCharging
IOPMAssertionID assertionID;
IOPMAssertionCreateWithName(kIOPMChargeInhibitAssertion, kIOPMAssertionLevelOn, kIOPMAssertionTypeInhibitCharging, &assertionID);
So any ideas on how this can be done?
The reason for doing this is that battery wearing will be reduced to a very low level if you always keep it charged somewhere between 40 and 80% while at the same time discharging and charging it a bit every day to keep the electrons moving. I mostly use my system on battery power while commuting, and at home for a few hours now and then, but I think if I could automate not charging beyond 80% I would almost always keep an optimal charge at no cost at all. If, on the other hand, your Li-ion batteries are at a 100% charge a large part of the time, they will slowly deplete over time even when you never deep discharge it. Particularly as I quite often use my computer for statistical analyses: it is bad for Li-ion batteries to get hot when fully charged.
Last edited: