Code: Select all
//attempt to have actinics come on and turn off one hour before and one hour after daylights
//Loaded July 13 with fix for time schedule and moon text
//also have the moon lights going off the right way, and moon % showing up after the lights go out
#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 <ReefAngel.h>
#include <avr/pgmspace.h>>
//-------------------------------------------------------------------------- Screen set-up ---------------------------------------------------------------------------------
#define NumScreens 3
int ScreenID=0;
////// Place global variable code below here
time_t WMRTimer=now();
boolean wmdelay=false;
byte wmport=Port5;
////// Place global variable code above here
void DrawCustomMain()
{
// Refresh is called at start of ShowInterface.
// ShowInterface calls DrawCustomMain
switch (ScreenID)
{
//---------------------------------------------------------------------------- Screen Code 1--------------------------------------------------------------------------------
case 0:
//Top Banner
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 120);
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "ROB'S REEF ANGEL");
ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 37, 119, 37);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 59, 119, 59);
pingSerial();
ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 6, 15, "Display");
ReefAngel.LCD.DrawLargeText(COLOR_GOLDENROD, COLOR_WHITE, 18, 27, "Tank");
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
pingSerial();
ReefAngel.LCD.DrawHugeText(COLOR_GOLDENROD, DefaultBGColor, 65, 17, text);
pingSerial();
// if ((hour() >= 5) && (hour() <= 21))
{
ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,72,39,"Frag:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 104, 39, 10);
}
// else
// {
// ReefAngel.LCD.DrawText(COLOR_TEAL, COLOR_WHITE, 72, 39,"Moon:");
// ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),COLOR_TEAL, 104, 39,1);
// ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, 115, 39, "%");
// }
ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,72,48,"Room:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 104, 48, 10);
//
pingSerial();
ReefAngel.LCD.DrawLargeText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 8, 44, "pH:");
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, 35, 44, text);
pingSerial();
break;
//---------------------------------------------------------------------------- Screen Code 2---------------------------------------------------------------------------------
case 1://wavemaker and moon phase
ReefAngel.LCD.DrawText(COLOR_TEAL, COLOR_WHITE, 72, 39,"Moon:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),COLOR_TEAL, 104, 39,1);
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_WHITE, 115, 39, "%");
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 5, 64,"WAVE FLOW:");
if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"----->"); //port 5 on
else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64,"<-----"); //port 6 on
else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 67, 64," 00000 "); //port5 and port 6 off, wavemaker delay: taken away for the
//show the timer for wavemaker
int t=WMRTimer-now();
if (t>=0)
ReefAngel.LCD.Clear(255,105,64,135,74);
ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,110,64,t);
pingSerial();
break;
//---------------------------------------------------------------------------- Screen Code 3---------------------------------------------------------------------------------
case 2:
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,79,"Actinic");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,89,"FragLt");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,99,"WM RT");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,10,109,"Fan");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,79,"Fr/Pump");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,89,"DayLts");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,99,"WM LFT");
ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN,DefaultBGColor,80,109,"Heater");
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawCircleOutletBox(60, 81, TempRelay, true);
break;
}
}
void DrawCustomGraph()
{
}
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 = Port5Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set Actinic and Daylight off by default
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
// Ports that are always on
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DayLights( Port1 );
ReefAngel.ActinicLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.DayLights( Port4 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.StandardFan( Port8 );
// PWMSlope based on Internal Memory values for Standard Lights
////// Place your custom code below here
if (ReefAngel.Joystick.IsLeft())
{
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID--;
}
if (ReefAngel.Joystick.IsRight())
{
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID++;
}
if (ScreenID<0) ScreenID=NumScreens;
if (ScreenID>=NumScreens) ScreenID=0;
MyWavemakerRandom(Port5,Port6,35,50); // Turn Port5 on/off random cycles that lasts from 35 to 50 secs
if ((hour() <= 5) || (hour() >= 22)) //from 5 am to 10 pm the moonlights will be off
{
ReefAngel.PWM.SetDaylight(MoonPhase());
ReefAngel.PWM.SetActinic(MoonPhase());
}
else
{
ReefAngel.PWM.SetDaylight(0); //from 10 pm to 5 am the moonlights will be on
ReefAngel.PWM.SetActinic(0);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "psyrob" );
ReefAngel.ShowInterface();
}
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
}
case 2:
and the error says:
In function 'void DrawCustomMain():
error: jump to case label
error: crosses initialization of 'int t'
If I comment "case 2:" out and merge that into the previous screen and change number of screens to 2, it will load and work...what is wrong?
Thanks