Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r67da3f0d10e1143173b1e8c29061097d609d8623 -re5713fcc4511a625434a4748f7dded3d237acdf8 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 67da3f0d10e1143173b1e8c29061097d609d8623) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision e5713fcc4511a625434a4748f7dded3d237acdf8) @@ -7,8 +7,8 @@ * * @file ModeDrain.c * -* @author (last) Dara Navaei -* @date (last) 27-Apr-2023 +* @author (last) Michael Garthwaite +* @date (last) 16-May-2023 * * @author (original) Leonardo Baloa * @date (original) 20-Dec-2019 @@ -113,6 +113,7 @@ { // re-initialize each time we transition to drain mode initDrainMode(); + setCurrentSubState( NO_SUB_STATE ); DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); @@ -247,9 +248,20 @@ { DG_DRAIN_STATE_T result = DG_DRAIN_STATE_DRAIN; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); + U32 targetVolumeML = getTargetDrainVolumeML(); + BOOL drainStatus = FALSE; + if ( 0 == targetVolumeML ) + { + drainStatus = hasTargetDrainToZeroBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ); + } + else + { + drainStatus = hasTargetDrainToVolumeBeenReached( inactiveReservoir, targetVolumeML, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ); + } + // if we have reached our target drain to volume (by weight) or cannot drain anymore, we are done draining - go back to generation idle mode - if ( TRUE == hasTargetDrainVolumeBeenReached( inactiveReservoir, DRAIN_WEIGHT_UNCHANGE_TIMEOUT_MS ) ) + if ( TRUE == drainStatus ) { DG_ACID_CONCENTRATES_RECORD_T acid; F32 acidBottleVolML;