need custom PDE help

Share you PDE file with our community
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

need custom PDE help

Post by jjdezek »

#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 = Port5Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 800 );


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

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


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

void loop()
{
ReefAngel.StandardATO( Port1,60 );
ReefAngel.StandardLights( Port3,18,0,10,0 );
ReefAngel.WavemakerRandom( Port5,30,100 );
ReefAngel.WavemakerRandom( Port6,30,100 );
ReefAngel.StandardHeater( Port7,752,755 );
ReefAngel.PWM.SetChannel( 0, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(7,30,21,30,0,35,180,0) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 3, PWMSlope(7,30,21,30,0,35,180,0) );
ReefAngel.PWM.SetChannel( 4, PWMSlope(7,0,22,0,0,40,180,0) );
ReefAngel.PWM.SetChannel( 5, PWMSlope(7,30,21,30,0,35,180,0) );
////// Place your custom code below here
if (hour()>=8 && hour()<12)
{
ReefAngel.PWM.SetDaylight( ReefCrestMode(100,20,true) ); // ReefCrest at 100% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(100,20,false) ); // ReefCrest at 100% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
ReefAngel.PWM.SetDaylight( ShortPulseMode(0,100,200,true) ); // Short pulse at 100% with 200ms pulse on sync mode
ReefAngel.PWM.SetActinic( ShortPulseMode(0,100,200,false) ); // Short pulse at 100% with 200ms pulse on anti-sync mode
}
else
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,100,10,true) ); // Long pulse at 100% with 10s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,100,10,false) ); // Long pulse at 6100% with 10s pulse on anti-sync mode
}
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.Portal( "jjdezek" );
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()
{
}
here is my current code
Image
dbmet
Posts: 235
Joined: Thu Nov 10, 2011 11:49 am

Re: need custom PDE help

Post by dbmet »

What is it your wanting to do?
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

sorry got a phone call before i could post that..what im looking for is the ability to be able to switch the wp40 between different wave patterns, and have the fuge light kick on during water change( i like that feature). also like the custom screen display that Inevo has. also i have my leds running on the anolog expansion but i have a custom weather/sunrise and sunset code programmed into the expansion itself
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

What part of my screen were you looking to add?

Your WP40 is currently on a time schedule.. what happens to that schedule if you update from the menu?

To have you fuge light kick in during water change is easy... :)

Code: Select all

  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
    ReefAngel.Relay.On(Port3);
  }
assuming... Port3 is your fuge light..
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

i believe the wp40 is just on random schedule i would like to be able to toggle manually between say reef crest nutrient export etc. i would also like to have the custom display like you have where it shows the ATO switches on the display with the larger temp and ph readings. i like your set up just dont need all the extra's that you have. the only extra's i have is the wp40 that i would like to control manually rather then it just being random.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Your not getting a random schedule for your WP40...

You have a time based schedule... 8am-12pm ReefCrest... 12pm-6pm ShortPulse any other time LongPulse

Toggling from the menu involves a lot more thought as to how it will interact. How long will it stay in the set mode? Permanent? Till next time window? It's not as easy.

Here's the relevant code that does the drawing that you want. Just put it at the end of your INO file and then call the two functions with the relevent x / y for your screen. You'll have to remove the existing drawing of those parameters or you'll be drawing twice and overlapping... these should work for you without modification.

Code: Select all

void DrawParams(int x, int y) {
  char buf[16];

  ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+5,y,"Temp:");
  ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+80, y, "PH:");
  // Temp and PH
  y+=2;
  ConvertNumToString(buf, ReefAngel.Params.Temp[T2_PROBE], 10);
  ReefAngel.LCD.DrawText(T2TempColor, DefaultBGColor, x+45, y, buf);
  y+=6; 
  ConvertNumToString(buf, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(T1TempColor, DefaultBGColor, x+5, y, buf, Num8x16);
  ConvertNumToString(buf, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+80, y, buf, Num8x16);
  y+=5;
  ConvertNumToString(buf, ReefAngel.Params.Temp[T3_PROBE], 10);
  ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, x+45, y, buf);
}

