in ReefAngel.h:
void CustomATO(byte ATORelay, int ATOTimeout);
in ReefAngel.cpp:
Code: Select all
/* This function activiates the ATO pump to refill (ATOLow Active) if the reservoir
is not empty (ATO high inactive). It also limits the time the ATO pump can run to the
ATOTimeout value (s).
*/
void ReefAngelClass::CustomATO(byte ATORelay, int ATOTimeout)
{
// Input: Relay port and timeout value (max number of seconds that ATO pump is allowed to run)
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
/*
Is the low switch active (meaning we need to top off) and are we not currently topping off
Then we set the timer to be now and start the topping pump. Before enabling the top-off pump,
check if the reservoir has water.
*/
if ( !HighATO.IsActive() )
{
LED.Off();
if ( LowATO.IsActive() && ( !LowATO.IsTopping()) )
{
LowATO.Timer = millis();
LowATO.StartTopping();
Relay.On(ATORelay);
}
// Low switch is deactivated so turn off the pump
else if ( (!LowATO.IsActive()) && (LowATO.IsTopping()) )
{
LowATO.StopTopping(); // stop the low ato timer
Relay.Off(ATORelay);
}
}
else LED.On(); // Turn on the LED if the water level in the reservoir is low
/*
If the current time minus the start time of the ATO pump is greater than the specified timeout value
AND the ATO pump is currently running:
We turn on the status LED and shut off the ATO pump
This prevents the ATO pump from contniously running.
*/
if ( (millis()-LowATO.Timer > TempTimeout) && LowATO.IsTopping() )
{
LED.On();
bitSet(Flags,ATOTimeOutFlag);
#ifdef ENABLE_EXCEED_FLAGS
if (InternalMemory.read(ATO_Exceed_Flag)==0)
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
Relay.Off(ATORelay);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}