File tree Expand file tree Collapse file tree 1 file changed +0
-23
lines changed Expand file tree Collapse file tree 1 file changed +0
-23
lines changed Original file line number Diff line number Diff 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 */
11391bool 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}
You can’t perform that action at this time.
0 commit comments