Code: Select all
if (now()%SECS_PER_DAY==600 || changeMode==true) { // Change every 10 mins or if controller rebooted
Try changing it to this.
Code: Select all
if (now()%600==0 || changeMode==true) {
Code: Select all
if (now()%SECS_PER_DAY==600 || changeMode==true) { // Change every 10 mins or if controller rebooted
Code: Select all
if (now()%600==0 || changeMode==true) {
Code: Select all
// Declare an integer (a whole number between -32,768 to 32,767) rmode
// and a boolean (false or true, 0 or 1) changeMode which is set to true.
// "static" means only initialize them once. Otherwise they would be reset
// every time loop loops around.
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
// modes[] is an array of bytes (whole numbers between 0 and 255).
byte modes[] = {
ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre };
// now() is a running tally of seconds since Jan 1, 1970. It's a big number.
// % is modulo, it returns the remainder from division. So, if the number of seconds ever
// divided by 600 is 0 (that is, every 600 seconds or 10 minutes) then this is true.
// The || means 'or'. '==' means 'is equal to'. So this line says 'if it's been 10 minutes,
// or changeMode is equal to true, then do this stuff in these curly braces.
if (now()%600==0 || changeMode==true) { // Change every 10 mins or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding; // another variable declaration, type unsigned long
// Difference between '==' and '=': '==' means 'is equal to' (comparing two things)
// '=' means 'make equal to' as in changing the value of something. So this line
// says if the menu displayed is equal to FEEDING_MODE, then make the variable 'feeding'
// equal to the number of seconds returned by the function now()
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
// if right now minus the time feeding was set is less than 3600 (seconds, remember now() returns
// seconds) then do the stuff in the curly braces.
if (now()-feeding<3600) {
// Continue NTM for the 60 minutes
ReefAngel.DCPump.UseMemory=false; // Turn off portal control of the pumps
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read(); // Get the portal pump duration from memory
ReefAngel.DCPump.Mode=NutrientTransport; // Manually set the mode to NutrientTransport
}
// so if the above 'if' isn't true, do the stuff after 'else'. If this thing is true, do this stuff, else do other stuff
// If it's been more than 60 minutes since feeding time, check to see if now (in seconds) divided by
// the number of seconds per day (86400 to be exact) returns a remainder of less than 43200 (noon)
// or greater than 79200 (10 PM, 2200) then do some stuff
else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false; // Turn off portal control of DC Pumps
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read(); // Get portal duration from memory location
ReefAngel.DCPump.Mode=Sine; // Set the mode to Sine
ReefAngel.DCPump.Speed=30; // With a speed of 30
}
// if the above isn't true, check this
else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode set on portal and nothing else going on (not feeding time, not night time)
ReefAngel.DCPump.UseMemory=false; // Turn off portal control of pumps
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read(); // Get the duration
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
}
// if none of this stuff was true, default to this
else {
// Do whatever the portal says to do with the DC Pumps
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
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 <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 = Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | 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( Port8 );
////// Place additional initialization code below here
// Password Protection username:xxxxxxx password:xxxxxxx
// ReefAngel.Network.WifiAuthentication("xxxxxx,xxxxxxx");
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DosingPumpRepeat1( Port1 );
ReefAngel.DosingPumpRepeat2( Port2 );
ReefAngel.ActinicLights( Port3 );
ReefAngel.DayLights( Port4 );
ReefAngel.MoonLights( Port5 );
ReefAngel.WavemakerRandom( Port6,120,1500 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = None;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
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, Lagoon, Constant, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre };
if (now()%600==0 || changeMode==true) { // Change every 10 mins or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<3600) {
// Continue NTM for the 60 minutes
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Sine;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "Reefology" );
ReefAngel.DDNS( "xxxxxxxx" ); // Your DDNS is Reefology-xxxxxxxx.myreefangel.com
ReefAngel.ShowInterface();
}
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 <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 = Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | 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
////// Place additional initialization code below here
// Password Protection username:xxxx password:xxxx
// ReefAngel.Network.WifiAuthentication("xxxx");
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DosingPumpRepeat1( Port1 );
ReefAngel.MoonLights( Port2 );
ReefAngel.ActinicLights( Port3 );
ReefAngel.DayLights( Port4 );
ReefAngel.WavemakerRandom1( Port5,120,1500 );
ReefAngel.WavemakerRandom2( Port6,180,1000 );
ReefAngel.StandardHeater( Port7 );
ReefAngel.DosingPumpRepeat2( Port8 );
ReefAngel.DCPump.ActinicChannel = AntiSync; // Now pump will be affected by the portal settings
// Comment out next 2 lines for single dc pump
// ReefAngel.DCPump.DaylightChannel = Sync; // Now pump will be affected by the portal settings
// ReefAngel.DCPump.AntiSyncOffset=100;
////// Place your custom code below here
// Wavemaker Koralia night mode
if (hour()>=22 || hour()<7) ReefAngel.Relay.Off (Port5 );
if (hour()>=23 || hour()<8) ReefAngel.Relay.Off (Port6 );
// DC pumps
// To run this code must choose Custom in portal
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };
if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<3000) {
// Continue NutrientTranspot Mode for 45 minutes
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Gyre;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "Reefology" );
ReefAngel.DDNS("xxxx"); // Your DDNS is Reefology-xxxx.myreefangel.com
ReefAngel.ShowInterface();
}
Code: Select all
// DC pumps
// To run this code must choose Custom in portal
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };
if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<3000) {
// Continue NutrientTranspot Mode for 45 minutes
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Gyre;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}
Code: Select all
// DC pumps
// To run this code must choose Custom in portal
static int rmode;
static boolean changeMode=true;
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };
if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
changeMode=false;
}
// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
if (now()-feeding<3000) {
// Continue NutrientTranspot Mode for 45 minutes
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
// Night mode (go to 30%)
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=Gyre;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) {
// Custom Mode and nothing else going on
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
} else {
ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
}