Code Monkey home page Code Monkey logo

Comments (5)

milux avatar milux commented on August 23, 2024

Have you been able to actually verify the ability of one of your devices to change the charging rate according to control file changes?
If yes, please provide more detailed information!
This could be very interesting for a future major version, but without actual experimental results I don't expect devices out there to actually support software-defined charging rates.
Greez!

from batterychargelimit.

tim-seoss avatar tim-seoss commented on August 23, 2024

The S4 i9505 (jfltexx) has kernel support for this:

/sys/devices/platform/sec-battery/power_supply/battery/siop_level

is a writable file which can be used to set the battery charge rate as a percentage of the normal rate, this is limited to a lower bound of the USB charging rate (about 0.5 amps).

https://github.com/LineageOS/android_kernel_samsung_jf/blob/9198bbe3ef238660b18edeb4dec3790f7df06f3a/drivers/battery/sec_battery.c#L2280

https://github.com/LineageOS/android_kernel_samsung_jf/blob/9198bbe3ef238660b18edeb4dec3790f7df06f3a/drivers/battery/max77693_charger.c#L805

I've verified this with a power supply which has a built-in meter - I could control the charge current between 1.2A and 0.5A by echoing integers to siop_level

The i9505 jfltexx (i9505) also has the ability to stop charging in software:

https://github.com/LineageOS/android_kernel_samsung_jf/blob/9198bbe3ef238660b18edeb4dec3790f7df06f3a/drivers/battery/sec_battery.c#L1077

# Cease charge:
echo 1 > /sys/devices/platform/sec-battery/power_supply/battery/test_mode

# Resume charge (and leave "test mode"):
echo 2 > /sys/devices/platform/sec-battery/power_supply/battery/test_mode

The above may also be true for the Galaxy S3 which uses the same charge control chip (or at least the kernel could be patched to use the S4 code I suppose if-not).

More generally, for other devices, I suppose it would be possible to limit battery temperature (e.g. only charge when temp within user-defined limits).

For devices which don't have an equiv of siop_level, you could do a basic PWM (e.g. charge for 1 second, off for 3 seconds for 25% duty), which would also AFAIK be easier on the battery than just flat-out charging...

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Nice, I own an I9505 jfltexx running on Lineage 14.1 that I use for experiments.
Thanks for your help!
I will try to reproduce this and do some experiments, as soon as my time allows it

As this is a completely new thing, please don't expect this feature to become available quickly, it will take its time...

Regarding the temperature idea: How do we handle the case that the phone is too warm (maybe it slipped under my pillow while I was sleeping), but I want to have my phone charged on the next day no matter what? 😉

Regarding your PWM idea: This came to my mind as well. And in theory, it's a nice idea. However, in practice things like the reaction time of the device are so unreliable that we would need to do something like "1 minute charging - 3 minutes idle" for a reliable 25% duty. Changing the state within seconds might result in unpredictable outcome.
In this case, however, I don't see any real benefit for the battery. The "real" PWM idea is to use signals with very high frequency. I think that any reliable frequency is too low to improve battery life. Therefore I abandoned this idea.

from batterychargelimit.

ltwiz avatar ltwiz commented on August 23, 2024

/sys/class/power_supply/battery/voltage_max is the voltage limit file for Pixel 2 XL (and I believe other Google/Pixel devices). Interestingly this has the contents format '4400000' as opposed to some other devices simply having '4200'.

The current battery voltage can be read from /sys/class/power_supply/battery/voltage_now

Setting this limit has the benefit of battery/status automatically detecting/setting "Full" charge state (even if percentage isn't 100) and automatically toggling charge_disable to 1 - confirmed to run my device off USB power when the specified voltage threshold is reached.

from batterychargelimit.

Donzi84 avatar Donzi84 commented on August 23, 2024

Hi,

I need help to understand what I have to do to block charging at 80% on a samsung tab 4

https://github.com/GalaxyTab4/android_kernel_samsung_millet/blob/millet/drivers/battery/sec_battery.c

this is the kernel link

Thank you all in advance.
Stefano

from batterychargelimit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.