Battery charge time

Post your questions and help other users.

Moderator: Martin

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Battery charge time

Post by Lucy » 12 Dec 2019 08:21

Lol my thought on discharging formula was wrong but im sure im on the right path

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Battery charge time

Post by Desmanto » 12 Dec 2019 18:16

It is very similar, we only need to change the target point. Charging is toward 100%, while discharging is toward 0%. We only need to change the 100. Take out the 100 - percent part and use if to determine the charging/discharging.

Code: Select all

dif = (if(global_battery_current_flow > 0) 100 else 0) - global_battery_percentage;
chargecheck = dif / 100.0 * 3000 / global_battery_current_flow * 3600000;
global_charge_time_left = getDurationString(chargecheck);
I have actually proof test and create a flow yesterday. It is simple, logging every minute and averaging from last 5. Show the result in widget. My script is far longer than above. It use exactly 1 flow with 1 trigger, 1 condition, 1 action, 1 widget and 1 glovar. :D So far it seems a good estimate based on the current.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Battery charge time

Post by Lucy » 12 Dec 2019 21:55

🤦‍♀️lol im so embarrassed haha.... thanks sweetie

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Battery charge time

Post by Lucy » 12 Dec 2019 22:00

My capacity, current, or every stat is lying to me because none of the formulas give me right output. Charge and discharge bothe give me anywhere from 9days to 26days. Ive checked over batt stats so im not sure whats goin on. But thank you so much for your time and efforts in helping me with this.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Battery charge time

Post by Desmanto » 13 Dec 2019 19:01

Try to use debug dialog and check every variable used in the formula there. Do a manual calculation on several example. I might get it wrong, since your phone has different value than mine. Mine show the current in micro Ampere, so I still have to divided by 1000 to get mA.

After checking the result for 2 days, I am thinking to resurrect my old flow to log the battery all the time. But I have to digress from other flow then.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Battery charge time

Post by Lucy » 14 Dec 2019 02:50

Lol... we all good hunny😊👍
Debug revealed i was using old glovar so i was getting that output. I fixed it and your formula is pretty damn close. I do see what you mean though with all stats taken into account undergoing continuous unpredictable changes due to user, software, hardware, etc. On extensive and prolonged use in apps, etc (especially sensors and any listening services) the average duration becomes unreliable and understandable if ya think about the basics of it! But we knew this and you mentioned it also. All that aside. In general, it works to an accuracy of only up to 30min out of the true duration. And that varies up and down. I had it read to only a 10min difference toward androids stock duration counter. So again... works great for general purposes. You have done absolutely well darling. Thank you.
And a HUGE thank you for your continued support and patience with my many annoying requests. But examples and your feedback and input have enabled a much easier and faster learning curve for me. In hay day, i wrote simple scripts in "dos, j2me, c+ and vbs" but many, many moons ago. Upon your teachings i can now read a lil more than just basic android native code and write simple scripts w/o reference. The way you have graciously been helping me is my way of learning. You are my NO. 1 hero atm😊🤸‍♀️🤹‍♀️🎉🤩 thank you so so so much for hanging in there with me. You have been there every step of the way amd NEVER disappoint in any form or fashion.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Battery charge time

Post by Desmanto » 14 Dec 2019 08:32

I am very happy that I can help and also learn along in the process. :D

You just have to stick to this forum long enough until we encounter some limit (either from Automagic, android or other factor) that we stuck and can't find solution for it. Then you will have the disappointment eventually :lol: Joking aside, feel free to ask again if you got problem, and we will try the best to find the solution. :)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply