-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
battery block: fallback for determining power consumption #653
Conversation
One thing I'm not sure about is how these changes affect this block: let status = self.status()?;
match status.as_str() {
"Full" => Ok(((full as f64 / usage) * 60.0) as u64),
"Discharging" => Ok(((fill / usage) * 60.0) as u64),
"Charging" => Ok((((full as f64 - fill) / usage) * 60.0) as u64),
_ => {
// TODO: What should we return in this case? It seems that under
// some conditions sysfs will return 0 for some readings (energy
// or power), so perhaps the most natural thing to do is emulate
// that.
Ok(0)
}
} Since it seems that depending on the context, |
Will test in ~4-5 hrs |
Oh wait - i remember writing that part of the code now, i added it via #214 exactly because my system doesn't have The idea was that Meaning, to be clear: if the device driver uses the combination of It works out anyways because in all 3 equations in the cited code block the units cancel out and we're left with a time value. So, in conclusion, your changes in With With Firstly, the sysfs value is apparently in μW and needs to be adjusted for that. Secondly, the timer doesn't work. When removing all changes to |
Seems like power is returned in μW, while the value is normally returned in W. Also the battery status reports |
Are you using the sysfs driver? |
Hey @travankor i revised my original test because i missed a couple of things. I usually use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added my suggestions as reviews, feel free to adjust to your liking. This github review thing seems to be fighting me, it's weird
Co-authored-by: Oskar <okkathe97th@gmail.com>
Co-authored-by: Oskar <okkathe97th@gmail.com>
OK so I believe it should be good to go now. @travankor Can you please test again? |
FYI, works fine on my end now. |
Thanks! |
Resolves #429 by implementing the simple approach mentioned here: #429 (comment). This could be worked on in the future for better hysteresis.
I don't have a battery operated device to test with at the moment so would appreciate if @travankor, @GladOSkar could check this out if they have time.