Index: firmware/App/Monitors/Level.c =================================================================== diff -u -rae7a7f0dc06fd31a53b0db564d515ce4c39acf67 -rffd0828ba7d0c1ed6ae4624cfb2c502a2e7a203d --- firmware/App/Monitors/Level.c (.../Level.c) (revision ae7a7f0dc06fd31a53b0db564d515ce4c39acf67) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision ffd0828ba7d0c1ed6ae4624cfb2c502a2e7a203d) @@ -63,6 +63,7 @@ static void publishLevelsData( void ); static BOOL processLevelCount( U16 count ); static LEVEL_STATE_T readFloaterLevelstatus( LEVEL_T levelId ); +static LEVEL_STATE_T readBicarbChamberFLevelStatus( void ); /*********************************************************************//** * @brief @@ -123,11 +124,11 @@ break; case D63_LEVL: - currentLevelStatus = ( processLevelCount( getFPGAD63LevelSensor() ) == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); + currentLevelStatus = readBicarbChamberFLevelStatus(); break; case D98_LEVL: - currentLevelStatus = ( processLevelCount( getFPGAD63LevelSensor() ) == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); + currentLevelStatus = readBicarbChamberFLevelStatus(); break; case D46_LEVL: @@ -324,6 +325,41 @@ /*********************************************************************//** * @brief + * Derive Bicarb chamber F level from the two level sensors. + * @details \b Inputs: FPGA level sensor data + * @details \b Outputs: level + * @return level status + *************************************************************************/ +static LEVEL_STATE_T readBicarbChamberFLevelStatus( void ) +{ + BOOL upperlevel = FALSE; + BOOL lowerlevel = FALSE; + + // These FPGA reads are raw counts + upperlevel = processLevelCount( getFPGAD63LevelSensor() ); + lowerlevel = processLevelCount( getFPGAD98LevelSensor() ); + + if ( ( FALSE == lowerlevel ) && ( FALSE == upperlevel ) ) + { + return LEVEL_STATE_LOW; + } + else if ( ( TRUE == lowerlevel ) && ( FALSE == upperlevel ) ) + { + return LEVEL_STATE_MEDIUM; + } + else if ( ( TRUE == lowerlevel ) && ( TRUE == upperlevel ) ) + { + return LEVEL_STATE_HIGH; + } + else + { + //upperlevel == TRUE while lowerlevel == FALSE -> illegal + return LEVEL_STATE_ILLEGAL; + } +} + +/*********************************************************************//** + * @brief * The publishLevelsData function broadcasts the level data at the * publication interval. * @details \b Inputs: levelsDataPublicationCounter