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

fix: multiple batteries support in the battery module #669

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

lucarin91
Copy link
Contributor

Description

I update the battery module, in order to implement an aggregating view of all the batteries present in the notebook.
The percentage of the battery is calculated with a weighted average of the energy of all the batteries. Instead, the battery state is calculated with the following rule:

  • Charging if at least one is Charging
  • Discharging if at least one is Discharging
  • Full if all are Full
  • Empty if all are Empty
  • Unknown otherwise

Motivation and Context

As stated in issue #656 if there are multiple batteries in the notebook the battery module gives inconsistent values of the battery percentage and state.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Screenshots (if appropriate):

How Has This Been Tested?

I test it on my Lenovo T450s that has two batteries. For now, there is not any unit test on the battery module.

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

Copy link
Member

@matchai matchai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @lucarin91!
Just a few comments before we can get this merged in. 😊

src/modules/battery.rs Show resolved Hide resolved
src/modules/battery.rs Outdated Show resolved Hide resolved
src/modules/battery.rs Show resolved Hide resolved
src/modules/battery.rs Outdated Show resolved Hide resolved
@lucarin91 lucarin91 requested a review from matchai December 3, 2019 10:20
@matchai matchai changed the title fix: multiple batteries support in the battery module (issue #656) fix: multiple batteries support in the battery module Dec 3, 2019
@matchai matchai merged commit 1558b22 into starship:master Dec 3, 2019
@matchai
Copy link
Member

matchai commented Dec 3, 2019

Thank you for your contribution, Luca! 😄

@all-contributors Please add @lucarin91 for code. 🎉

@allcontributors
Copy link
Contributor

@matchai

I've put up a pull request to add @lucarin91! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants