My pde with a custom main screen

Share you PDE file with our community
Post Reply
maxxdog21
Posts: 34
Joined: Thu Dec 08, 2011 3:19 pm

My pde with a custom main screen

Post by maxxdog21 »

My first try at a custom main screen. Thanks to roberto and others for some code.
Image

Code: Select all

/* The following features are enabled for this PDE File: 
#define SIMPLE_MENU
#define DisplayLEDPWM
#define RelayExp
#define wifi
#define VersionMenu
#define PWMEXPANSION
#define CUSTOM_MAIN
#define NUMBERS_8x16
#define COLORS_PDE
*/


#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Wifi.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#include <ReefAngel_Salinity.h>
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>


byte PWMChannel[]={
  0,0,0,0,0,0};
  
void DrawCustomMain()
{
  //Top Banner
  ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 9, 2, " Harry's 120H Reef "); 
  ReefAngel.LCD.DrawDate(6, 123);
  pingSerial();

  // Display Temp Text
  ReefAngel.LCD.DrawText(0,255,8,12,"Temp");
  
  // Display the T1 temp value
  char text[7];
  ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
  ReefAngel.LCD.Clear(255, 4, 22, 37, 38);
  ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 4, 22, text, Num8x16);
  pingSerial();

// Display Salt Text
  ReefAngel.LCD.DrawText(0,255,54,12,"Salt");
  
  // Display Salt Value
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.Clear(255, 52, 22, 75, 38);
  ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 52, 22, text, Num8x16);
  pingSerial();

  // Display pH Text
  ReefAngel.LCD.DrawText(0,255,112,12,"pH");
  
  // Display pH Value
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.Clear(255, 94, 22, 106, 38);
  ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 94, 22, text, Num8x16);
  pingSerial();

  
// Display Actinic Percentage Text
  ReefAngel.LCD.DrawText(0,255,8,40,"Blue LED %");

// Display Actinic Percentage Value
   ConvertNumToString(text, PWMChannel[1], 1);
   strcat(text,"  ");
   ReefAngel.LCD.DrawText(0, 255, 80, 40, text);
   pingSerial();  

 // Display Daylight Percentage Text
  ReefAngel.LCD.DrawText(0,255,8,50,"White LED %");

 // Display Daylight Percentage Value
   ConvertNumToString(text, PWMChannel[0], 1);
   strcat(text,"  ");
   ReefAngel.LCD.DrawText(0, 255, 80, 50, text);
   pingSerial();

 // Display Moonlight Phase Text
  ReefAngel.LCD.DrawText(0,255,8,60,"Moonlight ");

 // Display Moonlight Phase Value
  ConvertNumToString(text, PWMChannel[2], 1);
  strcat(text,"  ");
  ReefAngel.LCD.DrawText(0, 255, 80, 60, text);
  pingSerial();

 
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(13, 97, TempRelay);
  pingSerial();

  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(13, 109, TempRelay);
  pingSerial();
  

}
 void DrawCustomGraph()
{
 }

void setup()
{
  ReefAngel.Init();  //Initialize controller

  ReefAngel.FeedingModePorts = B00110000;
  ReefAngel.FeedingModePortsE[0] = B00110000;
  ReefAngel.WaterChangePorts = B00111100;
  ReefAngel.WaterChangePortsE[0] = B00110011;
  ReefAngel.OverheatShutoffPorts = B00000011;
  ReefAngel.LightsOnPorts = B00011110;

  // Ports that are always on
  ReefAngel.Relay.On(Port3);
  ReefAngel.Relay.On(Port4);
  ReefAngel.Relay.On(Box1_Port1);
  ReefAngel.Relay.On(Box1_Port2);

  // Wavemaker timer
  ReefAngel.Timer[1].SetInterval(random(15,90));
  ReefAngel.Timer[1].Start();
  ReefAngel.Relay.On(Port6);
  ReefAngel.Relay.On(Box1_Port6);

}

