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 <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
// 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( Port2 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardATO( Port1,2700);
ReefAngel.MoonLights( Port4 );
ReefAngel.StandardFan( Port5 );
ReefAngel.StandardHeater( Port6 );
ReefAngel.StandardLights( Port7,01,00,6,00);
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
ReefAngel.StandardLights(Port4,16,30,17,45);
ReefAngel.StandardLights(Port4,21,30,23,45);
//Wave patterns
if (hour()>=24 && hour()<8)
{
ReefAngel.PWM.SetActinic( LongPulseMode(40,40,10,true) ); // Long pulse at 40% with 10s pulse
}
else if (hour()>=8 && hour()<11)
{
ReefAngel.PWM.SetActinic( TidalSwellMode(50,true) ); // Tidal Swell at 40%
}
else if (hour()>=11 && hour()<12)
{
ReefAngel.PWM.SetActinic( ReefCrestMode(50,20,true) ); // ReefCrest at 50% + - 20
}
else if (hour()>=12 && hour()<13)
{
ReefAngel.PWM.SetActinic( ShortPulseMode(0,70,4,true)); // Short Pulse 70%
}
else if (hour()>=13 && hour()<14)
{
ReefAngel.PWM.SetActinic( ReefCrestMode(70,20,true) ); // ReefCrest at 70% + - 20
}
else if (hour()>=15 && hour()<18)
{
ReefAngel.PWM.SetActinic( millis()%1000>800?80:0); // Wave
}
else if (hour()>=18 && hour()<21)
{
ReefAngel.PWM.SetActinic( NutrientTransportMode(55,70,3000,true) ); // Nutrient Transport
}
else if (hour()>=21 && hour()<24)
{
ReefAngel.PWM.SetActinic( ShortPulseMode(0,70,4,true));
}
//Turn Off during feed mode
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.PWM.SetActinic(0);
}
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
{
ReefAngel.PWM.SetActinic(0);
}
//Feed Modes 7:55am and 6:55pm
//if(hour()==7 && minute()==55 && second()==0)
//{
// ReefAngel.FeedingModeStart();
//}
if(hour()==18 && minute()==55 && second()==0)
{
ReefAngel.FeedingModeStart();
}
if (hour()<17)
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "thavngr98" );
ReefAngel.ShowInterface();
}
//*********************************************************************************************************************************
//Custom Main, Graph & Menu
void DrawCustomMain()
{
byte x;
byte y = 2;
char text[7];
// *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
int TempColor; // Color for drawing temperature
boolean FanOn = ReefAngel.Relay.Status(Port5); // Get the status of the fan relay
boolean HeatOn = ReefAngel.Relay.Status(Port6); // Get the status of the heater relay
if (HeatOn)
{
TempColor = COLOR_NAVY; // Blue text, too cold, heater is on
}
if (FanOn)
{
TempColor = COLOR_RED; // Red text, too warm, fan is on
}
if (!HeatOn && !FanOn)
{
TempColor = COLOR_GREEN; // Green text, no fan or heater on
}
// ***********************************************************************************
ReefAngel.LCD.DrawText(COLOR_WHITE, COLOR_BLACK, 0, 1, " Dave's Reef "); // Put a banner at the top
ReefAngel.LCD.DrawDate(6, 119); // Put the date and time at the bottom
pingSerial(); // Hit the Wifi Attachment
x = 12;
y += MENU_START_ROW+1; // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp pH");
ConvertNumToString(text, ReefAngel.Params.PH, 100); // Get pH reading and convert
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16); // Put pH on the screen
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10); // Get T1 temp and convert
pingSerial();
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.Clear(TempColor, x, y-1, x+63, y-1); // Draw a line above and below the temp
ReefAngel.LCD.Clear(TempColor, x, y+16, x+63, y+16); // To make it look nicer and easier to read
ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text); // Draw the temperature, white numbers on a colored background
x += (16*4) + 8;
pingSerial();
//ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,8,y+25,"White %");
//ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, 24, y+35, 1); // Draw the white light %
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+8,y+25,"Blue %");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+24, y+35, 1); // Draw the blue light %
ReefAngel.LCD.Clear(COLOR_BLACK,5,y+22,127,y+22); // Draw a box around the light area
ReefAngel.LCD.Clear(COLOR_BLACK,5,y+22,5,y+46); //
ReefAngel.LCD.Clear(COLOR_BLACK,127,y+22,127,y+46); //
ReefAngel.LCD.Clear(COLOR_BLACK,5,y+46,127,y+46); //
pingSerial();
// Code for drawing the relay box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(14, 92, TempRelay);
}
void DrawCustomGraph()
{
}