custom main and new libraries

Share you PDE file with our community
Post Reply
psyrob
Posts: 247
Joined: Thu Sep 01, 2011 8:44 pm

custom main and new libraries

Post by psyrob »

How do I use the custom main screen I had before the library update? I tried just cutting and pasting my old code into the new one I generated with the Wizard and it won't compile. I notice there is no define section any more at the top of my ino file like before...
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main and new libraries

Post by rimai »

You should be able to just copy and paste.
Post the code and I can help.
Roberto.
psyrob
Posts: 247
Joined: Thu Sep 01, 2011 8:44 pm

Re: custom main and new libraries

Post by psyrob »

I got it to work...I was missing a "{" at the end of one of my cuts....

However, can you look at this code: I had this working to display the time of the wavemaker in seconds, and while it worked before, it now displays a number in the thousands, like 1321, even as the wavemaker alternates back and forth in 35 to 50 seconds..

Code: Select all

//July 7, 2012, first try with the new 1.0.0 libraries

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here
void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
  pingSerial();


  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Big Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 18, 28, text);
 
  pingSerial(); 
  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,48,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 40, 48, 10);

  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,8,39,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 40, 39, 10);
 
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 92, 15, "pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);

  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 88, 28, text);
  pingSerial();
  
      ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
        if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
        else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----");  //port 6 on
        //else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay: taken away for the moonlights July 2nd
        //show the timer for wavemaker
        int t=ReefAngel.Timer[1].Trigger-now();
        if (t>=0)
        ReefAngel.LCD.Clear(255,105,64,135,74);
        ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);
        
          pingSerial();
 
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"ATO");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{
    
}
void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit | Port6Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.DayLights( Port1 );
    ReefAngel.ActinicLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.DayLights( Port4 );
    //ReefAngel.Wavemaker1( Port5 );
    //ReefAngel.Wavemaker1( Port6 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    ReefAngel.PWM.SetActinic( MoonPhase() );
    ////// Place your custom code below here
    if ( (hour()>=7 && hour()<22))
       {
          ReefAngel.WavemakerRandom(Port5,35,50); // Turn Port5 on/off random cycles that lasts from 36 to 50 secs
          ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5)); // Turn Port6 on/off on opposite cycle as Port 5
        // Port 5 and 6 are synchronized.
         // They work in opposing motion of each other at random times.
        }
    else
        {
          ReefAngel.Relay.Off(Port5);
          ReefAngel.Relay.Off(Port6);
         } //Wavemaker on from 7 am to 10 pm, Off there after
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "psyrob" );
    ReefAngel.ShowInterface();
}

Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main and new libraries

Post by rimai »

Oh, it's been a while since we don't use the Timer[1] anymore.
Try this:

Code: Select all

//July 7, 2012, first try with the new 1.0.0 libraries

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here
time_t WMRTimer=now();

////// Place global variable code above here
void DrawCustomMain()
{
  // the graph is drawn/updated when we exit the main menu &
  // when the parameters are saved
  ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
  pingSerial();


  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Big Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 18, 28, text);

  pingSerial(); 
  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,48,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 40, 48, 10);

  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,8,39,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 40, 39, 10);

  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 92, 15, "pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);

  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 88, 28, text);
  pingSerial();

  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
  if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
  else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----");  //port 6 on
  //else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay: taken away for the Moonlights July 2nd

  //show the timer for wavemaker
  int t=WMRTimer-now();
  if (t>=0)
    ReefAngel.LCD.Clear(255,105,64,135,74);
  ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);

  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"ATO");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{

}
void setup()
{
  // This must be the first line
  ReefAngel.Init();  //Initialize controller
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port5Bit | Port6Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;


  // Ports that are always on

  ////// Place additional initialization code below here


  ////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.DayLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.DayLights( Port4 );
  //ReefAngel.Wavemaker1( Port5 );
  //ReefAngel.Wavemaker1( Port6 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  ReefAngel.PWM.SetActinic( MoonPhase() );
  ////// Place your custom code below here
  if ( (hour()>=7 && hour()<22))
  {
    MyWavemakerRandom(Port5,35,50); // Turn Port5 on/off random cycles that lasts from 36 to 50 secs
    ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5)); // Turn Port6 on/off on opposite cycle as Port 5
    // Port 5 and 6 are synchronized.
    // They work in opposing motion of each other at random times.
  }
  else
  {
    ReefAngel.Relay.Off(Port5);
    ReefAngel.Relay.Off(Port6);
  } //Wavemaker on from 7 am to 10 pm, Off there after
  ////// Place your custom code above here

  // This should always be the last line
  ReefAngel.Portal( "psyrob" );
  ReefAngel.ShowInterface();
}

