-
Notifications
You must be signed in to change notification settings - Fork 90
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 80% battery charge limit for Legion Go #1074
Conversation
WalkthroughThe recent changes introduce a new feature to set a battery charge limit for Lenovo Legion devices within the HandheldCompanion application. This involves adding a new setting, UI components, and methods to handle the battery charge limit functionality. Additionally, a new name "PlasmidEve" was added to the AboutPage. Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant DevicePage
participant LegionGo
participant SettingsManager
User ->> DevicePage: Toggle Battery Charge Limit
DevicePage ->> SettingsManager: Update Setting (LegionBatteryChargeLimit)
SettingsManager ->> LegionGo: Notify Setting Changed
LegionGo ->> LegionGo: UpdateSettings()
LegionGo ->> LegionGo: SetBatteryChargeLimit(enabled)
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- HandheldCompanion/App.config (1 hunks)
- HandheldCompanion/Devices/Lenovo/LegionGo.cs (3 hunks)
- HandheldCompanion/Properties/Resources.Designer.cs (1 hunks)
- HandheldCompanion/Properties/Resources.resx (1 hunks)
- HandheldCompanion/Properties/Settings.Designer.cs (1 hunks)
- HandheldCompanion/Properties/Settings.settings (1 hunks)
- HandheldCompanion/Views/Pages/AboutPage.xaml (1 hunks)
- HandheldCompanion/Views/Pages/DevicePage.xaml (1 hunks)
- HandheldCompanion/Views/Pages/DevicePage.xaml.cs (1 hunks)
Files skipped from review due to trivial changes (2)
- HandheldCompanion/App.config
- HandheldCompanion/Properties/Resources.resx
Additional comments not posted (9)
HandheldCompanion/Properties/Settings.settings (1)
275-277
: The addition of theLegionBatteryChargeLimit
setting is correctly implemented with the appropriate default value.HandheldCompanion/Views/Pages/AboutPage.xaml (1)
196-196
: The addition of "PlasmidEve" to the contributors list accurately reflects their contribution to the project.HandheldCompanion/Devices/Lenovo/LegionGo.cs (2)
100-110
: The implementation of theSetBatteryChargeLimit
method correctly utilizes theCapabilityID.InstantBootAc
to control the 80% battery charge limit. The reference to the LegionGoRemapper project provides a good context for this implementation.
446-459
: TheUpdateSettings
method and theSettingsManager_SettingValueChanged
event handler are correctly implemented to handle the newLegionBatteryChargeLimit
setting. This ensures that the setting is dynamically applied based on user preferences.HandheldCompanion/Views/Pages/DevicePage.xaml.cs (1)
508-514
: Proper implementation of the battery charge limit toggle.Verification successful
The integration of the
LegionBatteryChargeLimit
setting appears to be properly handled in the codebase. The setting is referenced in multiple relevant files, includingSettings.Designer.cs
,Resources.Designer.cs
, andLegionGo.cs
, indicating that it is correctly managed and utilized.
HandheldCompanion/Views/Pages/DevicePage.xaml.cs
: The toggle method updates the setting.HandheldCompanion/Properties/Settings.Designer.cs
: The setting is defined and accessed.HandheldCompanion/Properties/Resources.Designer.cs
: The setting's resources are defined.HandheldCompanion/Devices/Lenovo/LegionGo.cs
: The setting is used to set the battery charge limit.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of the `LegionBatteryChargeLimit` setting with the SettingsManager. # Test: Search for the usage of `LegionBatteryChargeLimit` in the settings manager. Expect: Proper handling and updates. rg --type csharp $'LegionBatteryChargeLimit' --exec cat {}Length of output: 468
Script:
#!/bin/bash # Description: Verify the integration of the `LegionBatteryChargeLimit` setting with the SettingsManager. # Test: Search for the usage of `LegionBatteryChargeLimit` in the settings manager. Expect: Proper handling and updates. rg --type csharp 'LegionBatteryChargeLimit'Length of output: 1455
HandheldCompanion/Properties/Settings.Designer.cs (1)
1107-1120
: Correct definition of theLegionBatteryChargeLimit
setting.HandheldCompanion/Views/Pages/DevicePage.xaml (1)
865-901
: The implementation of the battery charge limit toggle in the UI appears correct and well-integrated within the existing structure.HandheldCompanion/Properties/Resources.Designer.cs (2)
1072-1079
: LGTM! The property for the battery charge limit label is well implemented.
1081-1088
: LGTM! The property for the battery charge limit description is well implemented.
not needed, SettingsManager will iterate through all settings on startup anyway
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- HandheldCompanion/Devices/Lenovo/LegionGo.cs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- HandheldCompanion/Devices/Lenovo/LegionGo.cs
Good job, merged |
* Add 80% battery charge limit for Legion Go * removed UpdateSettings() not needed, SettingsManager will iterate through all settings on startup anyway --------- Co-authored-by: Lesueur Benjamin <[email protected]>
Adds 80% battery charge limit toggle for the Legion Go.
Initially, I was trying to do this through a function located in the SapientiaUSB.dll but I was unable to find anything of use. I did however find out through another project (LegionGoRemapper) that 0x03010001 handles the enabling or disabling of the 80% battery charge limit.
If there is an alternative way of doing this that makes more sense, please let me know!
Summary by CodeRabbit
New Features
UI Enhancements
Acknowledgements