Reefology's code


Posts: 173
Joined: Fri Dec 26, 2014 6:38 pm
PostPosted: Thu Feb 16, 2017 4:16 am
Code: Select all


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


////// Place global variable code above here


void setup()
{
    // This must be the first line
    InternalMemory.LCDID_write(255); //this line was added when i got a replacement RA+ board
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;
   
 

    // Ports that are always on
    ReefAngel.Relay.On( Port4 );
   

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

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.DayLights( Port2 );
    ReefAngel.StandardHeater( Port3 );
    ReefAngel.Relay.DelayedOn(Port5 );
    ReefAngel.DosingPumpRepeat1( Port7 );
    ReefAngel.DosingPumpRepeat2( Port8 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.ActinicPWMSlope();
    ReefAngel.DCPump.LowATOChannel = Sync; // WP40
    ReefAngel.DCPump.HighATOChannel = AntiSync; // SW-8
    ReefAngel.DCPump.AntiSyncOffset = 125;
   
    ////// Place your custom code below here
   
    // Wavemaker
   
    if ( ((hour() >= 2) && (hour() < 8)) || ((hour() >= 15) && (hour() < 19)) ) // off from 2am-8am & 3pm-7pm
      {
        ReefAngel.Relay.Off(Port6);
      }
        else
      {
        ReefAngel.WavemakerRandom( Port6, 30, 300 ); // random between 30 and 300 seconds
      }
 
 
    // DC pumps....................................
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, Else, Gyre, NutrientTransport };

    if (now()%1800==0 || changeMode==true)  // Change every 30 mins (1800seconds) or controller reboot
    {
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
   
    // Continue NutrientTranspot Mode for 30 minutes after feeding
    if (now()-feeding<1800)
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=ReefCrest;
    ReefAngel.DCPump.Speed=75;
    }
   
    // Night/Quiet mode
      else if (hour()>=2 && hour()<8 ) // 2am to 8am
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( Gyre,40,10 );
    }
      else if (hour()>=15 && hour()<19) // 3pm and 7pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( ShortPulse,40,30 );
    }
   
    //Storm mode
    else if (hour()>=1 && hour()<2) // 1am and 2am
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( Else,70,15 ); 
    }
      else if (hour()>=11 && hour()<12) // 11am and 12pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( ReefCrest,80,15 ); 
    }
    else if (hour()>=21 && hour()<22) // 9pm and 10pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( ShortPulse,85,30 ); 
    }
   
    // Custom Mode and nothing else going on
    else if (InternalMemory.DCPumpMode_read()==11)
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
    ////// Place your custom code above here

Image

Posts: 173
Joined: Fri Dec 26, 2014 6:38 pm
PostPosted: Wed Oct 11, 2017 2:36 pm
Hoping someone can help with this. I'd like to add Seasonal changes to my code but can't get it to compile.

Code: Select all
void SeasonalTemps ()
 {
  static int heatArray[][2] = { {782,786},// default in case of error in month=0 (June)
                    {760,764},//January (winter)
                    {764,768},//February (winter)
                    {765,769},//March (early spring)
                    {769,773},//April (spring)
                    {775,779},//May (spring)
                    {782,786},//June (early summer)
                    {789,793},//July (summer)
                    {796,800},//August (summer)
                    {786,790},//September (early fall)
                    {777,781},//October (fall)
                    {770,774},//November (fall)
                    {765,769} };//December (early winter)
                   
               
  ReefAngel.StandardHeater( Port3,heatArray[month()][0],heatArray[month()][1]);
 }//end seasonalTemps



where exactly do I input this?
Image
User avatar
Posts: 2628
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Thu Oct 12, 2017 7:15 pm
you have to simply copy the entire function and paste it into your INO file, most likely at the end of it. well after the last curly brace of the loop.

Sent from my XT1585 using Tapatalk
Previous

Return to Ask anything here

Who is online

Users browsing this forum: No registered users and 1 guest