need custom PDE help

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

Re: need custom PDE help

Post by jjdezek »

I want to keep the DP AP part of the params and delete the rest. is it easy to change the name from DP to say WP40L and AP to say WP40R?


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

Re: need custom PDE help

Post by lnevo »

Yes it's all very easy.

You will take out the block of code that is drawing the rest of the parameters and add something like this:

Code: Select all

DrawText(DPColor,DefaultBGColor,x+60,y+10,"DP:");
DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
DrawText(APColor,DefaultBGColor,x+60,y+20,"AP:");
DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+78, y+20,1);
you will need to play with the x and y and change the DP and AP to what you want

The DrawText function prints your label and the DrawSingleMonitor draws the values.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

easy for someone who knows what there doing maybe but is it easy for someone like me lol. ok so whats the x+60 mean, is that where its placing it on the screen? I tried plugging it in and get error not defined in scope?
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

is this what you mean by changing the DP and AP?

Code: Select all

DrawText(WP40LColor,DefaultBGColor,x+60,y+10,"WP40L:");
DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), WP40LColor, x+78, y+10,1);
DrawText(WP40RColor,DefaultBGColor,x+60,y+20,"WP40R:");
DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),WP40RPColor, x+78, y+20,1);
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

yes but don't change it for the colors... since WP40LColor and WP40RPColor are not defined... :)
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

so like this? now where do i put this exactly? in the bottom section or in the section between the global variable? I tried both but got the error saying not declared in this scope.
DrawText(DPColor,DefaultBGColor,x+60,y+10,"WP40L:");
DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
DrawText(APColor,DefaultBGColor,x+60,y+20,"WP40R:");
DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x+78, y+20,1);
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

This would all go inside your DrawCustomMain() function like you did with DrawStatus() and DrawParams(),

I see what the error is. I copied the code directly from the library function that does DrawMonitor...

so to use it in your code, you need to change DrawText to ReefAngel.LCD.DrawText and change DrawSingleMonitor to ReefAngel.LCD.DrawSingleMonitor.

Sorry about that.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

so i changed it like this

Code: Select all

ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x+60,y+10,"WP40L:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+60,y+20,"WP40R:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x+78, y+20,1);
and put it in here

Code: Select all

{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
ReefAngel.LCD.DrawText(COLOR_INDIGO, COLOR_WHITE,25,5, "Jeremy's Reef");
pingSerial();
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x+60,y+10,"WP40L:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+60,y+20,"WP40R:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x+78, y+20,1);
DrawStatus (20,80);
DrawParams (5,60);
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}
and got error the x and y are not declaired in this scope
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

ok i moved it into the bottom portion with the custom params section and it loaded. just got to figure out the placement.
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

thats not working all my params i.e. temp ph and pwm readings are all ontop of eachother.
ok did some more playing and created a new paramsa section to put the pwm files in so i can place them in there own area. :D
Last edited by jjdezek on Tue Jun 11, 2013 12:12 pm, edited 1 time in total.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

You just gotta play with the x and y's now. You don't define x and y in your DrawCustomMain I believe so you shouldn't have them in your DrawText and stuff... for the 4 lines you added, just start changing the x and y values to what works...

Now it's just a matter of moving things aroudn where you want them.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

ok still have a problem with the temp and ph showing up correctly. the big numbers overlap the words temp and ph. how do you offset the words from the numbers in each set of coding is that what the x+80,y+10 are for?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Yes, exactly. So just play around with it. You could always take out the x+ and y+ and just put hard coded numbers. It's odd that the temp and ph are offset though because the placement of the labels and variables should all be relative to each other, but not sure what's going on.

Either way you're on the right track.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

heres 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
#define NUMBERS_8x16
void DrawCustomMain()
{
// the graph is drawn/updated when we exit the main menu &
// when the parameters are saved
ReefAngel.LCD.DrawDate(6, 112);
ReefAngel.LCD.DrawText(COLOR_INDIGO, COLOR_WHITE,25,5, "Jeremy's Reef");
pingSerial();

DrawStatus (20,80);
DrawParams (5,40);
DrawParamsa (0,10);
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( 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 DrawParamsa(int x, int y){
char buf[16];
  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x+60,y+10,"WP40L:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+60,y+20,"WP40R:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x+78, y+20,1);

}

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+=10;

  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;

 }

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 »

Here is the screen

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

Re: need custom PDE help

Post by lnevo »

Looking good. Looks like the only thing left is to move the WP40R and WP40L labels over to the left. Something to keep in mind is that characters are 8pixels wide and you replaced two characters (AP and DP) with 5. That should tell you a bit how much to move them over.
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

For the wp40 I have it set at 0,10 and that's where it placed it. It's acting like the temp 1,2,and3 are still there.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Lets see the code. Its acting like the temps are still there because that was there default location when i copied the code for you. I suspect its not 0 and 10 as you think
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

I posted the code above the last screen shot
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

I see that! Kudos on creating your own function!!!!

You are indeed passing in 0,10 to your DrawParamsa function but inside that function the first draw is x+60!!!

So now go into your new function and adjust the values. You are well on your way!!

I feel like a proud poppa :D
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

yup that fixed it now its showing the full wp40L and wp40R centered in the screen
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

Image
Last edited by jjdezek on Tue Jun 11, 2013 5:25 pm, edited 1 time in total.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: need custom PDE help

Post by lnevo »

Sweet! Great job! Sorry I couldn't just do all that for you, but I do most of my replies from my phone or at work and don't have the compiler handy and drawing elements you really need the screen to test and see what you're doing. But it seems your picking it up pretty well and you built an awesome looking display! And now you can add C programmer to your resume!
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

Yeah I noticed that updated with correct one. Thanks for your time and help.
Image
jjdezek
Posts: 329
Joined: Fri May 17, 2013 1:35 pm

Re: need custom PDE help

Post by jjdezek »

Yeah not yet still have some learning to do before I can put that on a resume. Next thing is to set up a toggle for the different wave patterns :D
Image
Post Reply