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 <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
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 800 );
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardATO( Port1,60 );
ReefAngel.StandardLights( Port3,18,0,10,0 );
ReefAngel.WavemakerRandom( Port5,30,100 );
ReefAngel.WavemakerRandom( Port6,30,100 );
ReefAngel.StandardHeater( Port7,752,755 );
ReefAngel.PWM.SetChannel( 0, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(7,30,21,30,0,35,180,0) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 3, PWMSlope(7,30,21,30,0,35,180,0) );
ReefAngel.PWM.SetChannel( 4, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 5, PWMSlope(7,30,21,30,0,35,180,0) );
////// Place your custom code below here
if (hour()>=8 && hour()<12)
{
ReefAngel.PWM.SetDaylight( ReefCrestMode(100,20,true) ); // ReefCrest at 100% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(100,20,false) ); // ReefCrest at 100% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,100,200,true) ); // Short pulse at 100% with 200ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,100,200,false) ); // Short pulse at 100% with 200ms pulse on anti-sync mode
}
else
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,100,10,true) ); // Long pulse at 100% with 10s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,100,10,false) ); // Long pulse at 6100% with 10s pulse on anti-sync mode
}
if( ReefAngel.DisplayedMenu==FEEDING_MODE )
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "jjdezek" );
ReefAngel.ShowInterface();
}
void DrawParams(int x, int y) {
char buf[16];
ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+5,y,"Temp:");
ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+80, y, "PH:");
// Temp and PH
y+=2;
ConvertNumToString(buf, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawLargeText(T1TempColor, DefaultBGColor, x+5, y, buf, Num8x16);
ConvertNumToString(buf, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+80, y, buf, Num8x16);
y+=5;
ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, x+45, y, buf);
}
void DrawStatus(int x, int y) {
int t=x;
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,15,y,"High",Font8x16);
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,85,y,"Low",Font8x16);
if (ReefAngel.HighATO.IsActive()) {
ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_GREEN);
} else {
ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_RED);
}
if (ReefAngel.LowATO.IsActive()) {
ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_GREEN);
} else {
ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_RED);
}
}
void DrawCustomGraph()
{
}