diff options
author | Jenny Ho <hsiufangho@google.com> | 2023-09-16 00:22:02 +0800 |
---|---|---|
committer | Jenny Ho <hsiufangho@google.com> | 2023-09-21 00:23:14 +0000 |
commit | 54086a3d7d2ec8a9ff094bc8b1b3db1e7b894392 (patch) | |
tree | 73e281a82a3082862f2452237a3020f00521686a | |
parent | 6e1e2e5a1bf8f472d7ff2757814d9af15ccc66ba (diff) | |
download | bms-54086a3d7d2ec8a9ff094bc8b1b3db1e7b894392.tar.gz |
google_battery: add condition for the same marginal and need_rep threshold
Bug: 300479795
Change-Id: I95266cd97d5f5f2ba9c4e41fa1a6b678b62023cc
Signed-off-by: Jenny Ho <hsiufangho@google.com>
-rw-r--r-- | google_battery.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/google_battery.c b/google_battery.c index 062d0f6..e485c3d 100644 --- a/google_battery.c +++ b/google_battery.c @@ -4102,9 +4102,9 @@ static int bhi_calc_sd_index(int algo, const struct health_data *health_data) static int bhi_cycle_count_index(const struct health_data *health_data) { const int cc = health_data->bhi_data.cycle_count; - const int cc_mt = health_data->cycle_count_marginal_threshold; + int cc_mt = health_data->cycle_count_marginal_threshold; const int cc_nrt = health_data->cycle_count_need_rep_threshold; - const int h_mt = health_data->marginal_threshold; + int h_mt = health_data->marginal_threshold; const int h_nrt = health_data->need_rep_threshold; int cc_index; @@ -4112,6 +4112,12 @@ static int bhi_cycle_count_index(const struct health_data *health_data) if (h_mt < h_nrt || cc_nrt <= cc_mt) return BHI_ALGO_FULL_HEALTH; + /* remove marginal_threshold */ + if (h_mt == h_nrt) { + h_mt = 100; + cc_mt = 0; + } + /* use interpolation to get index via cycle count/health threshold */ cc_index = (h_mt - h_nrt) * (cc - cc_nrt) / (cc_mt - cc_nrt) + h_nrt; cc_index = cc_index * 100; /* for BHI_ROUND_INDEX*/ |