Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rcf09aeb3c5306f39131a92bbc002a102c6ed0ed8 -r9f25f22ef6cd3566f8f7fbbc5c037a69e7f9411b --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision cf09aeb3c5306f39131a92bbc002a102c6ed0ed8) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 9f25f22ef6cd3566f8f7fbbc5c037a69e7f9411b) @@ -15,7 +15,9 @@ **************************************************************************/ #include "FPGA.h" +#include "LoadCell.h" #include "OperationModes.h" +#include "Reservoirs.h" #include "Timers.h" #include "Valves.h" #include "ModeFill.h" @@ -66,9 +68,7 @@ // re-initialize fill mode each time we transition to fill mode initFillMode(); - // TODO - set initial actuator states - setFPGAValveStates(0x014F); - // VDr, VPo to drain + // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); // Conc. pumps on @@ -145,15 +145,28 @@ static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ) { DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; + LOAD_CELL_ID_T fillWeightLoadCell = LOAD_CELL_A1; // TODO - transition back when temperature or mix out of range - if ( 0 ) { setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); result = DG_FILL_MODE_STATE_DIALYSATE_PRODUCTION; } + + // determine which load cell to use for fill volume - we want weight of inactive reservoir + if ( RESERVOIR_1 == getActiveReservoir() ) + { + fillWeightLoadCell = LOAD_CELL_B1; + } + + // if we've reached our target fill to volume (by weight), we're done filling - go back to re-circ mode + if ( getReservoirFillVolumeTargetMl() <= getLoadCellFilteredWeight( fillWeightLoadCell ) ) + { + requestNewOperationMode( DG_MODE_CIRC ); + } + return result; }