Updated and trouble with code
Posted: Fri Jun 28, 2013 1:58 pm
Ive updated my library and now my code isn't working.
This is my current code, which was working until i just updated. Thanks in advance for any help!
This is my current code, which was working until i just updated. Thanks in advance for any help!
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 <ReefAngel.h>
////// Place global variable code below here
byte vtechmode=0;
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.AddStandardMenu(); // Add Standard Menu
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port5Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
// 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,13,30,18,0 );
ReefAngel.StandardLights( Port2,13,00,00,00 );
ReefAngel.DosingPumpRepeat( Port3,0,120,240 );
ReefAngel.DosingPumpRepeat( Port4,29,120,360 );
ReefAngel.StandardHeater( Port6,779,785 );
////// Place your custom code below here
if (hour()>=8 && hour()<11)
{
vtechmode=6;
ReefAngel.PWM.SetDaylight( TidalSwellMode(50,true) ); // Tidal Swell at 50% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(50,false) ); // Tidal Swell at 50% on anti-sync mode
}
else if (hour()>=11 && hour()<12)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ReefCrestMode(60,20,true) ); // ReefCrest at 60% + - 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(60,20,false) ); // ReefCrest at 60% + - 20 on anti-sync mode
}
else if (hour()>=12 && hour()<13)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% + - 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(70,20,false) ); // ReefCrest at 70% + - 20 on anti-sync mode
}
else if (hour()>=13 && hour()<14)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ReefCrestMode(80,20,true) ); // ReefCrest at 80% + - 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(80,20,false) ); // ReefCrest at 80% + - 20 on anti-sync mode
}
else if (hour()>=15 && hour()<18)
{
vtechmode=5;
ReefAngel.PWM.SetDaylight( NutrientTransportMode(77,90,1500,true) ); // Nutrient Transport on sync mode
ReefAngel.PWM.SetActinic( NutrientTransportMode(77,90,1500,false) ); // Nutrient Transport on anti-sync mode
}
else if (hour()>=18 && hour()<21)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ElseMode(70,30,true) ); // ReefCrest at 70% + - 15 on sync mode
ReefAngel.PWM.SetActinic( ElseMode(70,30,false) ); // ReefCrest at 70% + - 15 on anti-sync mode
}
else if (hour()>=21 && hour()<24)
{
vtechmode=6;
ReefAngel.PWM.SetDaylight( millis()%1200>800?80:0); // Tidal Swell at 60% on sync mode
ReefAngel.PWM.SetActinic( millis()%1200<400?0:80); // Tidal Swell at 60% on anti-sync mode
}
else
{
vtechmode=4;
ReefAngel.PWM.SetDaylight( LongPulseMode(40,40,10,true) ); // Long pulse at 40% with 10s pulse on syncy mode
ReefAngel.PWM.SetActinic( LongPulseMode(40,40,10,false) ); // Long pulse at 40% with 10s pulse on on anti-sync mode
}
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.ShowInterface();
}
//*********************************************************************************************************************************
//Custom Main, Graph & Menu
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
char text[7];
ReefAngel.LCD.DrawDate(6, 4);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
ReefAngel.LCD.DrawLargeText(0,255,10,16," WP40 Mode:");
if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,27,"Constant");
else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,26,"Lagoon");
else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,26,"Reef Crest");
else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,26,"Short Pulse");
else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,26,"Long Pulse");
else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,26,"Nutrient Trnsp.");
else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Tidal Swell");
else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,255,45,26,"Night");
ReefAngel.LCD.DrawLargeText(0,255,17,49,"Sump");
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawHugeText(COLOR_RED, 255, 12, 65, text, Num12x16);
pingSerial();
ReefAngel.LCD.DrawLargeText(0,255,100,40,"pH");
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(COLOR_BLUE, 255, 89, 55, text, Num8x8);
pingSerial();
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,15,89, "WP40L");
ReefAngel.LCD.DrawText(COLOR_BLACK,255,20,100, ReefAngel.PWM.GetDaylightValue());
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,88,89, "WP40R");
ReefAngel.LCD.DrawText(COLOR_BLACK,255,95,100, ReefAngel.PWM.GetActinicValue());
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 113, TempRelay);
}
void DrawCustomGraph()
{
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}