Lee, looking for some assistance with the code you've posted or what I might be missing.
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 <ReefAngel.h>
/*Port Designations
Port1 - Dosing Pump 1 (every 60min for 10s)
Port2 - Dosing Pump 2 (every 60min for 10s w/5 min offset)
Port3 - Left Radion
Port4 - Right Radion
Port5 - Heater
Port6 - ATO
Port7 - Skimmer
Port8 - Return
Box1_Port1 - Vortech
Box1_Port2 - Cabinet LED
*/
// Define Relay Ports by Name
#define DPump1 1
#define DPump2 2
#define LeftRadion 3
#define RightRadion 4
#define Heater 5
#define ATOPort 6
#define Skimmer 7
#define Return 8
#define Vortech Box1_Port1
#define CabinetLED Box1_Port2
#define Unused Box1_Port3
#define Unused Box1_Port4
#define Unused Box1_Port5
#define Unused Box1_Port6
#define Unused Box1_Port7
#define Unused Box1_Port8
// Initialize Buzzer variables
byte buzzer=0;
byte overheatflag=0;
byte atoflag=0;
////// Place global variable code below here
time_t running1, running2; //Records run time for dosing pumps (i.e. running1 = time for DP1)
////// 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 = Port8Bit;
ReefAngel.FeedingModePortsE[0] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
ReefAngel.LightsOnPortsE[0] = Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port7Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( LeftRadion );
ReefAngel.Relay.On( RightRadion );
ReefAngel.Relay.On( Return );
ReefAngel.Relay.On( Vortech );
// ATO locked on for now
ReefAngel.Relay.On( ATOPort );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.DosingPumpRepeat1( DPump1 ); //every 60min for 10s
// Other format ReefAngel.DosingPumpRepeat( Port3,10,360,10 );
ReefAngel.DosingPumpRepeat2( DPump2 ); //every 60min for 10s w/5 min offset
ReefAngel.StandardHeater( Heater );
// ReefAngel.StandardATO( ATOPort );
ReefAngel.Relay.DelayedOn( Skimmer );
ReefAngel.Relay.Set( CabinetLED, !ReefAngel.Relay.Status( Vortech ) );
ReefAngel.PWM.SetActinic( MoonPhase() );
ReefAngel.RF.UseMemory = true;
ReefAngel.RF.ChannelWhiteParabola();
ReefAngel.RF.ChannelRoyalBlueParabola();
ReefAngel.RF.ChannelRedParabola();
ReefAngel.RF.ChannelGreenParabola();
ReefAngel.RF.ChannelBlueParabola();
ReefAngel.RF.ChannelIntensityParabola();
overheatflag = InternalMemory.read( Overheat_Exceed_Flag );
atoflag = InternalMemory.read( ATO_Exceed_Flag );
buzzer = overheatflag + atoflag;
if ( buzzer >= 1 ) buzzer = 100;
ReefAngel.PWM.SetDaylight( buzzer );
////// Place your custom code below here
//*******************Dosing and ATO Pump Logging************************
const byte numPumps=3;
byte pump[numPumps] = { DPump1, DPump2, ATOPort };
byte portalMinutes[numPumps] = { 0, 2, 4 };
byte portalSeconds[numPumps] = { 1, 3, 5 };
static time_t pumpTimer[numPumps];
static boolean pumpStatus[numPumps];
static boolean atoDisabled;
static boolean clearTimer;
if (now()%SECS_PER_DAY!=SECS_PER_DAY-1) clearTimer=true;
if ( (now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer==true) {
// Backup timers to portal variable
ReefAngel.CustomVar[portalSeconds[0]] = pumpTimer[0]/60;
ReefAngel.CustomVar[portalSeconds[1]] = pumpTimer[1]/60;
ReefAngel.CustomVar[portalSeconds[2]] = pumpTimer[2]/60;
pumpTimer[0]=0; // Clear timer for DPump1
pumpTimer[1]=0; // Clear timer for DPump2
clearTimer=false;
}
for (int i=0;i< numPumps;i++) {
if (ReefAngel.Relay.Status(pump[i])) {
if (!pumpStatus[i]) {
pumpTimer[i]=now()-pumpTimer[i]; // Pump was off, timer is now a time
pumpStatus[i]=true;
}
} else {
if (pumpStatus[i]) {
pumpTimer[i]=now()-pumpTimer[i]; // Pump was on, timer is now a timer
pumpStatus[i]=false;
// Normalize and assign to CustomVar for reporting on the portal
ReefAngel.CustomVar[portalMinutes[i]]=pumpTimer[i]/60; // Number of Minutes
// ReefAngel.CustomVar[portalSeconds[i]]=pumpTimer[i]%60; // Number of Seconds
}
}
}
if (now()%SECS_PER_DAY==SECS_PER_DAY-1) {
// Backup timers to portal variable
ReefAngel.CustomVar[portalSeconds[0]] = pumpTimer[0]/60;
ReefAngel.CustomVar[portalSeconds[1]] = pumpTimer[1]/60;
ReefAngel.CustomVar[portalSeconds[2]] = pumpTimer[2]/60;
pumpTimer[0]=0; // Clear timer for Port3
pumpTimer[1]=0; // Clear timer for Port4
}
if (bitRead(ReefAngel.Relay.RelayMaskOff, 6)==0) { // ATO relay is manually disabled
atoDisabled=true;
}
if (atoDisabled && (bitRead(ReefAngel.Relay.RelayMaskOff, 6)==1)) { // ATO override has been cleared
pumpTimer[2]=0; // Clear timer for Port7
atoDisabled=false;
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "alexwbush" );
ReefAngel.ShowInterface();
}
// Add this for more than 1 screen
#define NumScreens 2
int ScreenID=0;
void DrawCustomMain()
{
switch (ScreenID)
{
case 0:
{
//Draw screen 0
byte x = 6;
byte y = 2;
byte t;
byte radionchannel=0;
byte radiontext=0;
byte radioncolor=0;
char text[7];
/* Drawing this:
01/01/12 00:00:00 AM
----------------------
Disp 79.9 pH 8.00
Sump 79.9 Sal 0.60
Room 77.7 WtrLvl Ok
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Moon Waning Crescent
Intensity 88%
Sunrise 06:15
Sunset 18:12
*/
/* Colors used in this script:
DefaultFGColor - For basic font and line
DefaultBGColor - For background color
PHColor - For values that may change
OutletOnBGColor - For okay water level
OutletOffBGColor - For low water level
To change colors, modify these values in ReefAngel_CustomColors.h file
*/
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(DefaultFGColor, 1, 11, 128, 11);
pingSerial();
//ReefAngel.LCD.DrawText(fcolor,bcolor,x,y,"text");
//Line 1 - Display Temp & pH
x = 8;
y = 15;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Disp");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"pH");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, x, y, 100);
//Line 2 - Sump & Salinity
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sump");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sal");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Salinity, PHColor, x, y, 10);
//Line 3 - Room
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Room");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], PHColor, x, y, 10);
x = 70;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"WL");
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.WaterLevel.GetLevel(), PHColor, x, y, 1);
//Lines 4 and 5 - Relays
x = 12;
y += 12;
// draw main relay
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);
y +=12;
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(x, y, TempRelay );
pingSerial();
pingSerial();
break;
}
case 1:
{
//Draw quick screen
byte x = 6;
byte y = 2;
byte t;
byte radionchannel=0;
byte radiontext=0;
byte radioncolor=0;
char text[7];
/* Drawing this:
01/01/12 00:00:00 AM
----------------------
79.9 79.7 77.7 34.5
Sump 79.9 Sal 34.5
Room 77.7 WtrLvl 77
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Moon Waning Crescent
Intensity 88%
Sunrise 06:15
Sunset 18:12
*/
/* Colors used in this script:
DefaultFGColor - For basic font and line
DefaultBGColor - For background color
PHColor - For values that may change
OutletOnBGColor - For okay water level
OutletOffBGColor - For low water level
To change colors, modify these values in ReefAngel_CustomColors.h file
*/
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(DefaultFGColor, 1, 11, 128, 11);
pingSerial();
//ReefAngel.LCD.DrawText(fcolor,bcolor,x,y,"text");
//Line 1 - Display Temp & pH
x = 8;
y = 15;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], PHColor, x, y, 10);
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], PHColor, x, y, 10);
x += 30;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], PHColor, x, y, 10);
x += 40;
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Salinity, PHColor, x, y, 10);
//Line 3
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Work in Progress");
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Push Joystick Left");
x = 8;
y += 10;
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"to return to main display");
break;
}
}
if (ReefAngel.Joystick.IsLeft())
{
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID--;
}
if (ReefAngel.Joystick.IsRight())
{
ReefAngel.ClearScreen(DefaultBGColor);
ScreenID++;
}
if (ScreenID<0) ScreenID=NumScreens-1;
if (ScreenID>=NumScreens) ScreenID=0;
}
// PWM Parameters
/*#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
*/
void DrawCustomGraph()
{
}
Ignore all the silly stuff I am playing with still, I edited them out to get this working.
When I go to the variables, I don't even see a chart. Any ideas?