Code Guru's pleas help

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Code Guru's pleas help

Post by Dctrojan »

Hello everyone , I was wondering if i could get some help from some more experienced reef angel users.

Ive been writing this code to add some custom menus to my android app to access the reef angel.

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
#include <avr/pgmspace.h>

prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Wavemaker";
prog_char menu4_label[] PROGMEM = "Overheat clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "White Lights";
prog_char menu7_label[] PROGMEM = "Blue Lights";
prog_char menu8_label[] PROGMEM = "Lunar Lights";
prog_char menu9_label[] PROGMEM = "date/Time"; 
 
PROGMEM const char *menu_items[] = { menu1_label, menu2_label,
menu3_label, menu4_label, menu5_label,
menu6_label, menu7_label, menu8_label, 
menu9_label

};

void MenuEntry1()

{
ReefAngel.FeedingModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry3()
{ 
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.On (Port3);

}
void MenuEntry7()
{
ReefAngel.Relay.On (Port4);
}
void MenuEntry8() 
{
ReefAngel.Relay.Toggle(255 ,231);
ReefAngel.DisplayMenuEntry("Moon cycle ");

}
void MenuEntry9() 
{
ReefAngel.SetupDateTime();  
7eefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void setup()
{

 ReefAngel.Init(); //Initialize controller

 ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

 
// Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Port7 );
void setup()


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

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

void loop()
{
    ReefAngel.MoonLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,10,60 );
    ReefAngel.WavemakerRandom2( Port6,5,10 );
    ReefAngel.StandardHeater( Port8 );
    ReefAngel.PWM.Channel0PWMSlope();
    ReefAngel.PWM.Channel1PWMSlope();
    ReefAngel.PWM.Channel2PWMSlope();
    ReefAngel.PWM.Channel3PWMSlope();
    ReefAngel.PWM.Channel4PWMSlope();
    ////// Place your custom code below here
     pinMode(lowATOPin,OUTPUT);
  if (InternalMemory.LEDPWMActinic_read()<=100)
    analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
  else
    analogWrite(lowATOPin,MoonPhase()*2.55);

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

    // This should always be the last line
    ReefAngel.Portal( "Dctrojan" );
    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, 39, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,76, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,76, 100 );    
    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()
{
}/code]

I was wondering if someone could help me with menu item #8? I would like to be able to toggle the lunar hub to follow the moonphase on and off. 
It would also be great if I could also control the lunar hub dimmer through this function as well.

By no means is this a finished code, just really  a starting point. im having trouble entering the toggle function, im not sure how to enter in the location and Bit. 

I ultimately would like to also lengthen the feeding time as well if anyone knows how to do this.

also eventually i would like to be able to control the circulation pumps timers.

thanks for all the help and advice.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Code Guru's pleas help

Post by binder »

for the feeding mode time, to change it open up the Android app and goto memory locations. then select feeding mode timer from the menu. input the number of seconds you want to use for the timer and press write. the default is 900 seconds or 15 minutes.

Sent from my Galaxy Nexus
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

Dctrojan wrote:Hello everyone , I was wondering if i could get some help from some more experienced reef angel users.

Ive been writing this code to add some custom menus to my android app to access the reef angel.

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
#include <avr/pgmspace.h>

prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Wavemaker";
prog_char menu4_label[] PROGMEM = "Overheat clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "White Lights";
prog_char menu7_label[] PROGMEM = "Blue Lights";
prog_char menu8_label[] PROGMEM = "Lunar Lights";
prog_char menu9_label[] PROGMEM = "date/Time"; 
 
PROGMEM const char *menu_items[] = { menu1_label, menu2_label,
menu3_label, menu4_label, menu5_label,
menu6_label, menu7_label, menu8_label, 
menu9_label

};

void MenuEntry1()

{
ReefAngel.FeedingModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry3()
{ 
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.On (Port3);

}
void MenuEntry7()
{
ReefAngel.Relay.On (Port4);
}
void MenuEntry8() 
{
ReefAngel.Relay.Toggle(255 ,231);
ReefAngel.DisplayMenuEntry("Moon cycle ");

}
void MenuEntry9() 
{
ReefAngel.SetupDateTime();  
7eefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void setup()
{

 ReefAngel.Init(); //Initialize controller

 ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

 
// Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Port7 );
void setup()


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

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

void loop()
{
    ReefAngel.MoonLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,10,60 );
    ReefAngel.WavemakerRandom2( Port6,5,10 );
    ReefAngel.StandardHeater( Port8 );
    ReefAngel.PWM.Channel0PWMSlope();
    ReefAngel.PWM.Channel1PWMSlope();
    ReefAngel.PWM.Channel2PWMSlope();
    ReefAngel.PWM.Channel3PWMSlope();
    ReefAngel.PWM.Channel4PWMSlope();
    ////// Place your custom code below here
     pinMode(lowATOPin,OUTPUT);
  if (InternalMemory.LEDPWMActinic_read()<=100)
    analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
  else
    analogWrite(lowATOPin,MoonPhase()*2.55);

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

    // This should always be the last line
    ReefAngel.Portal( "Dctrojan" );
    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, 39, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,76, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,76, 100 );    
    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()
{
}/code]

I was wondering if someone could help me with menu item #8? I would like to be able to toggle the lunar hub to follow the moonphase on and off. 
It would also be great if I could also control the lunar hub dimmer through this function as well.

By no means is this a finished code, just really  a starting point. im having trouble entering the toggle function, im not sure how to enter in the location and Bit. 

I ultimately would like to also lengthen the feeding time as well if anyone knows how to do this.

also eventually i would like to be able to control the circulation pumps timers.

thanks for all the help and advice.[/quote]

Ok sweet thanks . Also great write ups. I was using the one about tge custom menus to help me understand  writing code a little more. 

Sent from my SAMSUNG-SGH-I337 using Tapatalk
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

Also didnt mean to quote myself lol.

Sent from my SAMSUNG-SGH-I337 using Tapatalk
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

Does anyone know how to write the toggle function ? Or have any other input

Sent from my SAMSUNG-SGH-I337 using Tapatalk
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Code Guru's pleas help

Post by binder »

Dctrojan wrote:Does anyone know how to write the toggle function ? Or have any other input

Sent from my SAMSUNG-SGH-I337 using Tapatalk
i think someone else will have to help with the lunar function toggle. I'm not familiar with it at all. but don't worry, someone will chime in soon... they always do :)

Sent from my Nexus 7
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Code Guru's pleas help

Post by rimai »

Try this:

Code: Select all

void MenuEntry8() 
{
ReefAngel.DisplayMenuEntry("Moon cycle ");
if (InternalMemory.LEDPWMActinic_read()<=100)
  InternalMemory.LEDPWMActinic_write(101);
else
  InternalMemory.LEDPWMActinic_write(50);


}
[/code]
Roberto.
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

once again great customer service. Im running into another problem at the end of the code. Could someone help me the Adruino software is saying "a function-definition is not allowed her before { token . I've bolded the code and changed the color.

In this 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
#include <avr/pgmspace.h>

prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Wavemaker";
prog_char menu4_label[] PROGMEM = "Overheat clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "White Lights";
prog_char menu7_label[] PROGMEM = "Blue Lights";
prog_char menu8_label[] PROGMEM = "Lunar Lights";
prog_char menu9_label[] PROGMEM = "date/Time"; 
 
PROGMEM const char *menu_items[] = { menu1_label, menu2_label,
menu3_label, menu4_label, menu5_label,
menu6_label, menu7_label, menu8_label, 
menu9_label

};

void MenuEntry1()

{
ReefAngel.FeedingModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry3()
{ 
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);

}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.On (Port3);

}
void MenuEntry7()
{
ReefAngel.Relay.On (Port4);
}
void MenuEntry8() 
{
ReefAngel.DisplayMenuEntry("Moon cycle ");
if (InternalMemory.LEDPWMActinic_read()<=100)
  InternalMemory.LEDPWMActinic_write(101);
else
  InternalMemory.LEDPWMActinic_write(50);

}
void MenuEntry9() 
{
ReefAngel.SetupDateTime();  
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void setup()
{

 ReefAngel.Init(); //Initialize controller

 ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

 
// Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Port7 );
}
void loop()


    ////// Place additional initialization code below here
// .. other code here



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

{
{
    ReefAngel.MoonLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,10,60 );
    ReefAngel.WavemakerRandom2( Port6,5,10 );
    ReefAngel.StandardHeater( Port8 );
    ReefAngel.PWM.Channel0PWMSlope();
    ReefAngel.PWM.Channel1PWMSlope();
    ReefAngel.PWM.Channel2PWMSlope();
    ReefAngel.PWM.Channel3PWMSlope();
    ReefAngel.PWM.Channel4PWMSlope();
    ////// Place your custom code below here
     pinMode(lowATOPin,OUTPUT);
  if (InternalMemory.LEDPWMActinic_read()<=100)
    analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
  else
    analogWrite(lowATOPin,MoonPhase()*2.55);

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

    // This should always be the last line
    ReefAngel.Portal( "Dctrojan" );
    ReefAngel.ShowInterface();
[b][color=#4040FF]}
void DrawCustomMain()
{
    int x,y;[/color][/b]
    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, 39, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,76, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,76, 100 );    

    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()
{
}

{/code]
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Code Guru's pleas help

Post by rimai »

You have two { just below loop()
You should only have one.
Roberto.
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

Im still having problems with my code. Im not sure why my actinics port 4 isn't coming on at 10:30 am. Everyday i get home from work at noon for lunch to see only white/yellow light. Can someone look at my code and tell me whats going on.

Also the custom menu's i added don't seem to be working correctly. when I press them on the controller nothing happens except for the screen either goes white or goes back to the menu, no ports actually turn on or off.

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
#include <avr/pgmspace.h>

prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Wavemaker";
prog_char menu4_label[] PROGMEM = "Overheat clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "White Lights";
prog_char menu7_label[] PROGMEM = "Blue Lights";
prog_char menu8_label[] PROGMEM = "Lunar Lights";
prog_char menu9_label[] PROGMEM = "date/Time"; 
 
PROGMEM const char *menu_items[] = { menu1_label, menu2_label,
menu3_label, menu4_label, menu5_label,
menu6_label, menu7_label, menu8_label, 
menu9_label

};

void MenuEntry1()

{
ReefAngel.FeedingModeStart();
ReefAngel.Relay.Off (Port1);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
ReefAngel.Relay.Write();

 

}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
ReefAngel.Relay.Write();

 

}
void MenuEntry3()
{ 
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
ReefAngel.Relay.Write();

 

}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");

}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.On (Port3);
ReefAngel.Relay.Write();

 

}
void MenuEntry7()
{
ReefAngel.Relay.On (Port4);
ReefAngel.Relay.Write();



}
void MenuEntry8() 
{
ReefAngel.DisplayMenuEntry("Moon cycle ");
if (InternalMemory.LEDPWMActinic_read()<=100)
  InternalMemory.LEDPWMActinic_write(101);
else
  InternalMemory.LEDPWMActinic_write(50);


}
void MenuEntry9() 
{
ReefAngel.SetupDateTime();  
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void setup()
{

 ReefAngel.Init(); //Initialize controller

 ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

 
// Ports that are always on
    
    
}
void loop()


    ////// Place additional initialization code below here
// .. other code here



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

{

    ReefAngel.MoonLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,10,60 );
    ReefAngel.WavemakerRandom2( Port6,5,30 );
    ReefAngel.StandardHeater( Port8 );
    ReefAngel.PWM.Channel0PWMSlope();
    ReefAngel.PWM.Channel1PWMSlope();
    ReefAngel.PWM.Channel2PWMSlope();
    ReefAngel.PWM.Channel3PWMSlope();
    ReefAngel.PWM.Channel4PWMSlope();
    ////// Place your custom code below here
     pinMode(lowATOPin,OUTPUT);
  if (InternalMemory.LEDPWMActinic_read()<=100)
    analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
  else
    analogWrite(lowATOPin,MoonPhase()*2.55);

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

    // This should always be the last line
    ReefAngel.Portal( "Dctrojan" );
    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, 39, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,76, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,76, 100 );    

    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()
{
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Code Guru's pleas help

Post by rimai »

You can't turn on/off relays like that, because whatever function you have in the loop() will just override whatever you placed in your custom menu.
You must override those ports instead like this:

Code: Select all

ReefAngel.Relay.Override(Port4,1);
0 is off, 1 is on and 2 is auto
If you override either on or off, you must turn it back to auto or they will remain in overridden position forever.
That's why everybody don't even bother with the controller menu. It's much easier to use the Portal or android app.
Also, if you use internal memory, we can't help you figure out why your lights don't turn on. We can't see what's in your internal memory.
Roberto.
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

My temperature probe also seems to be not working can someone point me in the correct way to code for this
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

My temperature probe also seems to be not working can someone point me in the correct way to code for this
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

See thats the thing I thought I was using Internal memory. I selected use internal memory in the wizard before I copy and pasted the code?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Code Guru's pleas help

Post by rimai »

Exactly. We don't have access to see your internal memory.
We can only troubleshoot something if it is not hard coded.
Roberto.
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Code Guru's pleas help

Post by Dctrojan »

what about now? I uploaded a code from the wizard that I asked it to generate for me. Im not sure what else your meaning needs done? I copied the code to arduino and added a few lines that we previously placed in there (minus) the custom menus and I uploaded it.

Fixed the Temp problem.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Code Guru's pleas help

Post by rimai »

You need to choose hard coded settings and not internal memory settings
Roberto.
Post Reply