multiple wave pattern
Posted: Mon Apr 29, 2013 7:05 pm
OK so I inserted some wave pattern codes does this look right? I'm not sure if there needs to be something in the void setup or void loop section or not. If so can you help me with that? The Things I added or changed are in bold
#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Port1,9,0,22,0 );
ReefAngel.StandardLights( Port2,10,45,21,15 );
ReefAngel.StandardLights( Port3,11,15,20,45 );
ReefAngel.StandardLights( Port4,22,0,2,0 );
ReefAngel.StandardHeater( Port5,775,780 );
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place your custom code below here
////// Place your custom code above here
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{ if (hour()>=10 && hour()<14)
static unsigned long lastwavemillis=millis();
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > 5000)
{
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,60);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
else (hour()>=14:01 && hour()<22)
byte SineMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync) {
double x,y;
x=double(now()%(PulseDuration));
x/=PulseDuration;
x*=2.0*PI;
if (!PulseSync) x+=PI; // shift the sine wave for the right pump
y=sin(x);// y is now between -1 and 1
y+=1.0; // y is now between 0 and 2
y/=2.0; // y is now between 0 and 1
// now compute the tunze speed
y*=double(PulseMaxSpeed-PulseMinSpeed);
y+=double(PulseMinSpeed);
y+=0.5; // for proper rounding
// y is now between PulseMinSpeed and PulseMaxSpeed, constrain for safety
return constrain(byte(y),25,60);
}
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}
#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 820 );
// Ports that are always on
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Port1,9,0,22,0 );
ReefAngel.StandardLights( Port2,10,45,21,15 );
ReefAngel.StandardLights( Port3,11,15,20,45 );
ReefAngel.StandardLights( Port4,22,0,2,0 );
ReefAngel.StandardHeater( Port5,775,780 );
ReefAngel.Relay.DelayedOn( Port6,5 );
////// Place your custom code below here
////// Place your custom code above here
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{ if (hour()>=10 && hour()<14)
static unsigned long lastwavemillis=millis();
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > 5000)
{
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,60);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
else (hour()>=14:01 && hour()<22)
byte SineMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync) {
double x,y;
x=double(now()%(PulseDuration));
x/=PulseDuration;
x*=2.0*PI;
if (!PulseSync) x+=PI; // shift the sine wave for the right pump
y=sin(x);// y is now between -1 and 1
y+=1.0; // y is now between 0 and 2
y/=2.0; // y is now between 0 and 1
// now compute the tunze speed
y*=double(PulseMaxSpeed-PulseMinSpeed);
y+=double(PulseMinSpeed);
y+=0.5; // for proper rounding
// y is now between PulseMinSpeed and PulseMaxSpeed, constrain for safety
return constrain(byte(y),25,60);
}
// This should always be the last line
ReefAngel.Portal( "saltygxp" );
ReefAngel.ShowInterface();
}