|
|
@@ -21,6 +21,7 @@ static float _charger_coefficient = 1.0f;
|
|
|
static float _discharger_coefficient = 1.0f;
|
|
|
static float _discharger_no_full_coef = 1.0f;
|
|
|
static uint32_t charger_remain_time = 0;
|
|
|
+static uint8_t version_changed = 0;
|
|
|
static const float _discharger_gain[] = {1.0f/*>0度*/, 1.03f/*-2<t<=0*/, 1.04f/*-5<t<=-2*/, 1.05f/*-10<t<=-5*/, 1.06f/*-15<t<=-10*/, 1.08f/*-20<t<=-15*/};
|
|
|
#define MAX_TIME_FULL_TO_EMPTY (5 * 24 * 3600) //充满到欠压5天内达到,可以校准最小电量
|
|
|
#define MAX_TIME_EMPTY_TO_FULL (24 * 3600) //欠压到充满24小时内达到,可以校准最小电量
|
|
|
@@ -67,12 +68,12 @@ void soc_init(void){
|
|
|
}else if (_soc.capacity == 0) {
|
|
|
force_empty_ts = shark_get_seconds() + 1;
|
|
|
}
|
|
|
- if (_soc.current_real_coulomb != (_soc.coulomb_now - _soc.coulomb_min)) {
|
|
|
- _soc.current_real_coulomb = (_soc.coulomb_now - _soc.coulomb_min);
|
|
|
- }
|
|
|
}
|
|
|
if (soc_get_version() != SOC_CURRENT_VERSION) {
|
|
|
- //DO SOMETHING, FOR SOC VERSION CHANGED
|
|
|
+ _soc.current_real_coulomb = (_soc.coulomb_now - _soc.coulomb_min);
|
|
|
+ version_changed = 1;
|
|
|
+ soc_set_version(SOC_CURRENT_VERSION);
|
|
|
+ nv_save_all_soc();
|
|
|
}
|
|
|
soc_log();
|
|
|
}
|
|
|
@@ -92,7 +93,7 @@ void soc_set_version(u8 version) {
|
|
|
static void _soc_clear(void){
|
|
|
_soc.coulomb_min = 0;
|
|
|
_soc.coulomb_max = DEFALUT_MAX_COULOMB; //30HA,这个值最总需要soh模块给
|
|
|
- _soc.flags = 0;
|
|
|
+ _soc.flags = SOC_FLAG_VERSION(SOC_CURRENT_VERSION);
|
|
|
_soc.charger_coulomb = 0;
|
|
|
_soc.pre_charger_coulomb = 0;
|
|
|
_soc.dischrger_coulomb = 0;
|
|
|
@@ -229,8 +230,7 @@ void soc_log(void){
|
|
|
soc_debug("C max: %.4f\n", TOHA(_soc.coulomb_max));
|
|
|
soc_debug("C char: %.4f\n", TOHA(_soc.charger_coulomb));
|
|
|
soc_debug("C dischar: %.4f\n", TOHA(_soc.dischrger_coulomb));
|
|
|
- soc_debug("C pre char: %.4f\n", TOHA(_soc.pre_discharger_coulomb));
|
|
|
- soc_debug("C pre dischar: %.4f\n", TOHA(_soc.pre_charger_coulomb));
|
|
|
+ soc_debug("C version: %d, %d\n", soc_get_version(), version_changed);
|
|
|
soc_debug("C tol: %.2f\n", _soc.total_coulomb);
|
|
|
soc_debug("C real_coulomb: %f\n", _soc.current_real_coulomb);
|
|
|
soc_debug("C delta time %f, %f, -- %d\n", max_soc_delta_time, soc_delta_time, force_full_ts);
|