jebo wp40

Basic / Standard Reef Angel hardware
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

jebo wp40

Post by 805reefer »

hey guys im not very good at this but is there away anyone can help me with coding what I'm looking for is to have my jebo turn off during feeding and water change mode and im using the short pulse mode right now what i want to do is at 11pm to 7am make it to where the pump is in a more calmer mode then the short pulse if anyone could help it would be really appreciated I'm trying to learn how to do this whole coding thing its not as easy as i thought it would be but thats the fun in it thank you
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: jebo wp40

Post by rimai »

Try this:

Code: Select all

  //Normal Mode
  ReefAngel.PWM.SetActinic(ShortPulseMode(30,70,500,true));
  ReefAngel.PWM.SetDaylight(ShortPulseMode(30,70,500,true));
  
  // Feeding and WC mode
  if( ReefAngel.DisplayedMenu==FEEDING_MODE || ReefAngel.DisplayedMenu==WATERCHANGE_MODE )
  {
    ReefAngel.PWM.SetActinic(0);
    ReefAngel.PWM.SetDaylight(0);
  }
  
  //Night Mode
  if (hour()>=23 || hour()<7)
  {
    ReefAngel.PWM.SetActinic(30);
    ReefAngel.PWM.SetDaylight(30);
  }
Roberto.
aloise

Re: jebo wp40

Post by aloise »

does this get placed in the custom code section?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: jebo wp40

Post by rimai »

Yeap :)
Roberto.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

thanks roberto you are the man this is why i sold my apex and got an RA now if i only can learn how to code lol
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

i have one more question if i was to use this code how would i make it work with only one pump I'm using my actinic port to control it i tried erasing just the day lights but it says error on mode 1

////// Place your custom code below here
static time_t feeding;

// Time schedule first
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
wpMode=1;
} 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
wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
} else if (hour()>=15 && hour()<18) {
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
wpMode=2;
} 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
wpMode=2;
} 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
wpMode=1;
} 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
wpMode=4;
}

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(30);
wpMode=0;
feeding=now();
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
}
////// Place your custom code above here
Sebyte

Re: jebo wp40

Post by Sebyte »

Instead of deleting the code just comment the lines out by placing // at the beginning of the line. You may have accidentally removed required code in some way.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: jebo wp40

Post by rimai »

I think you are missing the declaration of wpMode variable.
Add this after static time_t feeding;

Code: Select all

static byte wpMode;
Roberto.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

//Night Mode
if (hour()>=23 || hour()<7)
{
ReefAngel.PWM.SetActinic(30);
ReefAngel.PWM.SetDaylight(30);
}

im trying to figure out how the hole setting time thing works can some one explain this to me please thank you for everything
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

If you replace it with AND it will break.

Your hour cant be greater than 23 AND less than 7.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

oh ok now i see what it means thank you im sure there will be more to come
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

hey guys i was wondering if someone can kind of explain what the bold sections i made mean, i like the way this works but i want to make some changes to the different modes i just do not understand the whole feeding setup at all thanks
////// Place your custom code below here
static time_t feeding;

// Time schedule first
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
wpMode=1;
} 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
wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
} else if (hour()>=15 && hour()<18) {
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
wpMode=2;
} 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
wpMode=2;
} 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
wpMode=1;
} 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
wpMode=4;
}

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(30);
wpMode=0;
feeding=now();
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
}

////// Place your custom code above here[/quote]
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

805reefer wrote:hey guys i was wondering if someone can kind of explain what the bold sections i made mean, i like the way this works but i want to make some changes to the different modes i just do not understand the whole feeding setup at all thanks
Ok, let's start with the first highlighted statement:
805reefer wrote: ////// Place your custom code below here
static time_t feeding;
time_t is a big number... big enough to hold all the seconds since Jan 1, 1970.
normally variables are not stored. when they are inside a function (in this case loop()) then each time loop() is run then it will be re-initialized to 0. by calling it as static then it maintains the state and doesn't reinitialize it each time loop() is run.

So here we have a "static" "time_t" variable called feeding. We will use this later...
805reefer wrote: } else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
Here is where we use the feeding variable the first time.. This is in the section of code that is determining which mode to run. In the previous and post "if" checks, it is only looking for time-frames. Here I added a Check to see when the last time feeding mode was run. If it was then we won't run the Nutrient Transport Mode here.

The way I did this was check how long it's been by subtracting the current time (the now() function) which from the time of the last feeding. These numbers are in seconds. So if the number of seconds between now and the last feeding is more than 24 hours, then we didn't feed the tank yet so let's run the Nutrient Transport Mode..
805reefer wrote: // If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(30);
wpMode=0;
feeding=now();
}
Ok, here is where we have our Feeding Mode setup. Since this test comes after the last if/else blocks then if this check passes, it's going to override whatever was decided from the time schedule... So while we are in feeding mode, we set the Daylight and Actinic ports to 30%. We also set the wpMode (which is a variable I setup so that we could display the "mode" on the LCD. Finally and the important thing that relates to your other questions is feeding=now(); This is where we update the timer referenced above. As long as feeding mode is active, the feeding variable will be updated to the current time... When feeding mode stops, this variable will no longer be updated and we can use it to see how long it's been since the last update (now()-feeding)
805reefer wrote:
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
wpMode=3;
}

////// Place your custom code above here
This section is pretty similar to the above for feeding mode, but it's checking that the time since the last feeding is less than 3 hours. If so it will run Nutrient Transport for 3 hours. So once feeding mode stops we get Nutrient Transport for 3 hours after.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

ok now i see.....so what mode will this run from 12am to 6am i dont see that time in the code? also how would i add to make the pump shut off when in water change mode and thank you again i really want to learn this whole coding stuff its just taking me for ever i really appreciate all the help
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

Ok, for water change mode, you can do something similar to the feeding mode. You can put this right before or right after the feeding mode block...

Code: Select all

if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0); 
}
As far as what is running between 12am-6am that is handled by the last "else" statement that has no if... so if none of the previous if statements catch a positive value then that last else will be the default.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

ok so i did some changes to the code that would work a little better for my tank can you look through it and see what you think, thanks alot again i really appreciate it

////// Place your custom code below here
static time_t feeding;static byte wpMode;
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
//ReefAngel.PWM.SetDaylight(0);
ReefAngel.PWM.SetActinic(0);
}
// Time schedule first
if (hour()>=6 && hour()<11) {
//ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(35,true) ); // TidalSwell at 45% on sync mode
wpMode=1;
} else if (hour()>=11 && hour()<15) {
//ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(40,20,true) ); // ReefCrest at 45% +/- 20% on anti-sync mode
wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
// ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,1900,true) );
wpMode=3;
} else if (hour()>=15 && hour()<18) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic(ShortPulseMode(15,44,1700,true));
wpMode=2;
} else if (hour()>=18 && hour()<20) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(45,25,true) ); // ReefCrest at 70% +/- 20% on anti-sync mode
wpMode=2;
} else if (hour()>=20 && hour ()<23) {
// ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic(SineMode(20,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
wpMode=1;
} else {
//ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(20,true) ); // TidalSwell at 45% on sync mode
wpMode=4;
}

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
// ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(0);
wpMode=0;
feeding=now();
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
//ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,6000,true) );
wpMode=3;
}
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

Any changes you want to make to the mode outside of the time schedule have to come AFTER the time schedule code.

So... this bit

Code: Select all

if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
//ReefAngel.PWM.SetDaylight(0); 
ReefAngel.PWM.SetActinic(0); 
}
Needs to go where you have the FEEDING_MODE being override... either before or after that, but not before the time stuff...

Otherwise the time stuff will override the WATERCHANGE_MODE... make sense?
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

oh ok i see what your saying.... so i made the changes and know im getting an error when i check the code im not sure how to fix this here is my 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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port6Bit | Port7Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Port8 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.DosingPumpRepeat1( Port3 );
    ReefAngel.DosingPumpRepeat2( Port5 );
    ReefAngel.DayLights( Port6 );
    ReefAngel.ActinicLights( Port7 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.Channel0PWMSlope(40);
    ReefAngel.PWM.Channel1PWMSlope(10);
    ReefAngel.PWM.Channel2PWMSlope(20);
    ReefAngel.PWM.Channel3PWMSlope(35);
    ReefAngel.PWM.Channel4PWMSlope(25);
    ////// Place your custom code below here
    static time_t feeding;static byte wpMode;

// Time schedule first
if (hour()>=6 && hour()<11) {
  //ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(35,true) ); // TidalSwell at 45% on sync mode
  wpMode=1;
} else if (hour()>=11 && hour()<15) {
  //ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(40,20,true) ); // ReefCrest at 45% +/- 20% on anti-sync mode
  wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
 // ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,1900,true) );
  wpMode=3;
} else if (hour()>=15 && hour()<18) {
 // ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
   ReefAngel.PWM.SetActinic(ShortPulseMode(15,44,2000,true));
  wpMode=2;
} else if (hour()>=18 && hour()<20) {
 // ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(45,25,true) ); // ReefCrest at 70% +/- 20% on anti-sync mode
  wpMode=2;
} else if (hour()>=20 && hour ()<23) {
 // ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic(SineMode(20,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
  wpMode=1;
} else {
  //ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(20,true) ); // TidalSwell at 45% on sync mode
  wpMode=4; 
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0);   
}    

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
 // ReefAngel.PWM.SetDaylight(30); 
  ReefAngel.PWM.SetActinic(0); 
  wpMode=0;
  feeding=now();  
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
//ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,6000,true) );
  wpMode=3;
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0); 

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

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Dimming Expansion
    x = 15;
    y = 2;
    for ( int a=0;a<6;a++ )
    {
      if ( a>2 ) x = 75;
      if ( a==3 ) y = 2;
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
      y += 10;
    }
    pingSerial();

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

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

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

void DrawCustomGraph()
{
}
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

Whats the error?

you left off the last } in the code we added..

try this

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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port6Bit | Port7Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Port8 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.DosingPumpRepeat1( Port3 );
    ReefAngel.DosingPumpRepeat2( Port5 );
    ReefAngel.DayLights( Port6 );
    ReefAngel.ActinicLights( Port7 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.Channel0PWMSlope(40);
    ReefAngel.PWM.Channel1PWMSlope(10);
    ReefAngel.PWM.Channel2PWMSlope(20);
    ReefAngel.PWM.Channel3PWMSlope(35);
    ReefAngel.PWM.Channel4PWMSlope(25);
    ////// Place your custom code below here
    static time_t feeding;static byte wpMode;

// Time schedule first
if (hour()>=6 && hour()<11) {
  //ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(35,true) ); // TidalSwell at 45% on sync mode
  wpMode=1;
} else if (hour()>=11 && hour()<15) {
  //ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(40,20,true) ); // ReefCrest at 45% +/- 20% on anti-sync mode
  wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
// ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,1900,true) );
  wpMode=3;
} else if (hour()>=15 && hour()<18) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
   ReefAngel.PWM.SetActinic(ShortPulseMode(15,44,2000,true));
  wpMode=2;
} else if (hour()>=18 && hour()<20) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(45,25,true) ); // ReefCrest at 70% +/- 20% on anti-sync mode
  wpMode=2;
} else if (hour()>=20 && hour ()<23) {
// ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic(SineMode(20,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
  wpMode=1;
} else {
  //ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(20,true) ); // TidalSwell at 45% on sync mode
  wpMode=4; 
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0);   
}    

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
// ReefAngel.PWM.SetDaylight(30); 
  ReefAngel.PWM.SetActinic(0); 
  wpMode=0;
  feeding=now();  
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
//ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,6000,true) );
  wpMode=3;
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0); 
  }
    ////// Place your custom code above here

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Dimming Expansion
    x = 15;
    y = 2;
    for ( int a=0;a<6;a++ )
    {
      if ( a>2 ) x = 75;
      if ( a==3 ) y = 2;
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
      ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
      y += 10;
    }
    pingSerial();

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

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

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

void DrawCustomGraph()
{
}
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

right on man thank you so much you are the man.....but my only question is im not seeing what mode its in on the screen how do i fix this? thank you again i really appreciate your help..
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

right on man thank you so much you are the man.....but my only question is im not seeing what mode its in on the screen how do i fix this? thank you again i really appreciate your help..
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

You don't have the code in your DrawCustomMain to display it...check out this example

http://forum.reefangel.com/viewtopic.php?p=27364#p27364
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

i see so i cant have my light channels and the modes on the same screen? i tried adding it and got this error code


jebo_mix_mode.cpp: In function 'void DrawCustomMain()':
jebo_mix_mode:156: error: redeclaration of 'int x'
jebo_mix_mode:140: error: 'int x' previously declared here
jebo_mix_mode:156: error: redeclaration of 'int y'
jebo_mix_mode:140: error: 'int y' previously declared here
jebo_mix_mode:159: error: 'wpMode' was not declared in this scope
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port6Bit | Port7Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Port8 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.DosingPumpRepeat1( Port3 );
    ReefAngel.DosingPumpRepeat2( Port5 );
    ReefAngel.DayLights( Port6 );
    ReefAngel.ActinicLights( Port7 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.Channel0PWMSlope(40);
    ReefAngel.PWM.Channel1PWMSlope(10);
    ReefAngel.PWM.Channel2PWMSlope(20);
    ReefAngel.PWM.Channel3PWMSlope(35);
    ReefAngel.PWM.Channel4PWMSlope(25);
    ////// Place your custom code below here
    static time_t feeding;static byte wpMode;

// Time schedule first
if (hour()>=6 && hour()<11) {
  //ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(35,true) ); // TidalSwell at 35% on sync mode
  wpMode=1;
} else if (hour()>=11 && hour()<15) {
  //ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(40,20,true) ); // ReefCrest at 40% +/- 20% on anti-sync mode
  wpMode=2;
} else if ( (hour()>=15 && hour()<18) && (now()-feeding > SECS_PER_DAY) ) { // We haven't fed today
// ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,6000,true) );
  wpMode=3;
} else if (hour()>=15 && hour()<18) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
   ReefAngel.PWM.SetActinic(ShortPulseMode(15,42,3000,true));
  wpMode=2;
} else if (hour()>=18 && hour()<20) {
// ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(40,20,true) ); // ReefCrest at 45% +/- 20% on anti-sync mode
  wpMode=2;
} else if (hour()>=20 && hour ()<23) {
// ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
  ReefAngel.PWM.SetActinic(SineMode(20,40,30,true) ); //SineMode from 20% to 40% for 30 seconds on sync mode
  wpMode=1;
} else {
  //ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(20,true) ); // TidalSwell at 20% on sync mode
  wpMode=4; 
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0);   
}    

// If we are feeding override the schedule
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
// ReefAngel.PWM.SetDaylight(30); 
  ReefAngel.PWM.SetActinic(0); 
  wpMode=0;
  feeding=now();  
}
// If we have finished feeding, start NTM for 3 hours
if (now()-feeding < 3*SECS_PER_HOUR) {
//ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
  ReefAngel.PWM.SetActinic( NutrientTransportMode(25,40,6000,true) );
  wpMode=3;
}  
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  //ReefAngel.PWM.SetDaylight(0); 
  ReefAngel.PWM.SetActinic(0); 
  }
    ////// Place your custom code above here

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Dimming Expansion
    x = 15;
    y = 2;
    for ( int a=0;a<6;a++ )
    {
      if ( a>2 ) x = 75;
      if ( a==3 ) y = 2;
     //ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
      //ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
     // ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
      y += 10;
    }
    pingSerial();
  // WP40 Mode
  int x, y;
  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 if (wpMode == 1) ReefAngel.LCD.DrawText(COLOR_MAGENTA,255,x,y,"Tidal Swell");
  else if (wpMode == 2) ReefAngel.LCD.DrawText(COLOR_GOLD,255,x,y,"Reef Crest");
  else if (wpMode == 3) ReefAngel.LCD.DrawText(COLOR_RED,255,x,y,"Nutrient");
  else if (wpMode == 4) ReefAngel.LCD.DrawText(COLOR_BLUE,255,x,y,"Sine Wave");
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

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

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

void DrawCustomGraph()
{
}
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: jebo wp40

Post by lnevo »

805reefer wrote:i see so i cant have my light channels and the modes on the same screen? i tried adding it and got this error code


jebo_mix_mode.cpp: In function 'void DrawCustomMain()':
jebo_mix_mode:156: error: redeclaration of 'int x'
jebo_mix_mode:140: error: 'int x' previously declared here
jebo_mix_mode:156: error: redeclaration of 'int y'
jebo_mix_mode:140: error: 'int y' previously declared here
jebo_mix_mode:159: error: 'wpMode' was not declared in this scope
You will have to move some things around to make some room.

If you look at the errors you are getting we can learn a few things that will help you troubleshoot in the future.

jebo_mix_mode:156: error: redeclaration of 'int x'
jebo_mix_mode:140: error: 'int x' previously declared here

This means you are declaring the int variable x twice....once on line 156 and originally on 140. Either rename one or make sure you coordinate what the numbers do and you can share the same variable for what you are already doing and what you are adding.

Same goes for y.

The last error is a scope error. Basically a variable defined "inside" a function can only be used by that function, Since DrawCustomMain() is a different function than loop() the variable wpMode is not in that scope. So what you need to do is make wpMode a global variable, all you have to do is move the declaration of that variable "static but wpMode;" to outside of the loop function. A good place for that is in between the "place global variables here" comments. Probably why it got missed earlier on by you in one of your earlier posts, because that's where it originally was :)

The x and y stuff will probably take more tweaking to get everything positioned how you want it.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

Code: Select all

Either rename one or make sure you coordinate what the numbers do and you can share the same variable for what you are already doing and what you are adding.

alright see what your talking about.... so how would i do this can you show me an example
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

so if i changed it to lets say v and w would that work
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: jebo wp40

Post by rimai »

Nah... To make it easier, just remove one of the lines like that:

Code: Select all

  int x, y;
You have 2 of them and that's why it's saying you are trying to redeclare....
Declaration of variables can only happen once.
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: jebo wp40

Post by rimai »

Roberto.
805reefer
Posts: 72
Joined: Wed Feb 27, 2013 10:38 pm

Re: jebo wp40

Post by 805reefer »

wow thanks for the site roberto.....i did what you said and everything is good i uploaded the code now it shows the mode under my channel 5 is there away to center it under the channel two and five or no it has to stay on one side

thank you guys for helping me out with this...it gets really frustrating not knowing how to do this
Post Reply