comparison src/cs/drivers/drv_app/fchg/fchg_api.c @ 61:75067af48bfd

FCHG updates for Tourmaline UI integration
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 22 Oct 2020 22:30:49 +0000
parents 4e78acac3d88
children 769cf6273fe4
comparison
equal deleted inserted replaced
60:48f280c19e16 61:75067af48bfd
9 #include "rvf/rvf_api.h" 9 #include "rvf/rvf_api.h"
10 #include "rvm/rvm_use_id_list.h" 10 #include "rvm/rvm_use_id_list.h"
11 11
12 T_RV_RET fchg_get_current_state(struct fchg_user_state *rstruct) 12 T_RV_RET fchg_get_current_state(struct fchg_user_state *rstruct)
13 { 13 {
14 UINT16 curr_disch_thresh;
15 INT16 ichg_temp;
16
14 if (!pwr_ctrl) 17 if (!pwr_ctrl)
15 return RV_NOT_READY; 18 return RV_NOT_READY;
16 rstruct->chg_state = pwr_ctrl->state; 19 rstruct->chg_state = pwr_ctrl->state;
17 rstruct->batt_mv = pwr_ctrl->batt_mv; 20 rstruct->batt_mv = pwr_ctrl->batt_mv;
21 curr_disch_thresh = pwr_ctrl->curr_disch_thresh;
18 rstruct->batt_percent = 22 rstruct->batt_percent =
19 pwr_ctrl->batt_thresholds[pwr_ctrl->curr_disch_thresh].remain_capa; 23 pwr_ctrl->batt.percent_thresh[curr_disch_thresh].remain_capa;
24 switch (rstruct->chg_state) {
25 case FCHG_STATE_CI_CHARGING:
26 ichg_temp = pwr_ctrl->ci_ichg - pwr_ctrl->i2v_offset;
27 if (ichg_temp < 0)
28 ichg_temp = 0;
29 rstruct->ichg = ichg_temp;
30 rstruct->batt_bars = FCHG_BATT_BARS_CHARGING;
31 break;
32 case FCHG_STATE_CV_CHARGING:
33 ichg_temp = pwr_ctrl->ichg_average - pwr_ctrl->i2v_offset;
34 if (ichg_temp < 0)
35 ichg_temp = 0;
36 rstruct->ichg = ichg_temp;
37 rstruct->batt_bars = FCHG_BATT_BARS_CHARGING;
38 break;
39 default:
40 rstruct->ichg = 0;
41 if (curr_disch_thresh <= pwr_ctrl->batt.bars_thresh[0])
42 rstruct->batt_bars = 4;
43 else if (curr_disch_thresh <= pwr_ctrl->batt.bars_thresh[1])
44 rstruct->batt_bars = 3;
45 else if (curr_disch_thresh <= pwr_ctrl->batt.bars_thresh[2])
46 rstruct->batt_bars = 2;
47 else if (curr_disch_thresh <= pwr_ctrl->batt.bars_thresh[3])
48 rstruct->batt_bars = 1;
49 else
50 rstruct->batt_bars = 0;
51 }
20 return RV_OK; 52 return RV_OK;
21 } 53 }
22 54
23 T_RV_RET fchg_user_charge_control(enum fchg_user_charge_ctrl arg) 55 T_RV_RET fchg_user_charge_control(enum fchg_user_charge_ctrl arg)
24 { 56 {
56 rvf_free_buf(msg); 88 rvf_free_buf(msg);
57 return RV_INTERNAL_ERR; 89 return RV_INTERNAL_ERR;
58 } 90 }
59 return RV_OK; 91 return RV_OK;
60 } 92 }
93
94 T_RV_RET fchg_register_event_handler(T_FCHG_EVENT_HANDLER handler)
95 {
96 if (!pwr_ctrl)
97 return RV_NOT_READY;
98 pwr_ctrl->event_handler = handler;
99 return RV_OK;
100 }