#define LONG_TIME_WEIGHT (0.7) /*weightage given for longer time discharge*/
#define SHORT_TIME_WEIGHT (1-LONG_TIME_WEIGHT) /*weightage given for short time discharge*/
#define MIN_TIME_FOR_LVL_CHANGE 50
+#define BATT_CHG_FLUSH_DATA 10
#define UPS_FACTOR (2.88)
#define DOUBLE_ZERO (0.000000)
return (curr_wall_time - batt_stat.last_wall_time_chg);
}
+static void heart_battery_print_prev_charge_data(void)
+{
+ int i;
+
+ _I("Charging stored data, current index = %d", batt_stat.index_chg);
+
+ for (i = 0; i < BATTERY_LEVEL_GAP; i++)
+ _I("Index = %d, time_diff = %d", i, batt_stat.last_wall_time_chg_diff[i]);
+}
+
+/*
+ * This function will flush the stored charge data
+ */
+static void heart_battery_flush_charge_data(void)
+{
+ int i;
+
+ _I("Prev and curr battery lvl gap = %d, flush charge data",
+ batt_stat.last_capacity_chg - batt_stat.curr_capacity);
+
+ for (i = 0; i < BATTERY_LEVEL_GAP; i++)
+ batt_stat.last_wall_time_chg_diff[i] = 0;
+
+ batt_stat.last_wall_time_chg = 0;
+ batt_stat.index_chg = 0;
+ data_avail_chg = false;
+}
+
/*
* This function will calculate the battery charging remaining time
*/
heart_battery_calculate_prediction(batt_stat.curr_charger_status);
if (logic_v2) {
- /* If charger has been removed then update the battery estimation time */
+ /*
+ * If charger removed/inserted then update the battery estimation time
+ */
heart_battery_cal_discharge_rem_time();
if (charger_status == CHARGING) {
+ /*
+ * if diff is more than 10% then flush the previous charge data
+ */
+ if ((batt_stat.last_capacity_chg > 0) &&
+ (batt_stat.last_capacity_chg - batt_stat.curr_capacity > BATT_CHG_FLUSH_DATA))
+ heart_battery_flush_charge_data();
+
batt_stat.last_wall_time_chg = 0;
first_level_change = TRUE;
+ heart_battery_print_prev_charge_data();
heart_battery_cal_charging_rem_time();
}
}
batt_stat.data_available = 0;
batt_stat.last_capacity = 0;
+ batt_stat.last_capacity_chg = 0;
first_level_change = FALSE;
batt_stat.curr_index = 0;
batt_stat.remaining_time = 0;