Reefology's code
Posted: Mon Jan 05, 2015 4:23 pm
Current code
Code: Select all
#include <Salinity.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_TS.h>
#include <RA_TouchLCD.h>
#include <RA_TFT.h>
#include <RA_TS.h>
#include <Font.h>
#include <RA_Wifi.h>
#include <RA_Wiznet5100.h>
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_ATO.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 <RA_CustomLabels.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <PAR.h>
#include <DCPump.h>
#include <ReefAngel.h>
#include <SoftwareSerial.h>
// Define Relay Ports by Name
#define Box1_Port1
#define skimmer Box1_Port2
#define actinics Box1_Port3
#define t5 Box1_Port4
#define sumplight Box1_Port5
#define fan Box1_Port6
#define radions Box1_Port7
#define returnpump Box1_Port8
#define cafeed Box2_Port1 // CaRx Feed Pump
#define co2 Box2_Port2 // Co2 Solenoid
#define carecirc Box2_Port3 // CaRx Recirculation Pump
#define heaters Box2_Port4
#define ozone Box2_Port5
#define Box2_Port6
#define powerheads Box2_Port7
#define Box2_Port8
//DC Power Expansion
#define dosingCa Box3_Port1
#define dosingVin Box3_Port2
#define dosingTrace Box3_Port3
#define dosingMg Box3_Port4
#define alkdosing Box3_Port5
#define Box3_Port6
#define feeder Box3_Port7
#define Box3_Port8
// Virtual Relays
#define co2purge Box4_Port1
#define showcorals Box4_Port2
#define feednow Box4_Port3
////// Place global variable code below here
void SeasonalTemps ()
{
static int heatArray[][2] = { {762,768},// default in case of error in month=0 (May)
{746,752},//January (winter)
{750,756},//February (winter)
{754,760},//March (early spring)
{758,764},//April (spring)
{762,768},//May (spring)
{768,774},//June (early summer)
{774,780},//July (summer)
{772,778},//August (summer)
{766,772},//September (early fall)
{760,766},//October (fall)
{754,760},//November (fall)
{750,756} };//December (early winter)
ReefAngel.StandardHeater( heaters,heatArray[month()][0],heatArray[month()][1]);
}//end seasonalTemps
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Star();
ReefAngel.AddExtraTempProbes(); // Adds 3 More Temp Probes
ReefAngel.AddHumidityExpansion(); // Humidity Expansion
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = Port8Bit;
ReefAngel.FeedingModePortsE[1] = Port7Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = Port8Bit;
ReefAngel.WaterChangePortsE[1] = Port7Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
ReefAngel.OverheatShutoffPortsE[1] = Port4Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port5Bit | Port7Bit;
ReefAngel.LightsOnPortsE[1] = 0;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T3_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that default on
ReefAngel.Relay.On( returnpump );// Return
ReefAngel.Relay.On( powerheads ); // DC power heads on smart bar
// Ports that default off
ReefAngel.Relay.Off( heaters ); // Heaters
ReefAngel.Relay.Off( ozone ); // Ozone
ReefAngel.Relay.Off( dosingCa ); // Dosing Pump 1
ReefAngel.Relay.Off( dosingVin ); // Dosing Pump 2
ReefAngel.Relay.Off( dosingTrace ); // Dosing Pump 3
ReefAngel.Relay.Off( dosingMg ); // Dosing Pump 4
ReefAngel.Relay.Off( alkdosing ); // Dosing Pump 5
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
SeasonalTemps();
ReefAngel.StandardLights( actinics,12,50,20,30 ); // Royal blue led strip
//ReefAngel.StandardLights( t5,13,00,16,00 ); // T5's
ReefAngel.StandardLights( sumplight,23,30,9,0 ); //Sump light
ReefAngel.StandardLights( radions,12,45,20,10 ); //Radions
ReefAngel.StandardLights( co2,12,35,23,30 ); // Co2 Solenoid
ReefAngel.StandardLights( carecirc,12,30,23,55 ); // CaCo3 Recirculation Pump
ReefAngel.DosingPumpRepeat( ozone,240,1440,1800 ); // Ozone, on 4am=240mins offset from midnight, 1440=every 1440 mins (once a day), for 30 mins=1800 sec's
//Virtual Relays
ReefAngel.Relay.Off( co2purge );// Purge Co2 from Calcium Reactor
ReefAngel.Relay.Off( Box4_Port2 );
ReefAngel.Relay.Off( Box4_Port3 );
ReefAngel.Relay.Off( Box4_Port4 );
ReefAngel.Relay.Off( Box4_Port5 );
ReefAngel.Relay.Off( Box4_Port6 );
ReefAngel.Relay.Off( Box4_Port7 );
ReefAngel.Relay.Off( Box4_Port8 );//Test Virtual Switch
// RA* Dimmers
//ReefAngel.PWM.SetDaylight( PWMSlope( 15,30,20,30,0,50,90,0 ) ); //analog
if (hour(now())<15) ReefAngel.PWM.SetActinic( PWMSlope( 12,50,14,59,0,100,10,0 ) ); //analog
else
ReefAngel.PWM.SetActinic( PWMSlope( 15,00,20,30,0,90,60,0 ) );
//ReefAngel.PWM.SetActinic( PWMSlope( 11,30,20,30,0,95,60,0 ) ); //analog
//ReefAngel.PWM.Daylight2PWMSlope();
//ReefAngel.PWM.Actinic2PWMSlope();
//Dimmer Expansion PopBloom RS90
//Whites
if (hour(now())<15) ReefAngel.PWM.SetChannel( 0,PWMSlope( 12,55,14,59,0,100,05,0) );
else
ReefAngel.PWM.SetChannel( 0,PWMSlope( 15,00,22,00,0,60,90,0) );
//Blues
if (hour(now())<15) ReefAngel.PWM.SetChannel( 1,PWMSlope( 12,50,14,59,0,100,10,0) );
else
ReefAngel.PWM.SetChannel( 1,PWMSlope( 15,00,23,45,0,85,90,0) );
//Cyan
if (hour(now())<15) ReefAngel.PWM.SetChannel( 2,PWMSlope( 12,50,14,59,0,100,10,0) );
else
ReefAngel.PWM.SetChannel( 2,PWMSlope( 15,00,23,30,0,85,120,0) );
//Moon
ReefAngel.PWM.SetChannel( 3,MoonPhase()*0.35);
//Fan
ReefAngel.PWM.SetChannel(4,PWMSlope(00,00,12,00,10,80,90,0 ));
//ReefAngel.PWM.Channel0PWMSlope();
//ReefAngel.PWM.Channel1PWMSlope();
//ReefAngel.PWM.Channel2PWMSlope();
//ReefAngel.PWM.Channel3PWMSlope();
//ReefAngel.PWM.Channel5PWMSlope();
boolean buzzer=false;
//if ( ReefAngel.isATOTimeOut() ) buzzer=true;
//if ( ReefAngel.isOverheat() ) buzzer=true;
if ( ReefAngel.isBusLock() ) buzzer=true;
if ( buzzer ) ReefAngel.BuzzerOn(2); else ReefAngel.BuzzerOff();
////// Place your custom code below here
// Turn off skimmer if return pump is off or from 9am-7pm
if (!ReefAngel.Relay.Status(returnpump) || (hour()>=14 && hour()<=21)) { //if return pump is off or from 2pm-8:59pm
ReefAngel.Relay.Off(skimmer);
} else {
ReefAngel.Relay.DelayedOn(skimmer,5); // Delay start skimmer when return pump is back on
}
// Turn off skimmer if collection container is full
if (ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Override(skimmer,0);
// CaRx Feed Pump
if ((hour() == 6 && minute() <=10) || (hour()>=13 && hour()<23) || (hour() == 23 && minute() <45)) ReefAngel.Relay.On(cafeed);//On from 6-6:10am and 1-11:45pm
else ReefAngel.Relay.Off(cafeed);
//Dosing Pumps
ReefAngel.DosingPumpRepeat1( dosingCa );
ReefAngel.DosingPumpRepeat2( dosingVin );
ReefAngel.DosingPumpRepeat3( dosingTrace );
// ALK Dosing
if (hour() == 12 && minute() == 30 && second() >= 0 && second() <= 50) {
ReefAngel.Relay.On(alkdosing);
} else {
ReefAngel.Relay.Off(alkdosing);
}
// Auto Fish feeder
if (hour() == 13 && minute() == 30 && second() >= 0 && second() <= 13) ReefAngel.Relay.On(feeder);
else if (hour() == 18 && minute() == 30 && second() >= 0 && second() <= 13) ReefAngel.Relay.On(feeder);
else ReefAngel.Relay.Off(feeder);
//Light Canopy Cooling
if (ReefAngel.Params.Temp[T5_PROBE] >= 825) ReefAngel.Relay.On(fan);
if (ReefAngel.Params.Temp[T5_PROBE] <= 705) ReefAngel.Relay.Off(fan);
// Check if the virtual switch is turned on
if (ReefAngel.Relay.Status(showcorals)) { // if showcorals virtual switch is on
ReefAngel.Relay.Off( t5 );
ReefAngel.Relay.On(actinics); // Turn on the actinics
ReefAngel.Relay.On( sumplight );
ReefAngel.PWM.SetChannel(0, 05); // Dimming channel 0 to 5%
ReefAngel.PWM.SetChannel(1, 35); // Dimming channel 1 to 35%
ReefAngel.PWM.SetChannel(2, 60); // Dimming channel 2 to 60%
ReefAngel.PWM.SetChannel(3, 70); // Dimming channel 3 to 70%
ReefAngel.PWM.SetActinic(55); // Dim the actinics to 55%
}
////// Place your custom code above here
ReefAngel.Network.Cloud();
// This should always be the last line
ReefAngel.ShowTouchInterface();
}
// RA_STRING1=4rBCB5aEN369IDJFYl/ESQ==::NTdkYmJkMzM0ODdmMmE0NA==
// RA_STRING2=null
// RA_STRING3=null
// RA_LABEL LABEL_TEMP1=FishRoom
// RA_LABEL LABEL_TEMP2=Sump
// RA_LABEL LABEL_TEMP3=OverFlow
// RA_LABEL LABEL_TEMP4=LightCanopy
// RA_LABEL LABEL_TEMP5=Cabinet
// RA_LABEL LABEL_TEMP6=NotInUse
// RA_LABEL LABEL_DAYLIGHT=Daylight
// RA_LABEL LABEL_ACTINIC=Actinic
// RA_LABEL LABEL_ACTINIC2=Actinic2
// RA_LABEL LABEL_DAYLIGHT2=Daylight2
// RA_LABEL LABEL_PWME0=Whites
// RA_LABEL LABEL_PWME1=Blues
// RA_LABEL LABEL_PWME2=Cyan
// RA_LABEL LABEL_PWME3=MoonLights
// RA_LABEL LABEL_PWME4=Channel4
// RA_LABEL LABEL_PWME5=Channel5
// RA_LABEL LABEL_PORT11=11
// RA_LABEL LABEL_PORT12=Skimmer
// RA_LABEL LABEL_PORT13=BlueLeds
// RA_LABEL LABEL_PORT14=T5's
// RA_LABEL LABEL_PORT15=SumpLight
// RA_LABEL LABEL_PORT16=Fan
// RA_LABEL LABEL_PORT17=Radions
// RA_LABEL LABEL_PORT18=Return
// RA_LABEL LABEL_PORT21=CaFeed
// RA_LABEL LABEL_PORT22=Co2 Sol
// RA_LABEL LABEL_PORT23=CaRecir
// RA_LABEL LABEL_PORT24=Heaters
// RA_LABEL LABEL_PORT25=Ozone
// RA_LABEL LABEL_PORT26=26
// RA_LABEL LABEL_PORT27=PowerHeads
// RA_LABEL LABEL_PORT28=28
// RA_LABEL LABEL_PORT31=DoseCa
// RA_LABEL LABEL_PORT32=DoseVin
// RA_LABEL LABEL_PORT33=DoseTrace
// RA_LABEL LABEL_PORT34=DoseMg
// RA_LABEL LABEL_PORT35=DoseAlk
// RA_LABEL LABEL_PORT36=36
// RA_LABEL LABEL_PORT37=Feeder
// RA_LABEL LABEL_PORT38=38
// RA_LABEL LABEL_PORT41=PurgeCo2
// RA_LABEL LABEL_PORT42=ShowCorals
// RA_LABEL LABEL_PORT43=FeedNow
// RA_LABEL LABEL_PORT44=Virtual
// RA_LABEL LABEL_PORT45=Virtual
// RA_LABEL LABEL_PORT46=Virtual
// RA_LABEL LABEL_PORT47=Virtual
// RA_LABEL LABEL_PORT48=Test
//
//
//
//
//
//
//