GugsJr Code

Share you PDE file with our community

Posts: 66
Joined: Fri Jun 20, 2014 6:30 am
PostPosted: Fri Mar 17, 2017 9:49 am
Update Log
3-17-17
* Added Seasonal Temp
* Added Go into feed mode at 5pm
* Added Run feeder at 5:01pm
* Added Nutrient Transport mode for 2.5 hours after feeding mode


3-20-17
* Added custom lcd screen



Current list of Equipment

2 DIY Rapid LED
3 Jebaos
3 Heaters
Dimming Module
Expansion Relay
Expansion Hub
Protein Skimmer
Return Pump
ASF-1 Super Feeder

Current Code:
Code: Select all


#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 <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

// Define Relay Ports by Name

#define Feeder             Port6

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


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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
     
    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.WaterChangeSpeed=0;
       
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    ReefAngel.FeedingModePortsE[0] = Port2Bit;
   
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    ReefAngel.WaterChangePortsE[0] = 0;
   
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    ReefAngel.LightsOnPortsE[0] = 0;
   
       
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port5Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port5Bit;
   
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
   
   
   

       // Ports that are always on
    ReefAngel.Relay.On( Port7 );
    ReefAngel.Relay.On( Port8 );
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port8 );

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


   

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

void loop()
{

// seasonal temperatures
    SeasonalTemps();

    ReefAngel.StandardLights( Port1,14,25,1,5 );
    ReefAngel.StandardLights( Port2,14,25,3,10 );
    ReefAngel.StandardLights( Port3,22,55,2,30 );
   
   
    ReefAngel.StandardLights( Port4,23,55,3,0 );
    ReefAngel.StandardATO( Box1_Port6 );
    ReefAngel.StandardLights( Box1_Port7,22,0,17,0 );
    ReefAngel.PWM.Channel1PWMParabola(); //Front Whites 4:00pm-10:00pm
    ReefAngel.PWM.Channel2PWMParabola(90); //Back Blues 2:30pm-11:30pm
    ReefAngel.PWM.Channel3PWMParabola(-30,30); //Back Whites 4:30pm-10:30pm
    ReefAngel.PWM.Channel4PWMParabola(120); //Back Blues 3:00pm-12:00AM
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ReefAngel.DCPump.AntiSyncOffset=110; //power of the Antisync pump
    ReefAngel.DCPump.ExpansionChannel[0] = Sync;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = None;
    ReefAngel.DCPump.ExpansionChannel[5] = None;
   
////// Place your custom code below here





//AutoFeeder
static unsigned long autofeeding = 0;

if (hour()==17 && minute()==0 && second() <= 2)//if it is 5 pm
{
ReefAngel.FeedingModeStart(); //START FEEDING MODE
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
if ( autofeeding == 0 ) {
autofeeding = now(); //set the time of the start of feeding to variable feeding
}

if (hour()==17 && minute()==1 && second() <= 1)//if it is 5:01.01 pm
{
ReefAngel.Relay.On(Feeder); //TURN FEEDER RELAY ON
}
else
{
ReefAngel.Relay.Off(Feeder); //TURN FEEDER RELAY OFF
}
} else {
if ( autofeeding > 0 ) {
autofeeding = 0;
}
}

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();

// keep Jebaos off for first 5 minutes of feeding mode.
if (now()-feeding<=300 && ReefAngel.DisplayedMenu==FEEDING_MODE) {
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
   
} else if (now()-feeding<8700) { // 5 minutes plus 2 hour 25 minutes
  // Continue NTM for the next 2 hours  25 minutes (150 minutes total)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
}
else {
  ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
   

    ////// Place your custom code above here
   
   

    // This should always be the last line
    ReefAngel.Portal( "GugsJr" );
    ReefAngel.DDNS( "Home" ); // Your DDNS is GugsJr-Home.myreefangel.com
    ReefAngel.ShowInterface();
}

//Custom Main, Graph & Menu

static unsigned long PumpSpeed = InternalMemory.DCPumpSpeed_read(); //Sets Value to pump speed
static int PumpOffset = (PumpSpeed*1.10); //Change Value to match AntiSyncOffset value

void DrawCustomMain() {
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];

 ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE, 6, 2, " GugsJr's Reef");
 ReefAngel.LCD.DrawDate(6, 118);
 ReefAngel.LCD.Clear(COLOR_BLACK, 1, 17, 132, 17);
 pingSerial();

  ReefAngel.LCD.DrawLargeText(COLOR_BLUE,COLOR_WHITE, 24,16,"Jebao Mode:");
       if  (now()%SECS_PER_DAY<1800|| now()%SECS_PER_DAY >=522000) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,28,26,"Night Mode");
  else if  (InternalMemory.DCPumpMode_read()==Lagoon) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,42,26,"Lagoon");
  else if  (InternalMemory.DCPumpMode_read()==ReefCrest) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,25,26,"Reef Crest");
  else if  (InternalMemory.DCPumpMode_read()==ShortPulse) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,22,26,"Short Pulse");
  else if  (InternalMemory.DCPumpMode_read()==LongPulse) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,25,26,"Long Pulse");
  else if  (InternalMemory.DCPumpMode_read()==NutrientTransport) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,26,"Nutrient Trnsp.");
  else if  (InternalMemory.DCPumpMode_read()==TidalSwell) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Tidal Swell");
  else if  (InternalMemory.DCPumpMode_read()==Custom) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Custom");
  else if  (InternalMemory.DCPumpMode_read()==Else) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Tidal Else");
  else if  (InternalMemory.DCPumpMode_read()==Sine) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Sine");
  else if  (InternalMemory.DCPumpMode_read()==Gyre) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Gyre");
  else if  (InternalMemory.DCPumpMode_read()== Constant) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,35,27,"Constant");

  ReefAngel.LCD.DrawLargeText(0,255,17,36,"Display");
  ReefAngel.LCD.DrawLargeText(0,255,17,49,"Temp");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawHugeText(COLOR_RED, 255, 12, 65, text, Num12x16);
  pingSerial();

  ReefAngel.LCD.DrawLargeText(0,255,100,45,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_BLUE, 255, 89, 65, text, Num8x8);
  pingSerial();
 
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,5,80, "Jebao");
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,10,89, "Left");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,16,100, InternalMemory.DCPumpSpeed_read());
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,50,80, "Jebao");
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,49,89, "Center");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,59,100, PumpOffset);
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,93,80, "Jebao");
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,88,89, " Right");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,100,100, InternalMemory.DCPumpSpeed_read());

  pingSerial();
 
 
 
}
void DrawCustomGraph()
{
}



