Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rc20c77ef196a760a7642d2426e509995e4a98e01 -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision c20c77ef196a760a7642d2426e509995e4a98e01) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) @@ -140,14 +140,14 @@ transitionToNewOperationMode( newMode ); currentMode = newMode; - if ( MODE_TREA == currentMode ) + if ( ( MODE_TREA == lastMode ) && ( currentMode != MODE_TREA ) ) { - // If the current mode is treatment but transitioning to another mode has been requested (including transitioning to fault mode) + // If the last mode is treatment but the new mode is not treatment // it means the treatment is done. Get the elapsed time since the beginning of the treatment and convert it to hours to be written U32 txElapsedTimeMS = calcTimeSince( getTreatmentStartTimeStamp() ); F32 txElapsedTimeHrs = (F32)txElapsedTimeMS / ( MIN_PER_HOUR * SEC_PER_MIN * MS_PER_SECOND ); // Write the treatment hours and set the service to be false so the treatment hours is not reset - setTxTimeHours( txElapsedTimeHrs, FALSE ); + setTxTimeHours( txElapsedTimeHrs ); } }