|
|
@@ -85,18 +85,17 @@ void CC_CV_UpdateChargingState(uint8_t slot_id) {
|
|
|
|
|
|
// 4. Cut-off check inside CV
|
|
|
|
|
|
- else if ((charging_state == STATE_CV_CHARGING) &&
|
|
|
- (batt_current <= batt_cutoff_current + BATTERY_THRESHOLD)) {
|
|
|
- if (cycle_count < MAX_CYCLES) {
|
|
|
+ else if ((charging_state == STATE_CV_CHARGING) && (batt_current <= batt_cutoff_current + BATTERY_THRESHOLD)) {
|
|
|
+ //since after the reset the cycle_count sets back to 0, and if the previous_cycle_number obtained from the Pi is greater then:
|
|
|
+ if(previous_cycle_number > cycle_count){
|
|
|
+ cycle_count= previous_cycle_number;
|
|
|
+ charging_state = STATE_DISCHARGING;
|
|
|
+ }else if (cycle_count < MAX_CYCLES) {
|
|
|
charging_state = STATE_DISCHARGING;
|
|
|
cycle_count++;
|
|
|
- } else if(previous_cycle_number < cycle_count){
|
|
|
- cycle_count= previous_cycle_number;
|
|
|
}else {
|
|
|
charging_state = STATE_FINAL_DISCHARGE;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 5. State Discharging condition
|
|
|
@@ -123,10 +122,7 @@ void CC_CV_UpdateChargingState(uint8_t slot_id) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /*
|
|
|
+/*
|
|
|
Function for Battery Charging and Discharging:
|
|
|
** Pre Charge: Once the battery is in discharged state, pre-charging
|
|
|
begins. Starts charging safely with a typically low current C/10
|