I have had no change to have a look at this, will do sometime today or tommorow.
For anyone else interrested, I have posted the code.
I have to split it into 2 posts, as its big.
Does the "bool fOverrideRF = false;" not need to be "boolean fOverrideRF = false;"
First Half :
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 <ReefAngel.h>
#include <avr/pgmspace.h>>
//***************************************************************************************************************************************************************************
//-------------------------------------------------------------------------- Screen set-up ---------------------------------------------------------------------------------
#define NumScreens 7
int ScreenID=0;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- PWM Cloud -----------------------------------------------------------------------------------
boolean ForceCloud=false;
boolean ForceLightning=false;
//
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------- PWM Channels ----------------------------------------------------------------------------------
#define LEDWhiteBlue 0
#define LEDWhiteBlue1 1
#define LEDWhiteBlue2 2
#define LEDWhiteBlue3 3
#define MixedLED 4
#define LEDMoonlights 5
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------- Start of Global Variables ---------------------------------------------------------------------------
byte ChannelValue[]=
{
0,0,0,0,0,0
};
byte SeasonsVar[]=
{
0,0,0,0,0,0
};
byte MoonPWMValue;
byte vtechmode = 0;
bool fOverrideRF = false;
byte DayAge;
byte ThisPhase;
int JulianDate(int,int,int);
double MoonAge(int,int,int);
byte MoonState();
boolean bFeeding=false;
byte x,y;
int maxTemp=0;
int minTemp=2000;
int maxPH=600;
int minPH=900;
char text[10];
int v;
int moonlight=0;
long calcSec(long,long);
long calcTime(long,long);
short Ndays;
int rhour = 0, rmin = 0, shour = 0, smin = 0;
byte TempRelay =15;
byte TempRelay2=15;
static byte lightningchance=0;
byte cloudduration=0;
int cloudstart=0;
//***************************************************************************************************************************************************************************
//----------------------------------------------------------------------- Custom Menu Code ----------------------------------------------------------------------------------
prog_char menu1_label[] PROGMEM = "Food!!";
prog_char menu2_label[] PROGMEM = "Cleanup";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Force Storm";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Salty Calibration";
prog_char menu7_label[] PROGMEM = "Vortech Modes";
prog_char menu8_label[] PROGMEM = "Sump On";
prog_char menu9_label[] PROGMEM = "Sumo Off";
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ForceCloud=true;
ForceLightning=true;
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.SetupCalibrateSalinity();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
// TODO complete this function
/*
Need to have an override variable inside the loop that forces a specific mode whenever
the menu is toggled. This should mimic the PWM override.
*/
/*
Cycle through the modes.
Use the Internal Memory values OR create a switch statement that has default values
for Speed and Duration based on the modes being switched to.
Once at the end of the modes,
return to constant mode (begining)
resume normal operations
*/
fOverrideRF = true;
vtechmode++;
if ( vtechmode == 7 ) vtechmode = 9;
if ( vtechmode > 9 ) { vtechmode = 0; fOverrideRF = false; }
// 1st parameter is Mode, 2nd is speed, 3rd is duration
ReefAngel.RF.SetMode(vtechmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry8()
{
ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = ReefAngel.LightsOnPortsE[i];
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry9()
{
ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------- Grouped Menu Entries ----------------------------------------------------------------------------
PROGMEM const char *menu_items[] =
{
menu1_label, menu2_label, menu3_label,
menu4_label, menu5_label, menu6_label,
menu7_label,menu8_label,menu9_label
};
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------- Custom Main -------------------------------------------------------------------------------
void DrawCircleOutline(byte x, byte y, byte radius, byte bordercolor);
void FillCircle(byte x, byte y, byte radius, byte fillcolor);
void DrawCircleOutletBox(byte x, byte y, byte RelayData, bool reverse = false);
//***************************************************************************************************************************************************************************
//-------------------------------------------------------------------------- Analog Clock constants -------------------------------------------------------------------------
const float pi = 3.141592653;
byte clock_center_x = 65;
byte clock_center_y = 65;
byte clock_radius = 55;
byte secondhand_radius = 33;
float secondangle;
byte secondend_x;
byte secondend_y;
float minuteangle;
float hourangle;
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------- Analog Clock Structure ------------------------------------------------------------------------
int minutebase_radius = 3;
int minutehand_radius = 33;
int hourbase_radius = 3;
int hourhand_radius = 25;
int seconds_hand_x, seconds_hand_y, minutes_hand_x, minutes_hand_y, hours_hand_x, hours_hand_y;
int hours_hand_base_x, hours_hand_base_y, hours_hand_base_x1, hours_hand_base_y1;
int minutes_hand_base_x, minutes_hand_base_y, minutes_hand_base_x1, minutes_hand_base_y1;
int minutebase_x, minutebase_y, minutebase_x1, minutebase_y1;
int minuteend_x, minuteend_y;
int hourbase_x, hourbase_y, hourbase_x1, hourbase_y1;
int hourend_x, hourend_y;
float minfloat;
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------------Time Stamp --------------------------------------------------------------------------------
time_t tsmax=now();
time_t tsmin=now();
time_t PHmax=now();
time_t PHmin=now();
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Minutes Hand --------------------------------------------------------------------------
void draw_minute(int color)
{
Drawline(minutebase_x, minutebase_y, minutebase_x1, minutebase_y1, color);
Drawline(minutebase_x, minutebase_y, minuteend_x, minuteend_y, color);
Drawline(minutebase_x1, minutebase_y1, minuteend_x, minuteend_y, color);
}
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------- Draw Hour Hand --------------------------------------------------------------------------------
void draw_hour(int color)
{
Drawline(hourbase_x, hourbase_y, hourbase_x1, hourbase_y1, color);
Drawline(hourbase_x, hourbase_y, hourend_x, hourend_y, color);
Drawline(hourbase_x1, hourbase_y1, hourend_x, hourend_y, color);
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Line ----------------------------------------------------------------------------------
void Drawline (int x0, int y0, int x1, int y1, int color)
{
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
if (dy < 0)
{
dy = -dy;
stepy = -1;
}
else
{
stepy = 1;
}
if (dx < 0)
{
dx = -dx;
stepx = -1;
}
else
{
stepx = 1;
}
dy <<= 1; // dy is now 2*dy
dx <<= 1; // dx is now 2*dx
ReefAngel.LCD.PutPixel(color, x0, y0);
if (dx > dy)
{
int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (x0 != x1)
{
if (fraction >= 0)
{
y0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
x0 += stepx;
fraction += dy; // same as fraction -= 2*dy
ReefAngel.LCD.PutPixel(color, x0, y0);
}
}
else
{
int fraction = dx - (dy >> 1);
while (y0 != y1)
{
if (fraction >= 0)
{
x0 += stepx;
fraction -= dy;
}
y0 += stepy;
fraction += dx;
ReefAngel.LCD.PutPixel(color, x0, y0);
}
}
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Time ----------------------------------------------------------------------------------
void DrawTime(byte x, byte y, byte FGcolor, byte BGcolor, time_t ts)
{
char text[13];
char temp[]=" ";
strcpy(text,"");
itoa(hourFormat12(ts),temp,10);
if (temp[1]==0) strcat(text,"0");
strcat(text,temp);
strcat(text,":");
itoa(minute(ts),temp,10);
if (temp[1]==0) strcat(text,"0");
strcat(text,temp);
strcat(text,":");
itoa(second(ts),temp,10);
if (temp[1]==0) strcat(text,"0");
strcat(text,temp);
if (isAM(ts))
{
strcat(text," AM");
}
else
{
strcat(text," PM");
}
ReefAngel.LCD.DrawText(FGcolor, BGcolor, x, y, text);
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Circle --------------------------------------------------------------------------------
void DrawCircle(int a, int b, int r, byte color)
{
int f = 1 - r;
int ddF_x = 1;
int ddF_y = -2 * r;
int x = 0;
int y = r;
ReefAngel.LCD.PutPixel(color, a, b+r);
ReefAngel.LCD.PutPixel(color ,a, b-r);
ReefAngel.LCD.PutPixel(color, a+r, b);
ReefAngel.LCD.PutPixel(color, a-r, b);
while (x<y)
{
if (f >= 0)
{
y--;
ddF_y += 2;
f += ddF_y;
}
x++;
ddF_x += 2;
f += ddF_x;
ReefAngel.LCD.PutPixel(color, a + x, b + y);
ReefAngel.LCD.PutPixel(color, a - x, b + y);
ReefAngel.LCD.PutPixel(color, a + x, b - y);
ReefAngel.LCD.PutPixel(color, a - x, b - y);
ReefAngel.LCD.PutPixel(color, a + y, b + x);
ReefAngel.LCD.PutPixel(color, a - y, b + x);
ReefAngel.LCD.PutPixel(color, a + y, b - x);
ReefAngel.LCD.PutPixel(color, a - y, b - x);
}
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Weekly ------------------------------------------------------------------------------
void DrawWeeklyAvg (byte hr, int sensor, byte color, byte x, byte y, byte z)
{
const int numReadings = 7;
int dailyread;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
if (hour()==hr && minute()==0 && second()==0)
{
dailyread=sensor;
total= total - readings[index]; // subtract the last reading:
readings[index] = dailyread; // read from the sensor:
total= total + readings[index]; // add the reading to the total:
index = index + 1; // advance to the next position in the array:
if (index >= numReadings) // if we're at the end of the array...
index = 0; // ...wrap around to the beginning:
average = total / numReadings; // calculate the average:
delay (1000);
ReefAngel.LCD.DrawSingleMonitor(average, color, x, y, z);
}
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Daily ---------------------------------------------------------------------------------
void DrawDailyAvg (int sensor, byte color, byte x, byte y, byte z)
{
const int numReadings = 24;
int dailyread;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
if (minute()==0 && second()==0)
{
dailyread=sensor;
total= total - readings[index]; // subtract the last reading:
readings[index] = dailyread; // read from the sensor:
total= total + readings[index]; // add the reading to the total:
index = index + 1; // advance to the next position in the array:
if (index >= numReadings) // if we're at the end of the array...
index = 0; // ...wrap around to the beginning:
average = total / numReadings; // calculate the average:
delay (1000);
ReefAngel.LCD.DrawSingleMonitor(average, color, x, y, z);
}
}
void DrawCustomMain()
{
// Refresh is called at start of ShowInterface.
// ShowInterface calls DrawCustomMain
switch (ScreenID)
{
//---------------------------------------------------------------------------- Screen Code 1--------------------------------------------------------------------------------
case 0:
//Top Banner
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
// Display T1 Header Text
ReefAngel.LCD.DrawLargeText(COLOR_STEELBLUE,255,5,15,"Sump Temp", Font8x8);
// Display the T1 Temp Value
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.Clear(255, 10, 25, 50, 60);
if (ReefAngel.Params.Temp[T1_PROBE]>270) ReefAngel.LCD.DrawHugeNumbers(COLOR_RED, 255, 10, 25, text);
else if (ReefAngel.Params.Temp[T1_PROBE]>270) ReefAngel.LCD.DrawHugeNumbers(COLOR_ORANGE, 255, 10, 25, text);
else ReefAngel.LCD.DrawHugeNumbers(COLOR_MIDNIGHTBLUE, 255, 10, 25, text);
// Display the T2 Header Text
ReefAngel.LCD.DrawLargeText(0,255,5,45,"Room Temp", Font8x8);
// Display the T2 Temp Value
ReefAngel.LCD.Clear(255, 90, 50, 132, 60);
ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
ReefAngel.LCD.DrawLargeText(COLOR_MIDNIGHTBLUE, 255, 90, 45, text, Num8x8);
// Display pH Header Text
ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,95,15,"pH", Font8x8);
// Display pH Value
ConvertNumToString(text, ReefAngel.Params.PH, 100); // check code
ReefAngel.LCD.Clear(0, 65, 62 , 65, 62);
if (ReefAngel.Params.PH>840 || ReefAngel.Params.PH<790) ReefAngel.LCD.DrawLargeText(COLOR_RED, 255, 85, 25, text, Num8x8);
else if (ReefAngel.Params.PH>830 || ReefAngel.Params.PH<800) ReefAngel.LCD.DrawLargeText(COLOR_ORANGE, 255, 85, 25, text, Num8x8);
else ReefAngel.LCD.DrawLargeText(COLOR_MIDNIGHTBLUE, 255, 85, 25, text, Num8x8);
// Display Vortech Mode
ReefAngel.LCD.DrawLargeText(0,255,5,55,"Vortech", Font8x8);
// Display EcoSmart Mode Value
ReefAngel.LCD.Clear(255, 66, 60, 132, 70);
if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255, 66, 55,"Constant");
else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255, 66, 55,"Lagoon");
else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255, 80, 55,"RCM");
else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255, 80, 55,"Short");
else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255, 66, 55,"Long");
else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255, 80, 55,"NTM");
else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255, 80, 55,"TSM");
else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_GRAY,255, 80, 55,"Night");
// Display Salinity
ReefAngel.LCD.DrawLargeText(0,255,64,114,"Salinity", Font8x8);
// Display Salinity Value
ReefAngel.LCD.Clear(255, 82, 85, 65, 95);
ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 85, 122, text, Num8x8);
//Start Moon Phase,Cloud or Storm Display
SeasonsVar[0]=ChannelValue[LEDWhiteBlue];
SeasonsVar[1]=rhour;
SeasonsVar[2]=rmin;
SeasonsVar[3]=shour;
SeasonsVar[4]=smin;
SeasonsVar[5]=cloudstart/60;
SeasonsVar[6]=cloudstart%60;
SeasonsVar[7]=cloudduration;
SeasonsVar[8]=lightningchance;
SeasonsVar[9]=ChannelValue[LEDWhiteBlue1];
SeasonsVar[10]=ChannelValue[LEDWhiteBlue2];
SeasonsVar[11]=ChannelValue[LEDWhiteBlue3];
SeasonsVar[12]=ChannelValue[MixedLED];
SeasonsVar[13]=ChannelValue[LEDMoonlights];
//Start Moon Phase,Cloud or Storm Display
if (SeasonsVar[13] > 0)//if moon phase is active display state and pwm %
{
DayAge = MoonAge(day(), month(), year());
MoonState(DayAge);
char* ThisPhaseLabel[]= {"New","Waxing C","First Q","Waxing G","Full","Waning G","Last Q","Waning C"};
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,70,105,ThisPhaseLabel[ThisPhase]);
}
else if (SeasonsVar[5] > 0) //or if there is a cloud display clouds instead
{
if (SeasonsVar[8] > 0) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,60,85, "Storm"); //decide between dislaying storm or cloud based on lightningchance
else ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,95,85,"Cloud");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,60,95, SeasonsVar[5]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,75,94, ":");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,80,95, SeasonsVar[6]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,93,95,"Lnt");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,113,95, SeasonsVar[7]);
}
else if (hour() >8 || hour() <14 && SeasonsVar[5,6,7] <= 0)
{
ReefAngel.LCD.DrawLargeText(COLOR_ORANGERED,255,3,65, "Sunrise",Font8x8);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,3,75, SeasonsVar[0]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,20,74, ":");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,24,75, SeasonsVar[9]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,41,74, ":");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,45,75, SeasonsVar[10]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,66,75, "|");
}
else if (hour() >14 || hour() <22 && SeasonsVar[5,6,7] <=0)
{
ReefAngel.LCD.DrawLargeText(COLOR_ORANGE,255,75,65, "Sunset",Font8x8);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,70,75, SeasonsVar[0]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,87,74, ":");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,91,75, SeasonsVar[9]);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,108,74, ":");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,112,75, SeasonsVar[10]);
}
//End Display Moon Phase Display
// Display Main and Expansion Relay Box
TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawCircleOutletBox(10,90, TempRelay);
pingSerial();
TempRelay2 = ReefAngel.Relay.RelayDataE[0];
TempRelay2 &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay2 |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawCircleOutletBox(40,90, TempRelay2);
pingSerial();
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 2---------------------------------------------------------------------------------
case 1: //Temperature detail screen with sump and room temp, 24 hr. max/min, time stamps, and graph
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
ReefAngel.LCD.DrawLargeText(0,255,10,15,"Temp Details", Font8x8);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,33,"Sump:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], COLOR_BLACK, 36, 33, 10);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,43,"HI:");
ReefAngel.LCD.DrawSingleMonitor(maxTemp, 0, 23, 43, 10);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,48,43,"at");
DrawTime(60,43,0, COLOR_WHITE,tsmax);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,53,"LO:");
ReefAngel.LCD.DrawSingleMonitor(minTemp, 0, 23, 53, 10);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,48,53,"at");
DrawTime(60,53,0,COLOR_WHITE, tsmin);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,63,"Range:");
ReefAngel.LCD.DrawSingleMonitor((maxTemp-minTemp), COLOR_BLACK, 46, 63, 10);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,69,63,"Degrees C");
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,73,"Avg:");
DrawDailyAvg(ReefAngel.Params.Temp[T1_PROBE], COLOR_BLACK, 43, 73, 1);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,5,83,"WeeklyAvg:");
DrawWeeklyAvg(12,ReefAngel.Params.Temp[T1_PROBE], COLOR_BLACK, 66, 83, 1);
ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor, 86,83,"at noon");
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor, 5 ,93,"Room:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], COLOR_BLACK, 36, 93, 10);
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 3---------------------------------------------------------------------------------
case 2: //pH details
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
ReefAngel.LCD.DrawLargeText(0,255,20,15,"pH Details", Font8x8);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,33,"pH:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, COLOR_BLACK, 36, 33, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,43,"HI:");
ReefAngel.LCD.DrawSingleMonitor(maxPH, 0, 23, 43, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,48,43,"at");
DrawTime(60,43,0, COLOR_WHITE,PHmax);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,53,"LO:");
ReefAngel.LCD.DrawSingleMonitor(minPH, 0, 23, 53, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,48,53,"at");
DrawTime(60,53,0,COLOR_WHITE, PHmin);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,63,"Range:");
ReefAngel.LCD.DrawSingleMonitor((maxPH-minPH), COLOR_BLACK, 46, 63, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,73,"Avg:");
DrawDailyAvg(ReefAngel.Params.PH, COLOR_BLACK, 43, 73, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,83,"WeeklyAvg:");
DrawWeeklyAvg(12,ReefAngel.Params.PH, COLOR_BLACK, 66, 83, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor, 86,83,"at noon");
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,5,93,"WeeklyAvg:");
DrawWeeklyAvg(0,ReefAngel.Params.PH, COLOR_BLACK, 66, 93, 100);
ReefAngel.LCD.DrawText(PHColor,DefaultBGColor, 86,93,"at midnt");
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 4---------------------------------------------------------------------------------
case 3: //relay box key
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawCircleOutletBox(56,46,TempRelay);
pingSerial();
ReefAngel.LCD.DrawLargeText(0,255,27,20,"RelayBox 1", Font8x8);
ReefAngel.LCD.DrawLargeText(0,255,3,44,"LDFan", Font8x8); //1
// ReefAngel.LCD.DrawLargeText(0,255,7,54,"ATU", Font8x8); //3
ReefAngel.LCD.DrawLargeText(0,255,7,64,"ATU", Font8x8); //5
ReefAngel.LCD.DrawLargeText(0,255,7,74,"Salty", Font8x8); //7
ReefAngel.LCD.DrawLargeText(0,255,75,44,"Skimer", Font8x8); //2
ReefAngel.LCD.DrawLargeText(0,255,75,54,"Reactr", Font8x8); //4
ReefAngel.LCD.DrawLargeText(0,255,75,64,"Heatr", Font8x8); //6
ReefAngel.LCD.DrawLargeText(0,255,75,74,"Relay", Font8x8); //8
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 5---------------------------------------------------------------------------------
case 4: //relay box key
ReefAngel.Refresh();
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
TempRelay2 = ReefAngel.Relay.RelayDataE[0];
TempRelay2 &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay2 |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawCircleOutletBox(56,46,TempRelay2);
pingSerial();
ReefAngel.LCD.DrawLargeText(0,255,27,20,"RelayBox 2", Font8x8);
ReefAngel.LCD.DrawLargeText(0,255,7,44,"VTech", Font8x8);//1
ReefAngel.LCD.DrawLargeText(0,255,3,54,"Return", Font8x8);//3
// ReefAngel.LCD.DrawLargeText(0,255,7,64,"Day1", Font8x8);//5
// ReefAngel.LCD.DrawLargeText(0,255,7,74,"Day3", Font8x8);//7
ReefAngel.LCD.DrawLargeText(0,255,75,44,"VTech", Font8x8);//2
ReefAngel.LCD.DrawLargeText(0,255,75,54,"SumpL", Font8x8);//4
// ReefAngel.LCD.DrawLargeText(0,255,75,64,"Day2", Font8x8);//6
ReefAngel.LCD.DrawLargeText(0,255,75,74,"LED", Font8x8);//8
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 6---------------------------------------------------------------------------------
case 5: //setclock
// Analog clock is modified from the original source by Jeff Miller
// Author: Jeff Miller http://arduinofun.blogspot.com/
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
// Frame
DrawCircle(clock_center_x, clock_center_y, clock_radius, COLOR_CORNFLOWERBLUE);
DrawCircle(clock_center_x, clock_center_y, clock_radius - 1, COLOR_CORNFLOWERBLUE);
DrawCircle(clock_center_x, clock_center_y, clock_radius - 2, COLOR_CORNFLOWERBLUE);
// Face Tick Marks (x = r cos theta, y = r sin theta)
for (byte r=0; r < 12; r++)
{
float angle = (2 * pi / 12)*r;
int tick_x_out = (clock_radius - 8) * cos (angle) + clock_center_x;
int tick_y_out = (clock_radius - 8) * sin (angle) + clock_center_y;
int tick_x_in = clock_radius *.72 * cos (angle) + clock_center_x;
int tick_y_in = clock_radius * .72 * sin (angle) + clock_center_y;
Drawline(tick_x_in, tick_y_in, tick_x_out, tick_y_out, COLOR_CORNFLOWERBLUE);
}
// Face Characters
ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 8,106," 6", Font8x8);
ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 8, 25,"12", Font8x8);
ReefAngel.LCD.DrawLargeText(0,255,clock_center_x + 34,clock_center_y," 3", Font8x8);
ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 50, clock_center_y - 4,"9 ", Font8x8);
// Draw Seconds Hand
secondangle = (2 * pi / 60) * second();
if (second() > 15)
{
secondangle = secondangle -1.57;
}
else
{
secondangle = secondangle +4.71;
}
Drawline(clock_center_x, clock_center_y, secondend_x, secondend_y, WHITE);
secondend_x = secondhand_radius * cos (secondangle) + clock_center_x;
secondend_y = secondhand_radius * sin (secondangle) + clock_center_y;
Drawline(clock_center_x, clock_center_y, secondend_x, secondend_y, BLACK);
// Redraw minutes hand since the section closest to the center gets erased by the seconds hand
draw_minute(BLACK);
// Redraw hour hand
draw_hour(BLACK);
// Draw Minutes Hand
minuteangle = (2 * pi / 60) * minute();
if (minute() > 15)
{
minuteangle = minuteangle -1.57;
}
else
{
minuteangle = minuteangle +4.71;
}
// Erase old minutes Hand
draw_minute(WHITE);
// Calculate Minute Hand Base
minutebase_x = minutebase_radius * cos (minuteangle - pi/2) + clock_center_x;
minutebase_y = minutebase_radius * sin (minuteangle - pi/2) + clock_center_y;
minutebase_x1 = minutebase_radius * cos (minuteangle + pi/2) + clock_center_x;
minutebase_y1 = minutebase_radius * sin (minuteangle + pi/2) + clock_center_y;
// Calculate Minute Hand Point
minuteend_x = minutehand_radius * cos (minuteangle) + clock_center_x;
minuteend_y = minutehand_radius * sin (minuteangle) + clock_center_y;
// Draw new minutes Hand
draw_minute(BLACK);
// Redraw hour hand
draw_hour(BLACK);
// Draw Hour Hand
minfloat = minute(); // Convert minute short to float
hourangle = (2 * pi / 12) * ((hourFormat12()) + (minfloat/60)); // Find angle for hour hand
hourangle = hourangle -1.57;
// Erase old Hour Hand
draw_hour(WHITE);
// Calculate hour Hand Base
hourbase_x = hourbase_radius * cos (hourangle - pi/2) + clock_center_x;
hourbase_y = hourbase_radius * sin (hourangle - pi/2) + clock_center_y;
hourbase_x1 = hourbase_radius * cos (hourangle + pi/2) + clock_center_x;
hourbase_y1 = hourbase_radius * sin (hourangle + pi/2) + clock_center_y;
// Calculate hour Hand Point
hourend_x = hourhand_radius * cos (hourangle) + clock_center_x;
hourend_y = hourhand_radius * sin (hourangle) + clock_center_y;
// Draw new hours Hand
draw_hour(BLACK);
ReefAngel.LCD.DrawDate(5,121);
break;
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 7---------------------------------------------------------------------------------
case 6: // Vortech Setup
ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
ReefAngel.LCD.DrawText(0,255,20,50,"Assigning Slaves");
ReefAngel.RF.SetMode(Slave_Start,0,0);
if (ReefAngel.Joystick.IsButtonPressed())
{
ReefAngel.RF.SetMode(Slave_Stop,0,0);
ReefAngel.LCD.DrawText(0,255,50,60,"Done");
}
break;
}
}
void DrawCustomGraph()
{}
//***************************************************************************************************************************************************************************