So here is my full code. So far seems to work well. Haven't gotten around to implementing ATO, but that will need to be done in the next week, as I'll be out of town for 5 days at the end of June.
The Feeding Mode add worked as expected and something that I've found very awesome is being able to control relay 5 manually via my iphone app, thus negating the need for 3 hands while holding the hose from a pump to do water changes, plug it in, and not spray everything! (continuing after code)
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
////// 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 = Port3Bit | Port7Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port6Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit | Port5Bit | Port8Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 830 );
// Ports that are always on
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port6 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port1,790,800 );
ReefAngel.Relay.DelayedOn( Port3,4 );
ReefAngel.StandardATO( Port7,250 );
ReefAngel.StandardHeater( Port8,770,790 );
////// Place your custom code below here
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(30);
}
else if (hour()>=6 && hour()<11) {
ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
} else if (hour()>=11 && hour()<15) {
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()>=15 && hour()<18) {
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
} else if (hour()>=18 && hour()<20) {
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()>=20 && hour ()<23) {
ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
} else {
ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
ReefAngel.PWM.SetActinic(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "markywmson" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
// Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Mark's Reef");
ReefAngel.LCD.DrawDate(6, 118);
pingSerial();
ReefAngel.LCD.DrawMonitor(15, 68, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(),
ReefAngel.PWM.GetActinicValue());
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 101, TempRelay);
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph(5, 11);
}
So my next quest on the powerhead portion of this would be 2 things. 1) since I have all those modes 'timelined' to happen at different times, is there a way to display that on the RA controller? (I'm sure the iphone app isn't there yet... I can see the different modes in the graph though). 2) is there a way to make it follow this logic...
-Sine mode overnight
-Tidal Swell in AM
-Reefcrest in early afternoon
-NTM in mid afternoon
-Reefcrest in late afternoon
-Tidal swell in PM
-Sine mode overnight
--> FEEDING MODE interrupts this timeline and sets power at 30 constant. //up to here my code is fine
--> Following FEEDING MODE interrupt the timeline with NTM for 3 hours, then resume timeline.
-->caveat... if this happens before NTM hits in the timeline (3p-6p), could the RA skip that NTM and
continue Reefcrest?
Thanks for any help! I'm actually starting to (kinda, sorta) understand this. Still can't write the code, but can steal and modify
-mark