Skip to content
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

Add support for power_now #2099

Merged
merged 2 commits into from
Dec 3, 2024
Merged

Conversation

shuber2
Copy link
Contributor

@shuber2 shuber2 commented Dec 2, 2024

Checklist

  • I have described the changes
  • I have linked to any relevant GitHub issues, if applicable
  • Documentation in doc/ has been updated
  • All new code is licensed under GPLv3

Description

  • Describe the changes, why they were necessary, etc
  • Describe how the changes will affect existing behaviour.
  • Describe how you tested and validated your changes.
  • Include any relevant screenshots/evidence demonstrating that the changes work and have been tested.

The C language defines long to be at least 32 bit and so on ILP32 data
models like Win32 and 32-bit Unix systems. It therefore will overflow
for values of the order of 1e12, which we obtain as a multiplication
result in get_battery_power_draw().

Fix this by an early conversion to double.
Not all systems report current_now through the power supply sysfs
interface, but some do report power_now instead. Add support for these,
too.

The new implementation first tries power_now and then falls back to
computing power as the product of current and voltage. The new
implementation also reduces memory footprint on the stack by some 512k.
Also the old implementation potentially left files open under some
circumstances.
Copy link

netlify bot commented Dec 2, 2024

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit f575f8b
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/674e0d8e1a2d970008cf5e4b

@github-actions github-actions bot added the sources PR modifies project sources label Dec 2, 2024
@brndnmtthws brndnmtthws merged commit d024721 into brndnmtthws:main Dec 3, 2024
38 checks passed
@brndnmtthws brndnmtthws added the feature suggest addition of new functionality that isn't currently supported in any way label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature suggest addition of new functionality that isn't currently supported in any way sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants