#define SHORT_TIME_WEIGHT (1-LONG_TIME_WEIGHT) /*weightage given for short time discharge*/
#define MIN_TIME_FOR_LVL_CHANGE 50
-/*
- * Below 6 values are the co-efficient of the polynomial. These are devired from
- * OCV and and battery percentage level based on experiment
- */
-#define OCV_SOC_POLY_COEF_1 (3402.664)
-#define OCV_SOC_POLY_COEF_2 (42.031)
-#define OCV_SOC_POLY_COEF_3 (-1.76745)
-#define OCV_SOC_POLY_COEF_4 (0.034798)
-#define OCV_SOC_POLY_COEF_5 (-0.00030516)
-#define OCV_SOC_POLY_COEF_6 (0.0000010116)
#define UPS_FACTOR (2.88)
#define DOUBLE_ZERO (0.000000)
#define FULL_CAPACITY 100
if (logic_v2) { /* new logic */
/*wait till enough data gets collected to estimated battery remaining time */
- if (batt_stat.data_available == TRUE) {
+ if (batt_stat.data_available == TRUE)
return 1;
- }
return 0;
}
/* old logic */
{
int i;
int len = 0;
- char buff[BATTERY_DATA_MAX] = {0,0};
+ char buff[BATTERY_DATA_MAX] = {0, 0};
_cleanup_fclose_ FILE *fp = NULL;
fp = fopen(HEART_BATTERY_DATA_FILE, "w");
}
}
len += snprintf(buff + len, BATTERY_DATA_MAX - len, "%d %d %d %d %lf %d", \
- batt_stat.curr_index, batt_stat.last_capacity,batt_stat.remaining_time, \
+ batt_stat.curr_index, batt_stat.last_capacity, batt_stat.remaining_time, \
batt_stat.remaining_time_ups, batt_stat.last_pwr_bchg, batt_stat.data_available);
fputs(buff, fp);
{
int i;
int len = 0;
- char buff[BATTERY_DATA_MAX] = {0,0};
+ char buff[BATTERY_DATA_MAX] = {0, 0};
char *ch;
_cleanup_fclose_ FILE *fp = NULL;
{
int i;
- for (i = 0; i < ocv_degree; i++) {
+ for (i = 0; i < ocv_degree; i++)
volt_intg_full += (intg[i] /(i+1)) * pow(100 , i+1);
- }
volt_intg_full = volt_intg_full/100000.0;
pivot_nor = ((sqrt(discharge_fast) + sqrt(discharge_slow))/2);
if (batt_stat.last_wall_time[i] == 0) {
/* we do not have stored time value from this point onwards, stop updating*/
break;
- }
- else
+ } else
batt_stat.last_wall_time[i] += time_diff;
}
data_avail_chg, batt_stat.index_chg);
_I("last_wall_time_chg = %ld, curr_wall_time = %ld\n",
batt_stat.last_wall_time_chg, curr_wall_time);
- _I("time diff before averaging = %d seconds\n",time_diff);
+ _I("time diff before averaging = %d seconds\n", time_diff);
/*
* get the average of all time diff values stored including current
long curr_wall_time = 0;
long time_diff1, time_diff2;
- _I("last capacity = %d, current capacity = %d\n",batt_stat.last_capacity, batt_stat.curr_capacity);
+ _I("last capacity = %d, current capacity = %d\n", batt_stat.last_capacity, batt_stat.curr_capacity);
/* if battery level change happen then only calculate the new time*/
if (batt_stat.last_capacity != batt_stat.curr_capacity) {
/* calculate the voltage integral(energy) for current capacity */
- for (i = 0; i < ocv_degree; i++) {
+ for (i = 0; i < ocv_degree; i++)
curr_volt_intg += (intg[i] /(i+1)) * pow(batt_stat.curr_capacity , i+1);
- }
curr_volt_intg = curr_volt_intg /100000.0;
/*current time*/
*/
batt_pwr = batt_stat.last_pwr_bchg;
heart_battery_reject_data();
- }
- else {
+ } else {
index = BATTERY_WINDOW_INDEX(batt_stat.curr_index - BATTERY_LEVEL_GAP);
if (batt_stat.last_wall_time[index] == 0 &&
batt_stat.last_volt_intg[index] == 0) {
volt_intg_diff = batt_stat.last_volt_intg[0] - curr_volt_intg;
if (volt_intg_diff < DOUBLE_ZERO)
volt_intg_diff = volt_intg_full - curr_volt_intg;
- }
- else {
+ } else {
/* time differenc since last battery level change*/
time_diff1 = curr_wall_time - batt_stat.last_wall_time[index];
/* voltage integral(energy) change since last battery level change */
/* total remaining time based on current battery level*/
rem_time = (total_battery_capacity * curr_volt_intg) / batt_pwr;
- _I("pivot_nor = %lf, curr_volt_intg = %lf , volt_intg_full %lf, batt_pwr = %lf", pivot_nor, curr_volt_intg,volt_intg_full, batt_pwr);
+ _I("pivot_nor = %lf, curr_volt_intg = %lf , volt_intg_full %lf, batt_pwr = %lf", pivot_nor, curr_volt_intg, volt_intg_full, batt_pwr);
/* calculate remaining time for normal mode */
update_time = (pivot_nor * curr_volt_intg) / volt_intg_full;
if (logic_v2) {
/* get the device mode */
- if (vconf_get_int( VCONFKEY_HEART_BATTERY_DEVICE_MODE, &device_mode))
+ if (vconf_get_int(VCONFKEY_HEART_BATTERY_DEVICE_MODE, &device_mode))
_E("failed to get VCONFKEY_HEART_BATTERY_DEVICE_MODE\n");
/* for every battery level change, calculate the battery estimation time using new logic*/
return BATTERY_USAGE_LEARNING;
/* old logic */
- switch(mode){
+ switch (mode) {
case ULTRA_SAVING_MODE:
/* Fall through */
case POWER_SAVING_MODE: