Auto Water Change

Do you have a question on how to do something.
Ask in here.
Post Reply
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

binder wrote:Having the GetDisplayedMenu() function to be able to process the menu would work for custom menus but those modes are slightly different than other scenarios since the controller is displaying a different screen and still processing requests from other stuff. I'm going to have to move the feeding and water change mode stuff to their own function. Then, process the main default_menu (main screen) stuff inside ShowInterface and then allow the user to handle the other 2 modes (feeding and water change) in their own function defined inside their PDE just like with CustomMain. Then they would have to handle the feeding mode or water change mode if they want along with whatever menu items they create. If they want the default options then they could just call the default function and be done with it.

This is all just a thought right now.

curt
awesome ideas! I'll keep messing with the ReefAngel.cpp for now, but look forward to this change!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water Change

Post by rimai »

Maybe my idea was a little vague and caused confusion.
Here is the code I tried and worked for me

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (06/14/2011 20:55)
// RA_061411_2055.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages
#define WavemakerSetup
#define DateTimeSetup
#define VersionMenu
#define ATOSetup
#define MetalHalideSetup
#define DirectTempSensor
#define DisplayLEDPWM
#define StandardLightSetup
*/


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

byte LastDisplayedMenu=0;


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.WaterChangePorts=B10000000;
    // Ports that are always on
    ReefAngel.Relay.On(Port8);
    ReefAngel.Timer[4].SetInterval(3);
}

void loop()
{
    ReefAngel.ShowInterface();
    if(ReefAngel.DisplayedMenu==WATERCHANGE_MODE && LastDisplayedMenu != ReefAngel.DisplayedMenu) ReefAngel.Timer[4].Start();
    LastDisplayedMenu=ReefAngel.DisplayedMenu;
    if (ReefAngel.Timer[4].IsTriggered()) ReefAngel.Relay.RelayMaskOff|=1<<(Port8-1);   
}
I just turned DisplayedMenu into public for the purposes of testing.
Roberto.
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

thanks Roberto, I'll have to try that to see if it will work with the menu!

Curt, so you're saying while this mode is running, the stats from my tank wouldn't be reported to the banner?
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Auto Water Change

Post by binder »

alexwbush wrote:thanks Roberto, I'll have to try that to see if it will work with the menu!

Curt, so you're saying while this mode is running, the stats from my tank wouldn't be reported to the banner?
If you have your own function that everything is contained in and the controller stays in it for the duration of the mode (say you have everything contained in a WaterChangeFunction()) then yes.
But if you do what Roberto showed then no.

As long as the main loop keeps running and you still encounter the code that sends your banner stats then you will be fine.

curt
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

I'm getting errors from adding in the code Roberto posted...

My code:

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (05/08/2011 17:03)
// RA_050811_1703.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages - ok
#define WavemakerSetup - ok
#define DateTimeSetup - ok
#define ATOSetup - ok, but probably not needed since the ato timeouts are not used
#define MetalHalideSetup - ok
#define DirectTempSensor - ok
#define RelayExp - ok
#define SingleATOSetup - ok, but probably not needed since the single ato function isn't used
#define StandardLightSetup -ok
#define CUSTOM_MAIN - ok
#define COLORS_PDE - ok
*/

//Custom colors
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

/*
#define Box1_Port1    11    Fuge LED
#define Box1_Port2    12    Carbon Reactor
#define Box1_Port3    13    
#define Box1_Port4    14    Vortech
#define Box1_Port5    15    WC Heater
#define Box1_Port6    16    WC Pump
#define Box1_Port7    17    Actinic LED
#define Box1_Port8    18    
*/


byte LastDisplayedMenu=0;

void DrawCustomMain()
{
  // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
  ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 35, 2, "Alex's Cube");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
                            ReefAngel.PWM.GetDaylightValue(), 
                            ReefAngel.PWM.GetActinicValue());
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph(5, 10);
}

void setup()
{
    ReefAngel.Init();  //Initialize controller

    /*Need to set these up still
    //ReefAngel.FeedingModePorts = B10101000;
    //ReefAngel.WaterChangePorts = B10000010;
    //ReefAngel.WaterChangePorts = B00000001;
    //ReefAngel.OverheatShutoffPorts = B00000110;
    */

    // Ports that are always on 
    ReefAngel.Relay.On(Port8); //Fuge LED
    ReefAngel.Relay.On(Port5); //Vortech    
    ReefAngel.Relay.On(Box1_Port3); //Sump
    
    ReefAngel.PWM.SetDaylight(0);
    ReefAngel.PWM.SetActinic(0);
    
    ReefAngel.Timer[4].SetInterval(3); //start timer for water change menu
}

void loop()
{
    ReefAngel.ShowInterface();

    //water change menu
    if(ReefAngel.DisplayedMenu==WATERCHANGE_MODE && LastDisplayedMenu != ReefAngel.DisplayedMenu) 
    {
      ReefAngel.Timer[4].Start();
      LastDisplayedMenu=ReefAngel.DisplayedMenu;
    }
    if (ReefAngel.Timer[4].IsTriggered()) 
    {
        ReefAngel.Relay.RelayMaskOff|=1<<(Port8-1);   
    }

    // Have PWM on from 12p to 23p, with gradual 60 minute ramp up and down starting at the given times
    // From 12p to 1p, the Actinic PWM will slowly ramp from 15% to 50%
    // From 22p to 23p, the Actinic PWM will slowly ramp from 50% to 15%
    ReefAngel.PWM.SetActinic(PWMSlope(12,0,23,30,15,50,60,ReefAngel.PWM.GetActinicValue()));
    ReefAngel.PWM.SetDaylight(PWMSlope(13,0,22,30,15,50,60,ReefAngel.PWM.GetDaylightValue()));
/*    
    if ((NumMins(hour(now()),minute(now())) < NumMins(12,0)) || (NumMins(hour(now()),minute(now())) > NumMins(23,0)))
    {
      ReefAngel.PWM.SetDaylight(15);
      ReefAngel.PWM.SetActinic(15);
    }
*/
    // Specific functions
    // ReefAngel.SingleATOHigh(Port1);
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.On(Port3); //WC Pump
        ReefAngel.Relay.On(Box1_Port7); //ATO
    }
    if(ReefAngel.HighATO.IsActive()==false)
    {
        ReefAngel.Relay.Off(Port3); //WC Pump
        ReefAngel.Relay.Off(Box1_Port7); //ATO
    }
    if(ReefAngel.LowATO.IsActive())
        ReefAngel.DelayedOn(Box1_Port4, 1); //Skimmer Delayed on
    if(ReefAngel.LowATO.IsActive()==false)
        ReefAngel.Relay.Off(Box1_Port4); //Skimmer
    
    ReefAngel.StandardLights(Box1_Port8); //Fuge PC
//    ReefAngel.MHLights(Port6); //MH
    ReefAngel.StandardFan(Box1_Port2);
    ReefAngel.StandardHeater(Box1_Port1);
    
    ReefAngel.StandardLights(Port1,13,00,22,30); //Daylight
    ReefAngel.StandardLights(Port2,12,00,23,45); //Actinic
    ReefAngel.StandardLights(Port7,12,00,23,45); //LED Fan
}
Errors:

Code: Select all

C:\Documents and Settings\Webmaster\My Documents\Arduino\libraries\ReefAngel/ReefAngel.h: In function 'void loop()':
C:\Documents and Settings\Webmaster\My Documents\Arduino\libraries\ReefAngel/ReefAngel.h:191: error: 'byte ReefAngelClass::DisplayedMenu' is private
RA_050811_1703:112: error: within this context
C:\Documents and Settings\Webmaster\My Documents\Arduino\libraries\ReefAngel/ReefAngel.h:191: error: 'byte ReefAngelClass::DisplayedMenu' is private
RA_050811_1703:112: error: within this context
C:\Documents and Settings\Webmaster\My Documents\Arduino\libraries\ReefAngel/ReefAngel.h:191: error: 'byte ReefAngelClass::DisplayedMenu' is private
RA_050811_1703:115: error: within this context
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water Change

Post by rimai »

That's why I said I changed the private variable "DisplayedMenu" to public.
This was just to test, since it would require modifying libraries. Maybe Curt could give us a better way to get the DisplayedMenu variable, so others could also create custom functions that depend on the menu options, for example, custom feeding mode function.
But, if you want to test it anyways the way it is, all you have to do is open ReefAngel.h and move "byte DisplayedMenu;" from private to public section.
Roberto.
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

ah ok, sorry... completely missed over that part!

and I'm about out of memory :(
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

ok, so I got the menu to run, but as soon as I tried to do a simple "relay on" if the water change menu is selected... it shows the water change text and graphic, but no timer. When I exit the menu, the relay turns off, but when I try to reselect water change mode... text and graphic show on controller (still no timer), but the relay won't turn on.

my pde:

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (05/08/2011 17:03)
// RA_050811_1703.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages - ok
#define WavemakerSetup - ok
#define DateTimeSetup - ok
#define ATOSetup - ok, but probably not needed since the ato timeouts are not used
#define MetalHalideSetup - ok
#define DirectTempSensor - ok
#define RelayExp - ok
#define SingleATOSetup - ok, but probably not needed since the single ato function isn't used
#define StandardLightSetup -ok
#define CUSTOM_MAIN - ok
#define COLORS_PDE - ok
*/

//Custom colors
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

/*
#define Box1_Port1    11    Fuge LED
#define Box1_Port2    12    Carbon Reactor
#define Box1_Port3    13    
#define Box1_Port4    14    Vortech
#define Box1_Port5    15    WC Heater
#define Box1_Port6    16    WC Pump
#define Box1_Port7    17    Actinic LED
#define Box1_Port8    18    
*/


byte LastDisplayedMenu=0;

void DrawCustomMain()
{
  // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
  ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 35, 2, "Alex's Cube");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
                            ReefAngel.PWM.GetDaylightValue(), 
                            ReefAngel.PWM.GetActinicValue());
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph(5, 10);
}

void setup()
{
    ReefAngel.Init();  //Initialize controller

    //Need to set these up still
    //ReefAngel.FeedingModePorts = B10101000;
    ReefAngel.WaterChangePorts = B00000000;
    //ReefAngel.WaterChangePorts = B00000001;
    //ReefAngel.OverheatShutoffPorts = B00000110;
    

    // Ports that are always on 
    ReefAngel.Relay.On(Port8); //Fuge LED
    ReefAngel.Relay.On(Port5); //Vortech    
    ReefAngel.Relay.On(Box1_Port3); //Sump
    
    ReefAngel.PWM.SetDaylight(0);
    ReefAngel.PWM.SetActinic(0);
    
    ReefAngel.Timer[4].SetInterval(3); //start timer for water change menu
}

void loop()
{
    ReefAngel.ShowInterface();

    //water change menu
    if(ReefAngel.DisplayedMenu==WATERCHANGE_MODE && LastDisplayedMenu != ReefAngel.DisplayedMenu) 
    {
      ReefAngel.Timer[4].Start();
      LastDisplayedMenu=ReefAngel.DisplayedMenu;
      ReefAngel.Relay.On(Port6);
      ReefAngel.Relay.Write();
    }
    if (ReefAngel.Timer[4].IsTriggered()) 
    {
        ReefAngel.Relay.RelayMaskOff|=1<<(Port8-1);   
    }
    
    ReefAngel.Relay.Off(Port6);

    // Have PWM on from 12p to 23p, with gradual 60 minute ramp up and down starting at the given times
    // From 12p to 1p, the Actinic PWM will slowly ramp from 15% to 70%
    // From 22p to 23p, the Actinic PWM will slowly ramp from 70% to 15%
    ReefAngel.PWM.SetActinic(PWMSlope(12,0,23,30,15,70,60,ReefAngel.PWM.GetActinicValue()));
    ReefAngel.PWM.SetDaylight(PWMSlope(13,0,22,30,15,75,60,ReefAngel.PWM.GetDaylightValue()));
/*    
    if ((NumMins(hour(now()),minute(now())) < NumMins(12,0)) || (NumMins(hour(now()),minute(now())) > NumMins(23,0)))
    {
      ReefAngel.PWM.SetDaylight(15);
      ReefAngel.PWM.SetActinic(15);
    }
*/
    // Specific functions
    // ReefAngel.SingleATOHigh(Port1);
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.On(Port3); //WC Pump
        ReefAngel.Relay.On(Box1_Port7); //ATO
    }
    if(ReefAngel.HighATO.IsActive()==false)
    {
        ReefAngel.Relay.Off(Port3); //WC Pump
        ReefAngel.Relay.Off(Box1_Port7); //ATO
    }
    if(ReefAngel.LowATO.IsActive())
        ReefAngel.DelayedOn(Box1_Port4, 1); //Skimmer Delayed on
    if(ReefAngel.LowATO.IsActive()==false)
        ReefAngel.Relay.Off(Box1_Port4); //Skimmer
    
    ReefAngel.StandardLights(Box1_Port8); //Fuge PC
//    ReefAngel.MHLights(Port6); //MH
    ReefAngel.StandardFan(Box1_Port2);
    ReefAngel.StandardHeater(Box1_Port1);
    
    ReefAngel.StandardLights(Port1,13,00,22,30); //Daylight
    ReefAngel.StandardLights(Port2,12,00,23,45); //Actinic
    ReefAngel.StandardLights(Port7,12,00,23,45); //LED Fan
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water Change

Post by rimai »

Hey Alex,

The timer is not being drawn in your code and that's why it does not show.
This line ReefAngel.Relay.Off(Port6); is being executed all the time as there is no if statement in front of it, so it is always turning port 6 off.
I changed you code a little and I think this is what you are trying to achieve

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (05/08/2011 17:03)
// RA_050811_1703.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
 #define DisplayImages - ok
 #define WavemakerSetup - ok
 #define DateTimeSetup - ok
 #define ATOSetup - ok, but probably not needed since the ato timeouts are not used
 #define MetalHalideSetup - ok
 #define DirectTempSensor - ok
 #define RelayExp - ok
 #define SingleATOSetup - ok, but probably not needed since the single ato function isn't used
 #define StandardLightSetup -ok
 #define CUSTOM_MAIN - ok
 #define COLORS_PDE - ok
 */

//Custom colors
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

/*
#define Box1_Port1    11    Fuge LED
 #define Box1_Port2    12    Carbon Reactor
 #define Box1_Port3    13    
 #define Box1_Port4    14    Vortech
 #define Box1_Port5    15    WC Heater
 #define Box1_Port6    16    WC Pump
 #define Box1_Port7    17    Actinic LED
 #define Box1_Port8    18    
 */


byte LastDisplayedMenu=0;

void DrawCustomMain()
{
  // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
  ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 35, 2, "Alex's Cube");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), 
  ReefAngel.PWM.GetActinicValue());
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph(5, 10);
}

void setup()
{
  ReefAngel.Init();  //Initialize controller

  //Need to set these up still
  //ReefAngel.FeedingModePorts = B10101000;
  ReefAngel.WaterChangePorts = B00000000;
  //ReefAngel.WaterChangePorts = B00000001;
  //ReefAngel.OverheatShutoffPorts = B00000110;


  // Ports that are always on 
  ReefAngel.Relay.On(Port8); //Fuge LED
  ReefAngel.Relay.On(Port5); //Vortech    
  ReefAngel.Relay.On(Box1_Port3); //Sump

  ReefAngel.PWM.SetDaylight(0);
  ReefAngel.PWM.SetActinic(0);

  ReefAngel.Timer[4].SetInterval(3); //start timer for water change menu
}

void loop()
{
  ReefAngel.ShowInterface();

  //water change menu
  if(ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
  {
    if(LastDisplayedMenu != ReefAngel.DisplayedMenu) // If Water change mode has just been chosen, let's start the timer and turn Port 6 on
    {
      ReefAngel.Timer[4].Start();
      LastDisplayedMenu=ReefAngel.DisplayedMenu;
      ReefAngel.Relay.On(Port6);
    }
    //Draw Timer 4 in countdown mode
    int t=ReefAngel.Timer[4].Trigger-now();
    if (t>=0)
    {
      ReefAngel.LCD.Clear(255,60+(intlength(t)*5),110,100,108);
      ReefAngel.LCD.DrawText(0,255,60,110,t);
    }
    
    // draw main relay just to make it easy to see what's happening/debug purposes. comment out to save memory space
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
    
  }
  if (ReefAngel.Timer[4].IsTriggered()) 
  {
    ReefAngel.Relay.Off(Port6);   // Turns Port 6 off when timer 4 runs out
    ButtonPress++;  // Simulate a button press to exit water change mode
    ReefAngel.DisplayedMenu=DEFAULT_MENU;
  }

  // Have PWM on from 12p to 23p, with gradual 60 minute ramp up and down starting at the given times
  // From 12p to 1p, the Actinic PWM will slowly ramp from 15% to 70%
  // From 22p to 23p, the Actinic PWM will slowly ramp from 70% to 15%
  ReefAngel.PWM.SetActinic(PWMSlope(12,0,23,30,15,70,60,ReefAngel.PWM.GetActinicValue()));
  ReefAngel.PWM.SetDaylight(PWMSlope(13,0,22,30,15,75,60,ReefAngel.PWM.GetDaylightValue()));
  /*    
   if ((NumMins(hour(now()),minute(now())) < NumMins(12,0)) || (NumMins(hour(now()),minute(now())) > NumMins(23,0)))
   {
   ReefAngel.PWM.SetDaylight(15);
   ReefAngel.PWM.SetActinic(15);
   }
   */
  // Specific functions
  // ReefAngel.SingleATOHigh(Port1);
  if(ReefAngel.HighATO.IsActive())
  {
    ReefAngel.Relay.On(Port3); //WC Pump
    ReefAngel.Relay.On(Box1_Port7); //ATO
  }
  if(ReefAngel.HighATO.IsActive()==false)
  {
    ReefAngel.Relay.Off(Port3); //WC Pump
    ReefAngel.Relay.Off(Box1_Port7); //ATO
  }
  if(ReefAngel.LowATO.IsActive())
    ReefAngel.DelayedOn(Box1_Port4, 1); //Skimmer Delayed on
  if(ReefAngel.LowATO.IsActive()==false)
    ReefAngel.Relay.Off(Box1_Port4); //Skimmer

  ReefAngel.StandardLights(Box1_Port8); //Fuge PC
  //    ReefAngel.MHLights(Port6); //MH
  ReefAngel.StandardFan(Box1_Port2);
  ReefAngel.StandardHeater(Box1_Port1);

  ReefAngel.StandardLights(Port1,13,00,22,30); //Daylight
  ReefAngel.StandardLights(Port2,12,00,23,45); //Actinic
  ReefAngel.StandardLights(Port7,12,00,23,45); //LED Fan
}
Code was edited after posting.
Roberto.
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water Change

Post by alexwbush »

wow, thanks Roberto! I'll play with this this weekend!
Post Reply