void loop()
{	
  ReefAngel.ShowInterface();

  // Specific functions

  // T5 White
  ReefAngel.StandardLights(Port1,10,30,20,0);
  
  //T5 Blue
  ReefAngel.StandardLights(Port2,9,30,20,45);
  
  //LED Blue
  ReefAngel.StandardLights(Port7,9,0,21,15);
  
  //LED White
  ReefAngel.StandardLights(Port8,10,0,20,30);
  
  //Heater
  ReefAngel.StandardHeater(Box1_Port3,773,783);
  
  //Refugium
  ReefAngel.StandardLights(Box1_Port4,21,0,7,0);
  
  //Fan
  ReefAngel.StandardLights(Box1_Port7,8,30,21,0);
  
  //LED Moonlight
  ReefAngel.StandardLights(Box1_Port8,20,45,7,30);
  
  // Channel 0 = White
  PWMChannel[0]=PWMSlope(10,0,20,30,0,100,30,PWMChannel[0]); // calculate slope %
  // Channel 1 = Blue
  PWMChannel[1]=PWMSlope(9,0,21,15,0,100,30,PWMChannel[1]); // calculate slope %
  // Channel 2= Moonlights
  PWMChannel[2]=MoonPhase(); // calculate moon phase %

  // this section sends the data to the PWM expansion module
  for (int a=0;a<4;a++)
    ReefAngel.PWM.Expansion(a,int(2.55*PWMChannel[a]));

  // Wavemaker
  if ( ReefAngel.Timer[1].IsTriggered() )
  {
    ReefAngel.Timer[1].SetInterval(random(15,90));
    ReefAngel.Timer[1].Start();
    ReefAngel.Relay.Toggle(Port5);
    ReefAngel.Relay.Toggle(Port6);
    ReefAngel.Relay.Toggle(Box1_Port5);
    ReefAngel.Relay.Toggle(Box1_Port6);
  } 


}


psyrob
Posts: 247
Joined: Thu Sep 01, 2011 8:44 pm

Re: My pde with a custom main screen

Post by psyrob »

Looks great...good contrast of colors, the data really stands out...
Image
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: My pde with a custom main screen

Post by TanksNStuff »

I like the simplicity of your screen layout, but I might have gone with a darker blue color for the T1 Temp, Salt, pH values. Maybe ROYALBLUE instead of CORNFLOWERBLUE ?

Then again, maybe the flash from the camera distorts the actual look of it? Other than that, I'd say it's great!
maxxdog21
Posts: 34
Joined: Thu Dec 08, 2011 3:19 pm

Re: My pde with a custom main screen

Post by maxxdog21 »

Thanks for the nice comments. The flash did wash it out a little, in person it is fairly easy to read. I did change the color to a little darker just to see and it really didn't make much difference.
TanksNStuff
Posts: 188
Joined: Fri Dec 30, 2011 6:57 am

Re: My pde with a custom main screen

Post by TanksNStuff »

Yea, I actually borrowed pretty much your entire main screen code and the colors looked ok on mine in person too.

The only differences I made on mine was:
1. The banner text was customized (obviously)
2. I don't have salinity module, so I displayed Temp 2 instead
3. I have only LED's and they're on channels 0-3 on the PWM expansion module... so I listed all 4 of those channels and labeled them (LED B1, LEDB2, LEDW1, LEDW2). This took the place of your Blue LED %, White LED %, and Moonlight lines. I'm also considering altering the colors of these when I finish the rest of my code (if there's room for the extra bytes after all the important stuff goes in.)

Sorry I don't have a pic to show. Next time I hook it all up I'll take a pic and show it, along with my .pde. As I said above, I'm still working on my complete .pde file so it's not done and functioning at the moment. But I'm pretty happy with the display part so far at least.

Thanks for sharing this, it helped me a lot. The double relay box display was what I was looking for and when I found it in yours, I ended up adopting almost the entire main screen theme. ;)
Post Reply