void MyWavemakerRandom(byte WMRelay, int MinWMTimer, int MaxWMTimer)
{
  if (now()>WMRTimer)
  {
    WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
    ReefAngel.Relay.Toggle(WMRelay);
  }
}

Roberto.
psyrob
Posts: 247
Joined: Thu Sep 01, 2011 8:44 pm

Re: custom main and new libraries

Post by psyrob »

This works Roberto, thanks...One other question? My old code used to have a "slow down" for the wave makers at night, with one wavemaker going on for 20 seconds, then a one minute interval with no wavemaker on, then the second went on for 20 seconds, etc. This was the code, I took it out with the last upgrade of libraries, because I was afraid it wouldn't work...How can I get this back in there?
   if ( ReefAngel.Timer[1].IsTriggered() )
  {
    if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
    {
      if (wmdelay)
      {
        ReefAngel.Timer[1].SetInterval(60); // wm night delay
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.Off(Port5);
        ReefAngel.Relay.Off(Port6);
        if (wmport==Port5) wmport=Port6;
        else wmport=Port5;
        wmdelay=false;
      }
      else
      {
        ReefAngel.Timer[1].SetInterval(20); // short wave
        ReefAngel.Timer[1].Start();
        ReefAngel.Relay.On(wmport);
        wmdelay=true;
      }
    }
    else
    {
      //8a-9p normal wave settings
                        //ReefAngel.WavemakerRandom(Port5,35,50);
                        // Turn Port5 on/off random cycles that lasts from 35 to 50 secs
                        //ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5));
                        // Turn Port6 on/off on opposite cycle as Port 5
      ReefAngel.Timer[1].SetInterval(random(35,50));
      ReefAngel.Timer[1].Start();
      ReefAngel.Relay.Toggle(Port5);
      if bitRead(ReefAngel.Relay.RelayData,Port5-1) ReefAngel.Relay.Off(Port6);
      else ReefAngel.Relay.On(Port6);
    }
  }
  
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: custom main and new libraries

Post by rimai »

Try this:

Code: Select all

//July 7, 2012, first try with the new 1.0.0 libraries

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

////// Place global variable code below here
time_t WMRTimer=now();
boolean wmdelay=false;
byte wmport=Port5;

////// Place global variable code above here
void DrawCustomMain()
{
  // the graph is drawn/updated when we exit the main menu &
  // when the parameters are saved
  ReefAngel.LCD.DrawDate(6, 120);
  ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
  ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
  ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
  pingSerial();


  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Big Tank");
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, DefaultBGColor, 18, 28, text);

  pingSerial(); 
  ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,48,"Frag:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 40, 48, 10);

  ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,8,39,"Room:");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 40, 39, 10);

  pingSerial();
  ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 92, 15, "pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);

  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 88, 28, text);
  pingSerial();

  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
  if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
  else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----");  //port 6 on
  //else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay: taken away for the
  //Moonlights July 2nd

  //show the timer for wavemaker
  int t=WMRTimer-now();
  if (t>=0)
    ReefAngel.LCD.Clear(255,105,64,135,74);
  ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);

  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"ATO");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
  ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
}

void DrawCustomGraph()
{

}
void setup()
{
  // This must be the first line
  ReefAngel.Init();  //Initialize controller
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port5Bit | Port6Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;


  // Ports that are always on

  ////// Place additional initialization code below here


  ////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.DayLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.DayLights( Port4 );
  //ReefAngel.Wavemaker1( Port5 );
  //ReefAngel.Wavemaker1( Port6 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  ReefAngel.PWM.SetActinic( MoonPhase() );
  ////// Place your custom code below here
  MyWavemakerRandom(Port5,Port6,35,50); // Turn Port5 on/off random cycles that lasts from 36 to 50 secs
  // This should always be the last line
  ReefAngel.Portal( "psyrob" );
  ReefAngel.ShowInterface();
}

void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
  if (now()>WMRTimer)
  {
    if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a 
    {
      if (wmdelay)
      {
        WMRTimer=now()+60;
        ReefAngel.Relay.Off(WMRelay1);
        ReefAngel.Relay.Off(WMRelay2);
        if (wmport==Port5) wmport=Port6; 
        else wmport=Port5;        
        wmdelay=false;
      }
      else
      {
        WMRTimer=now()+20;
        ReefAngel.Relay.On(wmport);
        wmdelay=true;
      }
    }
    else
    {
      WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
      ReefAngel.Relay.Toggle(WMRelay1);
      ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
      // Port 5 and 6 are synchronized.
      // They work in opposing motion of each other at random times.
    }
  }
}
Roberto.
Post Reply