Skip to content

Commit 165feca

Browse files
authored
Merge pull request #148 from tmobile/CFSPDK-1237-Remove-exponential-filter
Remove exponential filter
2 parents 0c92154 + e1a0334 commit 165feca

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

samples/tmo_shell/src/tmo_adc.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,13 @@ void initADC(void)
8383
LOG_INF("HWID = %d\n", hwid);
8484
}
8585

86-
/**
87-
* @brief Exponential filter for battery level
88-
*/
89-
static void apply_filter(float *bv)
90-
{
91-
static float s_filtered_capacity = -1;
92-
static bool s_battery_is_charging = false;
93-
bool battery_is_charging;
94-
95-
// If there has been a switch between charger and battery, reset the filter
96-
battery_is_charging = is_battery_charging();
97-
if (s_battery_is_charging != battery_is_charging) {
98-
s_battery_is_charging = battery_is_charging;
99-
s_filtered_capacity = -1;
100-
}
101-
102-
if (s_filtered_capacity < 0) {
103-
s_filtered_capacity = *bv;
104-
}
105-
*bv = s_filtered_capacity = s_filtered_capacity * 0.95 + (*bv) * 0.05;
106-
}
107-
10886
/*
10987
* @brief This function writes the amount of battery charge remaining
11088
* (to the nearest 1%) in bv.
11189
* It returns true if successful, or false if there is an issue
11290
*/
11391
bool millivolts_to_percent(uint32_t millivolts, uint8_t *percent) {
11492
float curBv = get_remaining_capacity((float) millivolts / 1000);
115-
apply_filter(&curBv);
11693
*percent = (uint8_t) (curBv + 0.5);
11794
return true;
11895
}

0 commit comments

Comments
 (0)