Else mode in new libraries?

Related to the development libraries, released by Curt Binder

Posts: 98
Joined: Sun Jul 21, 2013 8:18 am
PostPosted: Sat Nov 30, 2013 5:18 am
Is the else mode included in the new libraries?
I still have this code at the end of my sketch. If the else mode is included in the new libraries then I can remove this piece of code, right?


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
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Nov 30, 2013 7:33 am
Not in the libraries. Not sure if it will be...it's very close to the reef-crest code.

Posts: 32
Joined: Thu Apr 03, 2014 11:37 pm
PostPosted: Wed Dec 24, 2014 3:09 am
my apologies for hijacking this thread....but I am experiencing a problem..I opened arduino today and it told me there is an update...I updated and now my code wont load onto the controller..i have the following error

"Globals\Globals.cpp.o: In function `ElseMode(unsigned char, unsigned char, unsigned char)':
C:\Users\Ridwaan.DellUser-PC\Documents\Arduino\libraries\Globals/Globals.cpp:881: multiple definition of `ElseMode(unsigned char, unsigned char, unsigned char)'
sketch_nov09a.cpp.o:C:\Users\RIDWAA~1.DEL\AppData\Local\Temp\build8546684784534505203.tmp/sketch_nov09a.cpp:156: first defined here
c:/program files (x86)/reef angel controller/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions"

I am not sure what to do?..please help

Posts: 32
Joined: Thu Apr 03, 2014 11:37 pm
PostPosted: Wed Dec 24, 2014 3:10 am
Also, just to keep in mind..i am not a programmer...But im good at copying and psting and that's how I got my reef angel working the way I like it...lol

so yes, I need your help asap
User avatar
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Wed Dec 24, 2014 5:01 am
You need to take the ElseMode section out of your code. What this error says is that it exists twice. Once in your code, and now, once in the libraries.

Post your code and I can show you what to take out.

--Colin

Posts: 32
Joined: Thu Apr 03, 2014 11:37 pm
PostPosted: Wed Dec 24, 2014 5:46 am
Cool Thanks so much...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 <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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.AddStandardMenu();  // Add Standard Menu

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddPHExpansion();  // pH Expansion Module
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );

    // Feeeding and Water Change mode speed

    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port3 );
    ReefAngel.Relay.On( Box1_Port4 );
    ReefAngel.Relay.On( Box1_Port5 );
    ReefAngel.Relay.On( Box1_Port6 );
    ReefAngel.Relay.On( Box1_Port7 );
    ReefAngel.Relay.On( Box1_Port8 );
   

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

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

void loop()
{
    ReefAngel.StandardLights( Port1,6,45,19,15 );
    ReefAngel.StandardLights( Port2,11,45,17,30 );
    ReefAngel.StandardHeater( Port3,240,255 );
    ReefAngel.StandardHeater( Port4,240,255 );
    ReefAngel.StandardFan( Port5,260,265 );
    ReefAngel.CO2Control( Port7,650,660 );
       
    ////// Place your custom code below here
static unsigned long atoTimer;

if (ReefAngel.DisplayedMenu==FEEDING_MODE) atoTimer=now();

if (now()-atoTimer < 300) { //300 second delay (five minutes)
  ReefAngel.Relay.Off(Port6);
 
} else {
  ReefAngel.SingleATO( true,Port6,20,0 );
}

   

if (hour()>=7 && hour()<10)
{
    ReefAngel.PWM.SetDaylight( LongPulseMode(0,80,5,true) ); // Ramp from 0% to 80% with 5 second duration in antisync mode
    ReefAngel.PWM.SetActinic( LongPulseMode(0,80,5,false) );
}

if (hour()>=10 && hour()<17)
{
    ReefAngel.PWM.SetDaylight( ElseMode(80,20,true) ); // ReefCrest at 80% +/- 20% on antisync mode
    ReefAngel.PWM.SetActinic( ElseMode(80,20,false) );
}
else if (hour()>=17 && hour()<20)
{
     ReefAngel.PWM.SetDaylight( LongPulseMode(0,80,10,true) ); // Ramp from 0% to 80% with 10 second duration in antisync mode
     ReefAngel.PWM.SetActinic( LongPulseMode(0,80,10,false) );
}   
    else if (hour()>=20 || hour()<7)
{
    ReefAngel.PWM.SetDaylight( ElseMode(30,10,true) ); // ReefCrest at 80% +/- 20% on antisync mode
    ReefAngel.PWM.SetActinic( ElseMode(30,10,false) );
}
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.Off(Port8);
    }
    else
    {
        ReefAngel.Relay.On(Port8);
    }
 
  if( ReefAngel.DisplayedMenu==FEEDING_MODE )
 {
   ReefAngel.PWM.SetActinic(0);
   ReefAngel.PWM.SetDaylight(0);
}
    ////// Place your custom code above here

    // This should always be the last line
    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;
  }
}

User avatar
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Wed Dec 24, 2014 5:54 am
I think this should do it. I just removed the ElseMode() function from your code, since it's in the new libraries now.

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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.AddStandardMenu();  // Add Standard Menu

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddPHExpansion();  // pH Expansion Module
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );

    // Feeeding and Water Change mode speed

    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port3 );
    ReefAngel.Relay.On( Box1_Port4 );
    ReefAngel.Relay.On( Box1_Port5 );
    ReefAngel.Relay.On( Box1_Port6 );
    ReefAngel.Relay.On( Box1_Port7 );
    ReefAngel.Relay.On( Box1_Port8 );
   

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

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

void loop()
{
    ReefAngel.StandardLights( Port1,6,45,19,15 );
    ReefAngel.StandardLights( Port2,11,45,17,30 );
    ReefAngel.StandardHeater( Port3,240,255 );
    ReefAngel.StandardHeater( Port4,240,255 );
    ReefAngel.StandardFan( Port5,260,265 );
    ReefAngel.CO2Control( Port7,650,660 );
       
    ////// Place your custom code below here
static unsigned long atoTimer;

if (ReefAngel.DisplayedMenu==FEEDING_MODE) atoTimer=now();

if (now()-atoTimer < 300) { //300 second delay (five minutes)
  ReefAngel.Relay.Off(Port6);
 
} else {
  ReefAngel.SingleATO( true,Port6,20,0 );
}

   

if (hour()>=7 && hour()<10)
{
    ReefAngel.PWM.SetDaylight( LongPulseMode(0,80,5,true) ); // Ramp from 0% to 80% with 5 second duration in antisync mode
    ReefAngel.PWM.SetActinic( LongPulseMode(0,80,5,false) );
}

if (hour()>=10 && hour()<17)
{
    ReefAngel.PWM.SetDaylight( ElseMode(80,20,true) ); // ReefCrest at 80% +/- 20% on antisync mode
    ReefAngel.PWM.SetActinic( ElseMode(80,20,false) );
}
else if (hour()>=17 && hour()<20)
{
     ReefAngel.PWM.SetDaylight( LongPulseMode(0,80,10,true) ); // Ramp from 0% to 80% with 10 second duration in antisync mode
     ReefAngel.PWM.SetActinic( LongPulseMode(0,80,10,false) );
}   
    else if (hour()>=20 || hour()<7)
{
    ReefAngel.PWM.SetDaylight( ElseMode(30,10,true) ); // ReefCrest at 80% +/- 20% on antisync mode
    ReefAngel.PWM.SetActinic( ElseMode(30,10,false) );
}
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.Off(Port8);
    }
    else
    {
        ReefAngel.Relay.On(Port8);
    }
 
  if( ReefAngel.DisplayedMenu==FEEDING_MODE )
 {
   ReefAngel.PWM.SetActinic(0);
   ReefAngel.PWM.SetDaylight(0);
}
    ////// Place your custom code above here

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

Posts: 32
Joined: Thu Apr 03, 2014 11:37 pm
PostPosted: Wed Dec 24, 2014 7:09 am
Thanks...that worked!
Learnt something new...

Posts: 1
Joined: Sun Aug 21, 2016 12:03 pm
PostPosted: Mon Aug 22, 2016 5:02 am
Is it possible to change Display Mode of grid/fields by Javascripts in Dynaform, if yes, how to compile the scripts, can you make an example.

Thanks.

Return to Development Libraries

Who is online

Users browsing this forum: No registered users and 2 guests

cron