I am still updating things before plug it into my tank
Any suggestions/Comments/Improvements are welcome
Please post if you see any bugs.
Thank you
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 <PAR.h>
#include <WiFiAlert.h>
#include <ReefAngel.h>
// TODO Alerts: High Water Level, Temp alerts, PH alerts, // it looks like the notifications can be created on the app.
// WifiAlert ... // sends email alert where is the email stored?
// Custom menus
#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding Mode";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Calibrate PH";
prog_char menu4_label[] PROGMEM = "Setup Date Time";
prog_char menu5_label[] PROGMEM = "DC Pump Settings";
prog_char menu6_label[] PROGMEM = "Version";
// Group the menu entries together
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label,
menu4_label, menu5_label, menu6_label
};
////// Place global variable code below here
// Needs to be global for DrawCustomGraph()
int ScreenID=1;
boolean drawGraph=true;
boolean HighAlertActive=false;
boolean EmptyAlertActive=false;
WiFiAlert levelAlert, emptyAlert;
//Rename ports
#define MAINPUMP Port1
#define REFPUMP Port2
#define SKIMMER Port3
#define REACTOR Port4
#define POWERHEAD Port5
#define REFLIGHTS Port6
#define UNUSED Port7
#define DRUMPUMP Port8
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items)); // Initialize Menu
//ReefAngel.AddStandardMenu(); // Add Standard Menu
//ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
//ReefAngel.FeedingModePorts = Port5Bit; // its being handled on runDCPump()
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
//ReefAngel.OverheatProbe = T1_PROBE;
//Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 869 );
// Jebao Pump
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.ActinicChannel=Sync; // DC pump on PWM Actinic channel
//ReefAngel.DCPump.DaylightChannel=AntiSync; // DC pump on PWM Daylight channel if I had one
//ReefAngel.DCPump.AntiSyncOffset=85;
//ReefAngel.Network.WifiAuthentication("alekos:xxxxxxxx"); // Not working
// Ports that are always on
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
//ports schedule
ReefAngel.Relay.On(MAINPUMP);
ReefAngel.Relay.On(REFPUMP);
ReefAngel.StandardLights( SKIMMER,7,0,22,0 );
ReefAngel.StandardLights( REACTOR,7,0,22,0 );
ReefAngel.StandardLights( POWERHEAD,7,0,22,0 );
ReefAngel.StandardLights( REFLIGHTS,8,0,22,0 );
ReefAngel.Relay.On( UNUSED ); // this port is not used yet
ReefAngel.StandardLights( DRUMPUMP,20,0,20,15 ); //Automatic Water change Time calculated for 2 Gal per day
////// Place your custom code below here
// using the High float switch to stop pumps to prevent overflow
if (!ReefAngel.HighATO.IsActive()){
levelAlert.Send("Display+Tank+water+level+high+PUMPS+OFF");
HighAlertActive=true;
ReefAngel.Relay.Off(MAINPUMP);
ReefAngel.Relay.Off(REFPUMP);
ReefAngel.Relay.Off(SKIMMER);
ReefAngel.Relay.Off(REACTOR);
ReefAngel.Relay.Off(POWERHEAD);
ReefAngel.Relay.Off(DRUMPUMP);
}
else{
//
}
if (HighAlertActive && ReefAngel.HighATO.IsActive())
HighAlertActive=false;
levelAlert.Send("Display+Tank+water+level+normal+PUMPS+Ok");
//Low sensor on the Water supply drum
//this is to avoid running the pump dry
if (ReefAngel.LowATO.IsActive()){
ReefAngel.Relay.Off(DRUMPUMP);
}
else{
//
}
runDCPump();// running the pump in custom mode
////// Place your custom code above here
// This should always be the last line
pingSerial();
ReefAngel.Portal("alekos");
ReefAngel.ShowInterface();
}
// Menu Code
void MenuEntry1() {
ReefAngel.FeedingModeStart();
DrawRelaysBox(0,0);
}
void MenuEntry2() {
ReefAngel.WaterChangeModeStart();
ReefAngel.ClearScreen(DefaultBGColor);
DrawWaterChangeScreen();
}
void MenuEntry3() {
ReefAngel.SetupCalibratePH();
}
void MenuEntry4() {
//ReefAngel.DisplayMenuEntry("Relay Control");
// I am Creating menu to turn on and off the Relay Box's ports
ReefAngel.StartSetupDateTime(); //Just a place holder
}
void MenuEntry5()
{
DCPumpSettingScreen();
}
void MenuEntry6() {
ReefAngel.DisplayVersion(); // Just Because...
}
void DrawCustomMain() {
const int NumScreens=3;
switch (ScreenID) {
case 0:
{
//Parameters and Chart small relay box
DrawScreen1();
break;
}
case 1:
{
//Parameters and nice relay box
DrawScreen2();
break;
}
case 2:
{
//DC Pump settings
DrawScreen3();
break;
}
}
//loop between screens
if (ReefAngel.Joystick.IsLeft()) {
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID--;
drawGraph=true;
}
if (ReefAngel.Joystick.IsRight()) {
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID++;
drawGraph=true;
}
if (ScreenID<0) ScreenID=NumScreens-1;
if (ScreenID>=NumScreens) ScreenID=0;
}
void DrawScreen1(){
// Main Header
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 31, 2,"Alekos's Reef");
ReefAngel.LCD.DrawDate(5,2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 128, 11);
// Param Header
DrawParams(5,14);
DrawStatus(5,35);
// Draw Relays
DrawRelays(13,116);
// Draw chart
if (drawGraph) {
ReefAngel.LCD.DrawGraph(5, 62);
drawGraph=false;
}
}
void DrawScreen2(){
// Main Header
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 31, 2,"Alekos's Reef");
ReefAngel.LCD.DrawDate(5,2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 128, 11);
// Param Header
DrawParams(5,14);
DrawStatus(5,35);
DrawRelaysBox(0,55);
// The Below code was moved to its own screen a better one from Draw2014Main()
//char jebaomsg[32];
//String PUMP_MODES[] = {"Constant","Lagoon","ReefCrest","Short Pulse","Long Pulse","Nutrient Trans.","Tidal Swell","Feeding","FeedingAndNightStop","Night","Storm","Custom","Else","Sine","Gyre"};
//char buf[16];
//PUMP_MODES[ReefAngel.DCPump.Mode].toCharArray(buf,16);
//sprintf(jebaomsg,"M:%s-%d s:%d d:%d ms",buf,pmode,InternalMemory.DCPumpSpeed_read(),InternalMemory.DCPumpDuration_read());
//ReefAngel.LCD.DrawText(COLOR_INDIGO,DefaultBGColor,2,62,jebaomsg);
}
//Modified From Draw2014Main()
void DrawScreen3(){
const unsigned PROGMEM char BAR_I_LEFT[] = {
0xAB, 0xAB, 0xAF, 0xD3, 0xD7, 0xFB};
const unsigned PROGMEM char BAR_CENTER[] = {
0x92, 0x92, 0xFF, 0xFF, 0xFF, 0xFF, 0xDB, 0xDB, 0xB6, 0xB6, 0xB6, 0xB6};
const unsigned PROGMEM char BAR_I_RIGHT[] = {
0xB7, 0xB7, 0xB7, 0xDB, 0xDB, 0xDB};
byte x,y,w;
char text[7];
char buf[16];
String PUMP_MODES[] = {"Constant","Lagoon","ReefCrest","Short Pulse","Long Pulse","Nutrient Trans.","Tidal Swell","Feeding","Feeding Stop","Night","Storm","Custom","Else","Sine","Gyre"};
x=5;
y=5;
ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE,40,y,"DC Pump");
y+=20;
ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE,x,y,"Mode");
y+=25;
ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE,x,y,"Duration");
y+=25;
ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE,x,y,"Speed");
y+=25;
ReefAngel.LCD.DrawLargeText(COLOR_BLACK,COLOR_WHITE,x,y,"Threshold");
y=33;
PUMP_MODES[ReefAngel.DCPump.Mode].toCharArray(buf,16);
ReefAngel.LCD.DrawLargeText(COLOR_DARKGREEN,DefaultBGColor,x,y,buf);
ReefAngel.LCD.Clear(DefaultBGColor,(PUMP_MODES[ReefAngel.DCPump.Mode].length()*8)+5,y,131,y+7);
y+=25;
ConvertNumToString(text, ReefAngel.DCPump.Duration, 1);
ReefAngel.LCD.DrawLargeText(COLOR_DARKGREEN,DefaultBGColor,x,y,text);
y+=25;
w=ReefAngel.DCPump.Speed;
ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor, 110,y," ");
ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor, 110,y,w);
for(int b=0; b<w; b++)
ReefAngel.LCD.DrawImage(1,6,b+5,y+2,BAR_I_LEFT);
ReefAngel.LCD.DrawImage(2,6,w+5,y+2,BAR_CENTER);
for(int b=w; b<100; b++)
ReefAngel.LCD.DrawImage(1,6,b+7,y+2,BAR_I_RIGHT);
y+=25;
ConvertNumToString(text, ReefAngel.DCPump.Threshold, 1);
ReefAngel.LCD.DrawLargeText(COLOR_DARKGREEN,DefaultBGColor,x,y,text);
}
void DrawWaterChangeScreen(){
// Main Header
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 31, 2,"Alekos's Reef");
ReefAngel.LCD.DrawDate(5,2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 128, 11);
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,1,12,"Water Change Mode");
// to display the relay box to ensre the right ports a off/on
DrawRelaysBox(0,0);
}
void DrawCustomGraph() {
if (ScreenID==0)
ReefAngel.LCD.DrawGraph(5, 62);
}
//Copied from lnevo, thanks
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[T2_PROBE], 10);
ReefAngel.LCD.DrawText(T2TempColor, DefaultBGColor, x+45, y, buf);
y+=6;
ConvertNumToString(buf, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawLargeText(T1TempColor, DefaultBGColor, x+6, y, buf, Num8x16);
ConvertNumToString(buf, ReefAngel.Params/dot/PH, 100); // Replace /dot/ for a period the forum didn't allowed this thinking it is an url
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+80, y, buf, Num8x16);
y+=5;
ConvertNumToString(buf, ReefAngel.Params.Temp[T3_PROBE], 10);
ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, x+45, y, buf);
}
//Copied from lnevo, thanks
void DrawRelays(int x, int y) {
// Draw Relays
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
/* //Extendsion Boxes
y+=12;
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
y+=12;
TempRelay = ReefAngel.Relay.RelayDataE[1];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[1];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[1];
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
*/
}
void DrawRelaysBox(int x, int y) {
// Draw Relays
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawCircleOutletBox(x+56,y+36,TempRelay);
//pingSerial();
ReefAngel.LCD.DrawLargeText(0,255,x+27,y+22,"RelayBox 1");
ReefAngel.LCD.DrawText(0,255,x+3,y+32,"MainPump"); //1
ReefAngel.LCD.DrawText(0,255,x+8,y+42,"Skimmer"); //3
ReefAngel.LCD.DrawText(0,255,x+7,y+52,"PwrHead"); //5
ReefAngel.LCD.DrawText(0,255,x+13,y+62,"Unused"); //7
ReefAngel.LCD.DrawText(0,255,x+75,y+32,"Ref Pump"); //2
ReefAngel.LCD.DrawText(0,255,x+75,y+42,"Reactor"); //4
ReefAngel.LCD.DrawText(0,255,x+75,y+52,"Ref Light"); //6
ReefAngel.LCD.DrawText(0,255,x+75,y+62,"Drum Pump"); //8
}
void DrawStatus(int x, int y) {
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,21,y,"High",Font8x16);
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,21,y+15,"Drum",Font8x16);
if (ReefAngel.HighATO.IsActive()) {
ReefAngel.LCD.FillCircle(11,y+3,5,COLOR_GREEN);
ReefAngel.LCD.DrawText(COLOR_GREEN,DefaultBGColor,53,y,"(Normal) ");
}
else {
ReefAngel.LCD.FillCircle(11,y+3,5,COLOR_RED);
ReefAngel.LCD.DrawText(COLOR_RED,DefaultBGColor,53,y,"(High level)");
}
if (ReefAngel.LowATO.IsActive()) {
ReefAngel.LCD.FillCircle(11,y+17,5,COLOR_GREEN);
ReefAngel.LCD.DrawText(COLOR_GREEN,DefaultBGColor,53,y+15,"(Normal) ");
}
else {
ReefAngel.LCD.FillCircle(11,y+17,5,COLOR_RED);
ReefAngel.LCD.DrawText(COLOR_RED,DefaultBGColor,53,y+15,"(Empty) ");
}
}
//parts copied and modified from 89delta Thanks
void runDCPump()
{
// Jebao Code
//ReefAngel.DCPump.SetMode( MODE,%SPEED,DURATION ms );
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { ReefCrest, Gyre, Lagoon, Constant, TidalSwell, ShortPulse, LongPulse, Else};
if (now()%SECS_PER_DAY<=2) { // Change at midnight
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<900) {
// Do Feeding mode for 15 minutes
ReefAngel.DCPump.Mode=NutrientTransport; // Maybe Feeding_Start I think this is for RF Only (Vortex)
ReefAngel.DCPump.Speed=5; // adjust for really low speed
}
else if (now()%SECS_PER_DAY>=75600 || now()%SECS_PER_DAY<32400) { // Between 9 pm and 9 am
// Night mode (go to 30% or lower)
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Speed=30; // lower depends how loud or fast this is.
}
else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
//ReefAngel.DCPump.Threshold=InternalMemory.DCPumpThreshold_read();// Set Threshold from portal
}
else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
}
//Menu screen to change DCPump settings
void DCPumpSettingScreen(){
// Drawing the screen
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,3,3,"DC Pump Settings");
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 128, 11);
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 25, "Mode:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 45, "Duration:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 65, "Speed:");
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 85, "Threshold:");
//initializing Some variables
byte setup_dcpump_option;
char buf[16];
char *dcpump_mode[15] = { "Constant ","Lagoon ","Reef Crest ","Short Pulse ","Long Pulse ","Nutrient Trans.","Tidal Swell ","Feeding ","Feeding Stop ","Night ","Storm ","Custom ","Else ","Sine ","Gyre "};
bool done = false;
bool page_refresh = true;
enum{
SETUP_DCPUMP_MODE,
SETUP_DCPUMP_DURATION,
SETUP_DCPUMP_SPEED,
SETUP_DCPUMP_THRESHOLD,
SETUP_DCPUMP_CANCEL,
SETUP_DCPUMP_OK
};
setup_dcpump_option=SETUP_DCPUMP_MODE;
//Pulling DCPump settings from memory
ReefAngel.DCPump.UseMemory=true;
int pmodeindex = InternalMemory.DCPumpMode_read();
int pduration = InternalMemory.DCPumpDuration_read();
int pspeed = InternalMemory.DCPumpSpeed_read();
int pthreshold = InternalMemory.DCPumpThreshold_read();
do{
if(page_refresh)
{
ReefAngel.LCD.DrawSelect(dcpump_mode[pmodeindex], setup_dcpump_option==SETUP_DCPUMP_MODE?1:0, 37, 25, 1);
ReefAngel.LCD.DrawOption(pduration, setup_dcpump_option==SETUP_DCPUMP_DURATION?1:0, 60, 45, "", "", 2);
ReefAngel.LCD.DrawOption(pspeed, setup_dcpump_option==SETUP_DCPUMP_SPEED?1:0, 42, 65, "", "", 2);
ReefAngel.LCD.DrawOption(pthreshold, setup_dcpump_option==SETUP_DCPUMP_THRESHOLD?1:0, 65, 85, "", "", 2);
ReefAngel.LCD.DrawOK(setup_dcpump_option==SETUP_DCPUMP_OK?1:0);
ReefAngel.LCD.DrawCancel(setup_dcpump_option==SETUP_DCPUMP_CANCEL?1:0);
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 95, " ");
//ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 4, 95, pmodeindex);
page_refresh = !page_refresh;
}else{
ReefAngel.Refresh();// not really refreshing the page is to avoid a blank screen
}
if(ReefAngel.Joystick.IsUp())
{
switch(setup_dcpump_option)
{
case SETUP_DCPUMP_MODE:
{
pmodeindex--;
if(pmodeindex<0){
pmodeindex=14;
}
}
break;
case SETUP_DCPUMP_DURATION:
{
pduration++;
if(pduration>99){
pduration=0;
}
}
break;
case SETUP_DCPUMP_SPEED:
{
pspeed++;
if(pspeed>99){
pspeed=0;
}
}
break;
case SETUP_DCPUMP_THRESHOLD:
{
pthreshold++;
if(pthreshold>99){
pthreshold=0;
}
}
break;
}
page_refresh = !page_refresh;
}
if(ReefAngel.Joystick.IsDown())
{
switch(setup_dcpump_option)
{
case SETUP_DCPUMP_MODE:
{
pmodeindex++;
if(pmodeindex>14){
pmodeindex=0;
}
}
break;
case SETUP_DCPUMP_DURATION:
{
pduration--;
if(pduration<0){
pduration=99;
}
}
break;
case SETUP_DCPUMP_SPEED:
{
pspeed--;
if(pspeed<0){
pspeed=99;
}
}
break;
case SETUP_DCPUMP_THRESHOLD:
{
pthreshold--;
if(pthreshold<0){
pthreshold=99;
}
}
break;
}
page_refresh = !page_refresh;
}
if(ReefAngel.Joystick.IsLeft())
{
setup_dcpump_option--;
if (setup_dcpump_option>SETUP_DCPUMP_OK)
{
setup_dcpump_option=SETUP_DCPUMP_OK;
}
page_refresh = !page_refresh;
}
if(ReefAngel.Joystick.IsRight())
{
setup_dcpump_option++;
if (setup_dcpump_option>SETUP_DCPUMP_OK)
{
setup_dcpump_option=SETUP_DCPUMP_MODE; //The first option. since im testing Cancel is the first option
}
page_refresh = !page_refresh;
}
if(ReefAngel.Joystick.IsButtonPressed())
{
if(setup_dcpump_option==SETUP_DCPUMP_OK||setup_dcpump_option==SETUP_DCPUMP_CANCEL)
{
if(setup_dcpump_option==SETUP_DCPUMP_OK)
{
// COMMIT THE CHANGES HERE
//ReefAngel.DCPump.UseMemory=true;
InternalMemory.DCPumpMode_write(pmodeindex);
//ReefAngel.DCPump.Mode=pmodeindex;
InternalMemory.DCPumpSpeed_write(pspeed);
//ReefAngel.DCPump.Speed=pspeed;
InternalMemory.DCPumpDuration_write(pduration);
//ReefAngel.DCPump.Duration=pduration;
InternalMemory.DCPumpThreshold_write(pthreshold);
//ReefAngel.DCPump.Threshold=pthreshold;
ReefAngel.ClearScreen(DefaultBGColor);
ReefAngel.DCPump.UseMemory=true;
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE; //Go Back to Menu
//ReefAngel.DisplayedMenu=DEFAULT_MENU;// Go Back to Main Screen
}else{
ReefAngel.ClearScreen(DefaultBGColor);
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE; //Go Back to Menu
//ReefAngel.DisplayedMenu=DEFAULT_MENU;// Go Back to Main Screen
}
page_refresh = !page_refresh;
done=true;
}
}
}while(!done);
}
// Not using code below at the moment
void WaterFill(bool stat)
{
if(stat = 0){
ReefAngel.Relay.Off(REFPUMP);
}
else{
ReefAngel.Relay.On(REFPUMP);
}
}
void saving_stuff(){
int pmode;
switch (ReefAngel.DCPump.Mode)
{
case Constant:
{
pmode=0;
break;
}
case Lagoon:
{
pmode=1;
break;
}
case ReefCrest:
{
pmode=2;
break;
}
case ShortPulse:
{
pmode=3;
break;
}
case LongPulse:
{
pmode=4;
break;
}
case NutrientTransport:
{
pmode=5;
break;
}
case TidalSwell:
{
pmode=6;
break;
}
case Feeding_Start:
{
pmode=7;
break;
}
case Feeding_Stop:
{
pmode=8;
break;
}
case Night:
{
pmode=9;
break;
}
case Storm:
{
pmode=10;
break;
}
case Custom:
{
pmode=11;
break;
}
case Else:
{
pmode=12;
break;
}
case Sine:
{
pmode=13;
break;
}
case Gyre:
{
pmode=14;
break;
}
}
}