void DrawStatus(int x, int y) {
  int t=x;
  
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,15,y,"High",Font8x16);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,85,y,"Low",Font8x16);
  
  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_RED);
  }
  
  if (ReefAngel.LowATO.IsActive()) {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_RED);
  }
}
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

so i place that below the very last line

void DrawCustomGraph()
{
}
and that will change my screen display?

Just put it at the end of your INO file and then call the two functions with the relevent x / y for your screen. You'll have to remove the existing drawing of those parameters or you'll be drawing twice and overlapping...
not sure what you mean here.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

No adding it just gives you the functions that will draw the elements you wanted.. You need to modify your DrawCustomMain() function to use them. It's pretty straight forward, you call those functions and pass the x and y locations where you want them drawn on the screen.

Theres a tutorial somewhere on doing custom main screens, i suggest you read through it.

Unfortunately this is not something i can test out for you and drawing screens takes a bit of tweaking to get things where you want them.

I'm happy to help you understand and learn what you are doing, but I can't do everything for you, i just don't have the means to debug and test what you need.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

jjdezek wrote:
lnevo wrote: Just put it at the end of your INO file and then call the two functions with the relevent x / y for your screen. You'll have to remove the existing drawing of those parameters or you'll be drawing twice and overlapping...
not sure what you mean here.
It means you are already drawing your temp and ph. You cant or shouldnt rather draw them twice. Plus they would overlap each other since you probably dont have room for both :)
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

is this the one your talking about?
http://curtbinder.info/ragen/docs/RA_Cu ... Screen.pdf

I know i found another one on here somewhere last night but im unable to find it now. it said something about putting a couple new lines into the ReefAngel_Features h file. i think that was for more menus to toggle between though. right now im LLMF i think my eyes crossed.
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

also for future issues i see everyone posting there codes in the little scroll down windows with the select code option up top. how do you do that?
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

going off of that link i plug the first part on the code in and run the verify and get this error

sketch_may29a.cpp: In function 'void DrawCustomMain()':
sketch_may29a:105: error: redefinition of 'void DrawCustomMain()'
sketch_may29a:30: error: 'void DrawCustomMain()' previously defined here
sketch_may29a.cpp: In function 'void DrawCustomGraph()':
sketch_may29a:144: error: redefinition of 'void DrawCustomGraph()'
sketch_may29a:48: error: 'void DrawCustomGraph()' previously defined here
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

jjdezek wrote:also for future issues i see everyone posting there codes in the little scroll down windows with the select code option up top. how do you do that?
When you use the editor you can highlight the text you want as code and click the Code button...

otherwise you can use the BBCode tags like this:

Code: Select all

[code]
[/code]
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

jjdezek wrote:going off of that link i plug the first part on the code in and run the verify and get this error

sketch_may29a.cpp: In function 'void DrawCustomMain()':
sketch_may29a:105: error: redefinition of 'void DrawCustomMain()'
sketch_may29a:30: error: 'void DrawCustomMain()' previously defined here
sketch_may29a.cpp: In function 'void DrawCustomGraph()':
sketch_may29a:144: error: redefinition of 'void DrawCustomGraph()'
sketch_may29a:48: error: 'void DrawCustomGraph()' previously defined here
Looks like you have two functions with the same name. DrawCustomMain and DrawCustomGraph... You can only have one function with that name...
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

I noticed the code i copied and pasted from the link was both the custommain and customgraph. So i copied just the custommain and ran the verify and gave me another error and jumped to the custommain at the end of my coding. the link doesnt say anything about what to do with that part of the code.
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

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
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

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


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

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

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

void loop()
{
    ReefAngel.StandardATO( Port1,60 );
    ReefAngel.StandardLights( Port3,18,0,10,0 );
    ReefAngel.WavemakerRandom( Port5,30,100 );
    ReefAngel.WavemakerRandom( Port6,30,100 );
    ReefAngel.StandardHeater( Port7,752,755 );
    ReefAngel.PWM.SetChannel( 0, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 1, PWMSlope(7,30,21,30,0,35,180,0) );
    ReefAngel.PWM.SetChannel( 2, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 3, PWMSlope(7,30,21,30,0,35,180,0) );
    ReefAngel.PWM.SetChannel( 4, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 5, PWMSlope(7,30,21,30,0,35,180,0) );
    ////// Place your custom code below here
    if (hour()>=8 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(100,20,true) ); // ReefCrest at 100% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(100,20,false) ); // ReefCrest at 100% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
  ReefAngel.PWM.SetDaylight( ShortPulseMode(0,100,200,true) ); // Short pulse at 100% with 200ms pulse on sync mode
  ReefAngel.PWM.SetActinic( ShortPulseMode(0,100,200,false) ); // Short pulse at 100% with 200ms pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( LongPulseMode(0,100,10,true) ); // Long pulse at 100% with 10s pulse on sync mode
  ReefAngel.PWM.SetActinic( LongPulseMode(0,100,10,false) ); // Long pulse at 6100% with 10s pulse on anti-sync mode
}
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.Portal( "jjdezek" );
    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()
{
}
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Where you pasted the DrawCustomMain() is wrong... it should be at the end of your INO file... but guess what? It's already there! You already have that function defined....

You can only define it once. You can't have two DrawCustomMain() functions... same for any function and DrawCustomGraph().
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

Does this come already set up on the new units or something cause I never put it there? So now all I have to do is modify it the way I want it?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

No. It looks like you added it as part of the dimming weather package the way its setup. So yes, you just need to start tweaking it.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

ok well i removed the previous custom portion from my code and placed the one you gave me in there and it loaded with a graph on my screen.
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

here is how i did the code pic of screen to follow



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


    // 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.StandardATO( Port1,60 );
    ReefAngel.StandardLights( Port3,18,0,10,0 );
    ReefAngel.WavemakerRandom( Port5,30,100 );
    ReefAngel.WavemakerRandom( Port6,30,100 );
    ReefAngel.StandardHeater( Port7,752,755 );
    ReefAngel.PWM.SetChannel( 0, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 1, PWMSlope(7,30,21,30,0,35,180,0) );
    ReefAngel.PWM.SetChannel( 2, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 3, PWMSlope(7,30,21,30,0,35,180,0) );
    ReefAngel.PWM.SetChannel( 4, PWMSlope(7,0,22,0,0,40,180,0) );
    ReefAngel.PWM.SetChannel( 5, PWMSlope(7,30,21,30,0,35,180,0) );
    ////// Place your custom code below here
    if (hour()>=8 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(100,20,true) ); // ReefCrest at 100% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(100,20,false) ); // ReefCrest at 100% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
  ReefAngel.PWM.SetDaylight( ShortPulseMode(0,100,200,true) ); // Short pulse at 100% with 200ms pulse on sync mode
  ReefAngel.PWM.SetActinic( ShortPulseMode(0,100,200,false) ); // Short pulse at 100% with 200ms pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( LongPulseMode(0,100,10,true) ); // Long pulse at 100% with 10s pulse on sync mode
  ReefAngel.PWM.SetActinic( LongPulseMode(0,100,10,false) ); // Long pulse at 6100% with 10s pulse on anti-sync mode
}
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.Portal( "jjdezek" );
    ReefAngel.ShowInterface();
}

void DrawParams(int x, int y) {
  char buf[16];

  ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+5,y,"Temp:");
  ReefAngel.LCD.DrawText(COLOR_BLACK,DefaultBGColor,x+80, y, "PH:");
  // Temp and PH
  y+=2;

  ConvertNumToString(buf, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(T1TempColor, DefaultBGColor, x+5, y, buf, Num8x16);
  ConvertNumToString(buf, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+80, y, buf, Num8x16);
  y+=5;
  ReefAngel.LCD.DrawText(T3TempColor, DefaultBGColor, x+45, y, buf);
}

void DrawStatus(int x, int y) {
  int t=x;
  
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,15,y,"High",Font8x16);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,85,y,"Low",Font8x16);
  
  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_RED);
  }
  
  if (ReefAngel.LowATO.IsActive()) {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_GREEN);
  } else {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_RED);
  }
}


void DrawCustomGraph()
{
}
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

Image
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

On so right now you took both DrawCustomMain() functions out and you are getting the stock screen...

You can now follow the tutorial and add that function in...when you do that you can use my functions that you also added correctly.

The syntax would be DrawStatus(x,y);
where x and y are the coordinates you want the ato circles and DrawParams(x,y);

You will use these inside the DrawCustomMain() function.

You do already have the DrawCustomGraph() function so make sure you dont add that one again when you follow the tutorial.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

ok you just confused me again. so do i put the custommenu code in the
////// Place global variable code below here


////// Place global variable code above here
wont that throw another error? Im trying to get a grasp on this coding stuff but everytime i think im getting the hang of it i find something that looses me.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

It goes at the bottom...it's a new function...look how DrawCustomGraph() is in your code...it I'll be just like that except with code in it...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

It could be where you put it last time, but that space is usually for variables...it doesn't really matter,..last time you had it in there twice ( at top and at bottom )...that was why you had an error
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

jjdezek wrote: Im trying to get a grasp on this coding stuff but everytime i think im getting the hang of it i find something that looses me.
Don't worry...we'll get you there...it's like learning a new language...actually it is learning a new language...

Check this tutorial it will help you understand a lot more. It really should be added as a MUST-READ!

http://forum.reefangel.com/viewtopic.php?p=27161#p27161
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

yeah i copied the custommenu code from the tutorial and put it in there and ran the varify and it didnt give any errors. im still not sure what to do next. I try reading the tutorial but it just makes me more cunfused. im more of a hands on learning. i can read all day and walk away not knowing what i read, not sure if it would be classified as A.D.D. it would really be helpful to see a partion of code typed out then see what that does on the screen. thanks for all the help with this.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Look at the last tutorial I posted...it's pretty much a line by line explanation of the code...


As far as the draw custom main tutorial...you had the right one that was posted earlier...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Here is an example from page 4 of the PDF from curt.

Code: Select all

////// Place global variable code below here
void DrawCustomMain()
{
     // the graph is drawn/updated when we exit the main menu &
     // when the parameters are saved
     ReefAngel.LCD.DrawDate(6, 112);
     pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
     ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
     ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
     pingSerial();
     byte TempRelay = ReefAngel.Relay.RelayData;
     TempRelay &= ReefAngel.Relay.RelayMaskOff;
     TempRelay |= ReefAngel.Relay.RelayMaskOn;
     ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}
void DrawCustomGraph()
{
     ReefAngel.LCD.DrawGraph(5,5);
}
////// Place global variable code above here
I see now why you posted it above :)

Let's look at a few lines...

Code: Select all

ReefAngel.LCD.DrawDate(6, 112);
What do you think that does? It draws the date at coordinates 6,112..

The pingSerial() commands are no longer needed in this function...you can ignore them...but what they used to do is manage the wifi while we were busy drawing new screens...

Code: Select all

ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
Ignore all the #ifdef lines for now...they are basically a way to make the screen generic for people that want to use sections of code to minimize the memory footprint...advanced topic for you...but look at this last line that I posted above...
it uses the DrawMonitor() function to print the daylight and actinic values on the screen starting at coordinates 15,60.

So to use the functions I gave you, you would just "call" one of mine inside the DrawCustomMain() with something like this.

Code: Select all

DrawStatus(15,80);
I recommend starting by just changing around the x and y locations in the default example so you can get that hands-on feeling and make room for what you want to add. Once you start getting a feel it will become easier.


I noodled that because I didn't want you to miss the recommendation through all the code explanation.
Post Reply