Skip to content
This repository was archived by the owner on Jul 24, 2025. It is now read-only.

Add battery min/max discharge rate and wear level#1660

Merged
BartoszCichecki merged 4 commits intoBartoszCichecki:masterfrom
tnt-exe:feat/battery-wear-level-minmax-discharge
Jun 2, 2025
Merged

Add battery min/max discharge rate and wear level#1660
BartoszCichecki merged 4 commits intoBartoszCichecki:masterfrom
tnt-exe:feat/battery-wear-level-minmax-discharge

Conversation

@tnt-exe
Copy link
Contributor

@tnt-exe tnt-exe commented May 24, 2025

Added features:

  • Battery wear level, min and max discharge rate.
  • Updates the BatteryInformation struct and logic to track and display these new metrics.
  • Modifies the UI (BatteryPage.xaml, StatusWindow) to show minimum/maximum discharge rates and wear level.
  • Add localization for Vietnamese.

image
image

Personally, I do monitor battery when off the wall a lots, so these changes would save me few steps from calculating them on my own.

if (Math.Abs(status.Rate) > Math.Abs(MaxDischargeRate))
MaxDischargeRate = status.Rate;

if (status.Rate == 0)
Copy link
Contributor

@Ace-Radom Ace-Radom May 24, 2025

Choose a reason for hiding this comment

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

When the machine isn't charging: which means, status.Rate == 0, calculating min rate & max rate shouldn't be necessary. I think the order here should be changed, although it won't break anything.

Copy link
Contributor

@Ace-Radom Ace-Radom left a comment

Choose a reason for hiding this comment

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

One tiny bug I found: after you plug in then plug out charger, max discharge rate remains its old rate when laptop still charged.

image

I don't know if it's designed to act like this (I think no?), but if it is a bug it should be easy to fix, others lgtm until now.

@Ace-Radom
Copy link
Contributor

As said, codes look good to me. One personal suggestion, whould it be better if we change min & max discharge rate into a discharge rate range? It saves one line space, and shows excatly the same thing.

Copy link
Owner

@BartoszCichecki BartoszCichecki left a comment

Choose a reason for hiding this comment

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

This isn’t acceptable in current state.

First of all: battery discharge rate in not refreshed in background. It will only refresh now when:

  1. Hwinfo integration is enabled (also in background)
  2. Battery page is displayed
  3. You hover over tray icon

Because of this, min max is not going to be displayed correctly. It also needs to reset when charger is plugged in.

Wear level should be reversed: people are more used battery health.

@tnt-exe
Copy link
Contributor Author

tnt-exe commented May 24, 2025

One tiny bug I found: after you plug in then plug out charger, max discharge rate remains its old rate when laptop still charged.

image

I don't know if it's designed to act like this (I think no?), but if it is a bug it should be easy to fix, others lgtm until now.

Right, it could be because of the order of calculating min/max and status.Rate you've mentioned above. I was trying to make this as short and less if-nested as possible at first; the test worked fine, so I guess in some condition it got slipped through. Maybe because when you plug and then unplug, there's a moment the discharge rate goes back to 0 before turning negative.

@tnt-exe
Copy link
Contributor Author

tnt-exe commented May 24, 2025

This isn’t acceptable in current state.

First of all: battery discharge rate in not refreshed in background. It will only refresh now when:

  1. Hwinfo integration is enabled (also in background)
  2. Battery page is displayed
  3. You hover over tray icon

Because of this, min max is not going to be displayed correctly. It also needs to reset when charger is plugged in.

Wear level should be reversed: people are more used battery health.

Thanks for pointing this out, Hwinfo integration is disable on me, and not running in background as well.

I did check the code at Hwinfo integration, and it seems to just only call for Battery Temp in background? I'm not sure if making discharge rate refresh in background will change much in current code, but I'll see what I can do.

Personally, I'm good with current one, even if it's not refresh in background, it's the same as when I want to see discharge rate, either open Battery page or hover tray icon, for tray icon I need to hover it again to get new discharge rate value.

I will also change wear level to battery health.

@tnt-exe
Copy link
Contributor Author

tnt-exe commented May 24, 2025

As said, codes look good to me. One personal suggestion, whould it be better if we change min & max discharge rate into a discharge rate range? It saves one line space, and shows excatly the same thing.

If I get this right, you mean it should be like this

Discharge rate range ±9;±20 W

I think it's okay if it's on Battery page, for tray icon it might be horizontally too long, and should be keep as 2 separate min/max discharge rate. Which will cause inconsistency with one on Battery page🤔.

@tnt-exe
Copy link
Contributor Author

tnt-exe commented May 26, 2025

These changes includes:

  • Fix min/max discharge rate calculate logic. This will now be reset when on conservation, charger is plugged in after a discharge session, and vice versa.
  • Change wear level to battery health, also change in localization.
  • Added new background service to keep track of min/max discharge rate.

@tnt-exe tnt-exe requested a review from BartoszCichecki May 26, 2025 16:58
@BartoszCichecki BartoszCichecki merged commit 80c8ac0 into BartoszCichecki:master Jun 2, 2025
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants