Giter Club home page Giter Club logo

Comments (18)

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024 1

Okay, @HarshDobariya79. I will leave it open in case you or someone else wants to pick this up in future.

from bat.

HarshDobariya79 avatar HarshDobariya79 commented on May 25, 2024 1

I implemented this health feature in my fork of this repo, but I think the repos have already diverged quite a bit... https://github.com/pepa65/bat

Ah.. That's bad. Seems like the entire repo has been re-fractored.

from bat.

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024 1

Yes, it seemed overly complex so I did a rewrite.

@pepa65, is that the charge_full_design variable? I have none of those on my device.

from bat.

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024 1

I see. You're right, it probably also depends on the battery model.

from bat.

pepa65 avatar pepa65 commented on May 25, 2024 1

A note about the implementation of @sravan-s: it uses energy_full and energy_full_design. Maybe you have those on your system, @tshakalekholoane ? I now implemented both, so you can try it out (or just merge @sravan-s's work).

from bat.

sravan-s avatar sravan-s commented on May 25, 2024 1

@pepa65 I found something interesting in this doc ->
https://www.kernel.org/doc/Documentation/power/power_supply_class.txt

~ ~ ~ ~ ~ ~ ~  Charge/Energy/Capacity - how to not confuse  ~ ~ ~ ~ ~ ~ ~
~                                                                       ~
~ Because both "charge" (µAh) and "energy" (µWh) represents "capacity"  ~
~ of battery, this class distinguish these terms. Don't mix them!       ~
~                                                                       ~
~ CHARGE_* attributes represents capacity in µAh only.                  ~
~ ENERGY_* attributes represents capacity in µWh only.                  ~
~ CAPACITY attribute represents capacity in *percents*, from 0 to 100.  ~
~                                                                       ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
CHARGE_FULL_DESIGN, CHARGE_EMPTY_DESIGN - design charge values, when
battery considered full/empty.

ENERGY_FULL_DESIGN, ENERGY_EMPTY_DESIGN - same as above but for energy.

And from upower docs ->

 The capacity of the power source expressed as a percentage between 0 and 100.
The capacity of the battery will reduce with age.
A capacity value less than 75% is usually a sign that you should renew your battery.
Typically this value is the same as (full-design / full) * 100.
However, some primitive power sources are not capable reporting capacity and in this
case the capacity property will be unset. 

So, as you said, energy/capacity either should be fine. .If neither exist, we can assume power source have some issue
Yeah, we can try/merge your solution or mine, all good ~

from bat.

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024 1

Hello @tshakalekholoane Thanks for the program ~ I use it on my laptop to set charge threshold

I was looking at battery health too. health is same as capacity, correct? https://upower.freedesktop.org/docs/Device.html#id-1.2.4.8.92

Upower calculates it using energy_full / energy_design https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/up-device-battery.c#L307

main...sravan-s:bat:feat/health This worked for me

Hi @sravan-s. It appears so! Thank you for sharing.

A note about the implementation of @sravan-s: it uses energy_full and energy_full_design. Maybe you have those on your system, @tshakalekholoane ? I now implemented both, so you can try it out (or just merge @sravan-s's work).

@pepa65, I do have those energy_full and energy_full_design but not the others so I will probably go with those. Both implementation look great!

Although I do have a preference for something more minimal so something like what @sravan-s did except with fmt.Sscanf instead of defining a function.

var v, w int
_, err := fmt.Sscanf(mustRead("energy_full"), "%d\n", &v)
// ...

I also like @pepa65's implementation of the calculation, v*100/w, which avoids floating-point arithmetic.

You are both welcome to file a pull requests or I can just do it and credit you both since you did the bulk of the research.

Also, the upower documentation you linked seems to say (full-design / full) * 100 which would be > 1, unless I am missing something?

But either way, thank you all for you contribution!

from bat.

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024

This is interesting. Would you like to help with this, @HarshDobariya79?

from bat.

HarshDobariya79 avatar HarshDobariya79 commented on May 25, 2024

Thank you for the opportunity @tshakalekholoane, I would love to but unfortunately I don't have any experience in GO language.

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

I implemented this health feature in my fork of this repo, but I think the repos have already diverged quite a bit... https://github.com/pepa65/bat

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

This repo has recently been refactored a lot, and since I liked to give a different CLI experience, it's divergent. But the core ideas are exactly the same.

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

I thought health would be charge_full divided by charge_full_design, but if that last one doesn't exist on some ASUS models, than that's sad... Are those /sys entries provided through a module? Perhaps version dependent??

from bat.

tshakalekholoane avatar tshakalekholoane commented on May 25, 2024

I believe so. For ASUS devices the charge threshold seems to be in linux/drivers/platform/x86/asus-wmi.c. The others i.e. charge_full, I am not sure. Maybe in linux/drivers/power/supply depending on the model 🤷.

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

On 5.19.0-43-generic #44~22.04.1-Ubuntu and on 5.15.0-75-generic charge_full_design is exposed here (and perhaps it also depends on the battery model?).
It seems to be in asus-wmi: https://www.spinics.net/lists/platform-driver-x86/msg19387.html and https://www.spinics.net/lists/platform-driver-x86/msg19537.html

from bat.

sravan-s avatar sravan-s commented on May 25, 2024

Hello @tshakalekholoane
Thanks for the program ~ I use it on my laptop to set charge threshold

I was looking at battery health too.
health is same as capacity, correct? https://upower.freedesktop.org/docs/Device.html#id-1.2.4.8.92

Upower calculates it using energy_full / energy_design
https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/up-device-battery.c#L307

main...sravan-s:bat:feat/health
This worked for me

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

Interesting about the Ampere vs. Watt, so yes, don't mix them..! How I have implemented it, they don't, so that's good.
I wonder if that depends on the battery, which are used.

from bat.

sravan-s avatar sravan-s commented on May 25, 2024

@pepa65 Feel free to make PR 😃

from bat.

pepa65 avatar pepa65 commented on May 25, 2024

@sravan-s Don't you already have a ready-to-go implementation? (I guess you don't handle charge_ entries...)

In any case, my fork is too divergent. 🤷🏼‍♂️

from bat.

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.