Smotz Code

Share you PDE file with our community

Posts: 411
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA
PostPosted: Wed May 29, 2013 11:40 am
To save it somewhere else ... :D

Code: Select all
////  Port 1         Heater
////  Port 2         ATO pump
////  Port 3         Reactor Pump
////  Port 4         Protien Skimmer
////  Port 5         Return Pump
////  Port 6         Wavemaker
////  Port 7                    UV Sterilizer
////  Port 8                    Fuge Light
////  Always on - Lights & Salinity Module


#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

#define Heater Port1
#define Topoff Port2
#define Reactor Port3
#define Skimmer Port4
#define Return Port5
#define Wave Port6
#define UVlight Port7
#define Fugelight Port8

#define FugelightBit   1<<7
#define UVlightBit   1<<6
#define WaveBit   1<<5
#define ReturnBit   1<<4
#define SkimmerBit   1<<3
#define ReactorBit   1<<2
#define TopoffBit   1<<1
#define HeaterBit   1<<0

static byte wpMode;
static byte wpWavStr;
static byte wpWavOff;



////// 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 = TopoffBit | ReactorBit | SkimmerBit | ReturnBit | UVlightBit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = HeaterBit | TopoffBit | ReactorBit | SkimmerBit | ReturnBit | WaveBit | UVlightBit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = FugelightBit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = HeaterBit | TopoffBit | ReactorBit | SkimmerBit | ReturnBit | WaveBit | UVlightBit;

  // Use T1 (SUMP) probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;

  // Ports that are always on
  ReefAngel.Relay.On( Return );
  ReefAngel.Relay.On( Reactor );
  ReefAngel.Relay.On( Wave );

  ////// Place additional initialization code below here


    ////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.StandardHeater( Heater );
  ReefAngel.StandardATO( Topoff );
  ReefAngel.MoonLights( Fugelight );

  ////// Place your custom code below here



  ReefAngel.LCD.DrawText(0,255,20,80,"Joe's Reef Tank");

  ReefAngel.Relay.DelayedOn(Skimmer,2);
  ReefAngel.Relay.DelayedOn(UVlight,1);

  ReefAngel.PWM.SetActinic(100);

  //Feeding Mode set the Waves to 30%
  if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
    ReefAngel.PWM.SetDaylight(30);
    ReefAngel.PWM.SetActinic(30);       
  }
  // IF not in feeding mode   
  else {

    wpWavOff=12;      //Set the Wave OffSet   

    // Set Wave Str
    if (wpMode=1) wpWavStr=45;
    if (wpMode=2) wpWavStr=50;
    if (wpMode=3) wpWavStr=55;

    ReefAngel.PWM.SetDaylight( ReefCrestMode(wpWavStr,wpWavOff,false) );

    if ( (hour() >= 5) && (hour() < 8) ) wpMode=1;       // from 5a - 8a
    if ( (hour() >= 8) && (hour() < 11) ) wpMode=2;      // from 8a - 11a
    if ( (hour() >= 11) && (hour() < 14) ) wpMode=3;     // from 11a - 2pm
    if ( (hour() >= 14) && (hour() < 17) ) wpMode=2;      // from 2pm - 5pm
    if ( (hour() >= 17) && (hour() < 20) ) wpMode=1;     // from 5pm - 8pm
    if ( (hour() >= 20) && (hour() < 23) ) wpMode=2;     // from 8pm - 11p
    if ( (hour() >= 23) && (hour() < 2) ) wpMode=3;      // from 11pm - 2am
    if ( (hour() >= 2) && (hour() < 5) ) wpMode=2;       // from 2am - 5am
  }

  //  Only turn on UV Sterilizer between 11pm and 5am
  if ( (hour() >= 5) && (hour() < 23) )  // from 5a - 11p
  {
    ReefAngel.Relay.Off(UVlight);
  }
  else {
    ReefAngel.Relay.On(UVlight);
  }

  ////// Place your custom code above here

  // This should always be the last line
  ReefAngel.Portal( "Smotz" );
  ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
  int x,y;
  char text[10];
  char buf[16];

  sprintf(buf,"RC %d% +/-%d%",wpWavStr,wpWavOff);

  // WP40 Mode
  x = 15;
  y = 52;
  ReefAngel.LCD.DrawText(0,255,x,y,"RF:");
  ReefAngel.LCD.Clear(DefaultBGColor,x,y,128-x,y+8);

  if (wpMode == 0) ReefAngel.LCD.DrawText(COLOR_GREEN,255,x,y,"Feeding");
  else ReefAngel.LCD.DrawText(0,255,x,y,buf);

  // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
  ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
  ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
  pingSerial();

  // Salinity
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,66, "SAL:" );
  ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,66, ReefAngel.Params.Salinity );
  pingSerial();

  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
  pingSerial();

  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
  pingSerial();
}

void DrawCustomGraph()
{
}








Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 2 guests