void SeasonalTemps ()
 {
  static int heatArray[][2] = { {780,785},// default in case of error in month=0 (June)
                    {770,774},//January (winter) 77.2
                    {774,778},//February (winter) 77.6
                    {775,779},//March (early spring) 77.7
                    {779,783},//April (spring) 78.1
                    {785,789},//May (spring) 78.7
                    {792,796},//June (early summer) 79.4
                    {799,803},//July (summer) 80.1
                    {806,810},//August (summer) 80.8
                    {796,800},//September (early fall) 79.8
                    {787,791},//October (fall) 78.9
                    {780,784},//November (fall) 78.2
                    {775,779} };//December (early winter) 77.7
                   
               
ReefAngel.StandardHeater(Port5,heatArray[month()][0],heatArray[month()][1]);
ReefAngel.StandardHeater(Box1_Port3,heatArray[month()][0],heatArray[month()][1]);
ReefAngel.StandardHeater(Box1_Port5,heatArray[month()][0],heatArray[month()][1]);
 }//end seasonalTemps



// RA_STRING2=null
// RA_STRING3=null


Last edited by GugsJr on Mon Mar 20, 2017 12:53 pm, edited 9 times in total.

Posts: 66
Joined: Fri Jun 20, 2014 6:30 am
PostPosted: Wed Apr 12, 2017 10:48 am
Code: Select all
ReefAngel.StandardLights( Port1,14,55,1,5 ); //LED Power Supply
    ReefAngel.StandardLights( Port2,14,55,3,10 );  //LED Fans
    ReefAngel.StandardLights( Port3,22,55,2,15 ); //Front Moonlights
    ReefAngel.StandardLights( Port4,23,25,2,30 );  //Rear Moonlights
    ReefAngel.StandardLights( Box1_Port7,22,0,17,0 );  //Refugium Light
    ReefAngel.StandardATO( Box1_Port6 );

    ReefAngel.PWM.Channel1PWMParabola(); //Front Whites 4:00pm-10:00pm (3:30-10:30)
    ReefAngel.PWM.Channel2PWMParabola(30); //Front Blues 2:30pm-11:30pm (3:00-11:00)
    ReefAngel.PWM.Channel3PWMParabola(-30,30); //Back Whites 4:30pm-10:30pm ( 4:00 – 11:00)
    ReefAngel.PWM.Channel4PWMParabola(0,60); //Back Blues 3:00pm-12:00AM (3:30 – 11:30)

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest