problem controlling jebao from portal

Do you have a question on how to do something.
Ask in here.
Post Reply
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

problem controlling jebao from portal

Post by psyrob »

I'm having a problem with my braces... :?

What I want to do is between the hours of 8 am and 9 pm be able to change my jebao from the portal and from 9 pm to 8 am only have it run what I have in the code, and not be able to switch it...and during that 8 am to 9 pm, have the "custom" switch from the portal run else mode...I keep getting an error about a brace being expected...

What am I doing wrong? am I missing a brace somewhere? Or what am I doing wrong...
Thanks

Rob

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>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Frag Pump";  
    ReefAngel.CustomLabels[1]="Actinics";  
    ReefAngel.CustomLabels[2]="Daylights";  
    ReefAngel.CustomLabels[3]="Frag LED";  
    ReefAngel.CustomLabels[4]="ATO Pump";  
    ReefAngel.CustomLabels[5]="Reactor";  
    ReefAngel.CustomLabels[6]="Heater";  
    ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.ActinicLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.SingleATOLow( Port5 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    //ReefAngel.DCPump.UseMemory = false;
   
 
        if (hour()>=8 && hour()<21)
         
           
           {
             
        if (ReefAngel.DCPump.Mode==Custom)
        {
         ReefAngel.PWM.SetActinic(ElseMode(60, 20, true));
         
            ReefAngel.DCPump.UseMemory = false;
        } else{
          ReefAngel.DCPump.UseMemory = true;}
            
           }
          else 
         {
         ReefAngel.PWM.SetActinic(LongPulseMode(65,40, 60, true));
         }
           
    }
  
    ////// Place your custom code below here
    

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

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


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;
  }
}
Image
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: problem controlling jebao from portal

Post by psyrob »

anyone? :?:
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: problem controlling jebao from portal

Post by rimai »

There was one brace that was misplaced :(

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>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
  // This must be the first line
  ReefAngel.Init();  //Initialize controller
  ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = 0;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port5Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;

  // Feeeding and Water Change mode speed
  ReefAngel.DCPump.FeedingSpeed=0;
  ReefAngel.DCPump.WaterChangeSpeed=0;


  // Ports that are always on
  ReefAngel.Relay.On( Port6 );

  ////// Place additional initialization code below here
  ReefAngel.CustomLabels[0]="Frag Pump";  
  ReefAngel.CustomLabels[1]="Actinics";  
  ReefAngel.CustomLabels[2]="Daylights";  
  ReefAngel.CustomLabels[3]="Frag LED";  
  ReefAngel.CustomLabels[4]="ATO Pump";  
  ReefAngel.CustomLabels[5]="Reactor";  
  ReefAngel.CustomLabels[6]="Heater";  
  ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
  ReefAngel.ActinicLights( Port1 );
  ReefAngel.ActinicLights( Port2 );
  ReefAngel.DayLights( Port3 );
  ReefAngel.ActinicLights( Port4 );
  ReefAngel.SingleATOLow( Port5 );
  ReefAngel.StandardHeater( Port7 );
  ReefAngel.StandardFan( Port8 );
  ReefAngel.PWM.SetDaylight( MoonPhase() );
  //ReefAngel.DCPump.UseMemory = false;


  if (hour()>=8 && hour()<21)


  {

    if (ReefAngel.DCPump.Mode==Custom)
    {
      ReefAngel.PWM.SetActinic(ElseMode(60, 20, true));

      ReefAngel.DCPump.UseMemory = false;
    } 
    else{
      ReefAngel.DCPump.UseMemory = true;
    }

  }
  else 
  {
    ReefAngel.PWM.SetActinic(LongPulseMode(65,40, 60, true));
  }


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


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

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


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;
  }
}

Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: problem controlling jebao from portal

Post by psyrob »

Thank you Roberto...that was driving me crazy ... :?
Image
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: problem controlling jebao from portal

Post by psyrob »

Now this uploads, but I can't control it from the portal...

When I first upload it, the jebao sets to "0", it isn't running. Then I pick "custom" from the drop down menu in internal memory on the portal, and it runs in else mode, but then if I change to anything else (long pulse, lagoon, or whatever), nothing happens, it stays in else mode. It did switch to sine mode at the right time, though...
Any thoughts?
Thanks
Rob

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>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Frag Pump";  
    ReefAngel.CustomLabels[1]="Actinics";  
    ReefAngel.CustomLabels[2]="Daylights";  
    ReefAngel.CustomLabels[3]="Frag LED";  
    ReefAngel.CustomLabels[4]="ATO Pump";  
    ReefAngel.CustomLabels[5]="Reactor";  
    ReefAngel.CustomLabels[6]="Heater";  
    ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.ActinicLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.SingleATOLow( Port5 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    ReefAngel.DCPump.UseMemory = true;
   
 
       if (hour()>=8 && hour()<21)
   
     {
             
        if (ReefAngel.DCPump.Mode==Custom)
          {
         ReefAngel.PWM.SetActinic(ElseMode(60, 20, true));
         
            ReefAngel.DCPump.UseMemory = false;
          } 
          
          else
            {
            ReefAngel.DCPump.UseMemory = true;
            }
      }
           
          else 
         {
         ReefAngel.PWM.SetActinic(SineMode(60,35, 20, true));
         }
           
    
  
    ////// Place your custom code below here
    

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

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

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;
  }
}
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: problem controlling jebao from portal

Post by rimai »

Do you have speed and duration set to valid values?
Roberto.
psyrob
Posts: 242
Joined: Thu Sep 01, 2011 8:44 pm

Re: problem controlling jebao from portal

Post by psyrob »

You mean when I switch modes on the portal? I think so...I tried reef rest, which I thought didn't use duration, I set speed at 65, I tried long pulse, set speed at 65, duration at 8...
Image
Post Reply