Custom Main Screens

Would you like to help?
Share your walkthrough tutorial with others
User avatar
Posts: 2745
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sat Jun 11, 2011 7:31 pm
Starting with 0.8.5.15 dev libraries, you are now able to create your own custom main screen. This topic will contain various main screens with the code to create them.

NOTE: There is a guide on creating the custom main screens. The link to download the guide is here:

http://curtbinder.info/ragen/docs/RA_Custom_Main_Screen.pdf

  • Default Screen
    default.JPG
    Default screen
    default.JPG (88.12 KiB) Viewed 7775 times

    Code: Select all
    void DrawCustomMain()
    {
      ReefAngel.LCD.DrawDate(6, 112);
      pingSerial();
      ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
                                ReefAngel.PWM.GetDaylightValue(),
                                ReefAngel.PWM.GetActinicValue());
      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);
    }
  • Default Screen with banner at top
    banner.JPG
    Default screen with banner
    banner.JPG (111.9 KiB) Viewed 7775 times

    Code: Select all
    void DrawCustomMain()
    {
      // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Trevor's NC6");
      ReefAngel.LCD.DrawDate(6, 118);
      pingSerial();
      ReefAngel.LCD.DrawMonitor(15, 68, ReefAngel.Params,
                                ReefAngel.PWM.GetDaylightValue(),
                                ReefAngel.PWM.GetActinicValue());
      pingSerial();
      byte TempRelay = ReefAngel.Relay.RelayData;
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 101, TempRelay);
    }

    void DrawCustomGraph()
    {
      ReefAngel.LCD.DrawGraph(5, 11);
    }
  • Banner with 2 Relays with Outlets Green = ON and Red = OFF
    Banner_2Relays.JPG
    Banner with 2 relays
    Banner_2Relays.JPG (102.53 KiB) Viewed 7766 times

    NOTE: This color change requires enabling COLORS_PDE in your ReefAngel_Features.h file
    Code: Select all
    // ReefAngel_Features.h
    #define COLORS_PDE

    This is the code that goes in your ReefAngel_CustomColors.h file. The file will already contain a lot of stuff in there (all this will be in there) but not the changes which are noted below. So you can just edit those lines indicated below.
    Code: Select all
    // ReefAngel_CustomColors.h
    #define T1TempColor         COLOR_RED
    #define T2TempColor         COLOR_CHOCOLATE
    #define T3TempColor         COLOR_MEDIUMORCHID
    #define PHColor             COLOR_SEAGREEN 
    #define DPColor             COLOR_SADDLEBROWN
    #define APColor             COLOR_DARKSLATEBLUE
    #define CalibrateColor      COLOR_RED 
    #define ModeScreenColor     COLOR_BLUE
    #define DateTextColor       COLOR_RED 
    #define OutletBorderColor   0x54 
    #define OutletOnBGColor     COLOR_GREEN  // CHANGED
    #define OutletOnFGColor     COLOR_WHITE 
    #define OutletOffBGColor    COLOR_RED  // CHANGED
    #define OutletOffFGColor    COLOR_WHITE  // CHANGED
    #define BtnBorderColor      COLOR_BLACK
    #define BtnActiveColor      COLOR_GRAY
    #define BtnInactiveColor    COLOR_LIGHTGRAY
    #define SelectionBGColor    COLOR_BLUE 
    #define SelectionFGColor    COLOR_WHITE
    #define DefaultBGColor      COLOR_WHITE 
    #define DefaultFGColor      COLOR_BLACK 
    #define GraphDotLineColor   0x49   

    Code to add at the top of your PDE file
    Code: Select all
    // You must add these lines at the top of the includes in your PDE
    #include <ReefAngel_Colors.h>
    #include <ReefAngel_CustomColors.h>
    #include <ReefAngel_Features.h>  // This is the first include line normally

    The custom main screen functions
    Code: Select all
    void DrawCustomMain()
    {
      // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 45, 2, "Alex Bush");
      ReefAngel.LCD.DrawDate(6, 119);
      pingSerial();
      ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
                                ReefAngel.PWM.GetDaylightValue(),
                                ReefAngel.PWM.GetActinicValue());
      pingSerial();
      // draw main relay
      byte TempRelay = ReefAngel.Relay.RelayData;
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
    #ifdef RelayExp
      // draw 1st expansion relay
      TempRelay = ReefAngel.Relay.RelayDataE[0];
      TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
      TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
      ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
    #endif  // RelayExp
    }

    void DrawCustomGraph()
    {
      ReefAngel.LCD.DrawGraph(5, 10);
    }

Feel free to post your own custom main screens. Please include a screenshot and the code used to create the screen with your post.

curt

Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA
PostPosted: Sat Jun 11, 2011 11:54 pm
awesome! Can you post a code to display 16 relays? They can be directly below the top 8.
User avatar
Posts: 2745
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sun Jun 12, 2011 5:36 am
alexwbush wrote:awesome! Can you post a code to display 16 relays? They can be directly below the top 8.


Like which screen? I've got some that can display the 16 relays. I just would like to know which screen you would like it to look like.....the default or with a banner.

curt

Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA
PostPosted: Sun Jun 12, 2011 1:08 pm
I would like both. Does the banner get rid of the time at the bottom? If so, preference goes to the default. Is this the one with green=on and red=off? I might end up replacing the DP and AP with a timer when the ATO starts up. I am having some trouble with the timer, but I'll post that in my auto water change thread. Thanks Curt!
User avatar
Posts: 2745
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sun Jun 12, 2011 2:52 pm
alexwbush wrote:I would like both. Does the banner get rid of the time at the bottom?

No, the banner does not get rid of the time at the bottom. Take a second look at the pictures. You will probably have to scroll the image down to see the bottom but the time is still there.

alexbush wrote:Is this the one with green=on and red=off?

No, it's not with the green=on and red=off. That will require enabling the COLORS_PDE define and adding in additional includes to your PDE for the custom colors. I can do it though and post how to enable it. :ugeek:

curt

Posts: 69
Joined: Thu Jun 02, 2011 1:58 pm
PostPosted: Sun Jun 12, 2011 5:22 pm
hey all, just a preference but it does add to the clean lines of the main, set the relay port outline to match the bg color...then you just have the colored ports.

hey curt, how hard would it be to invert the values for ap and dp that are displayed? roberto got me a working code for the pwmslope cause buckpucks r inverted, 0 volt is on 5 volts is off...while it works as it should the displayed values are wrong, instead on being say 60% as it should it reads 40%, get what im saying? thanks

Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA
PostPosted: Sun Jun 12, 2011 8:26 pm
Please feel free to delete this later to keep the tutorial clean.

I am having trouble making this work. I followed all of the steps and I didn't have any compile errors, but I still see the same default display. Here's my PDE code:
Note that I tried to make the web banner work with my expansion relays, but no luck so that's why that code is commented out.
Code: Select all
// Autogenerated file by RAGen (v1.0.4.92), (05/08/2011 17:03)
// RA_050811_1703.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File:
#define DisplayImages
#define WavemakerSetup
#define DateTimeSetup
#define ATOSetup
#define MetalHalideSetup
#define DirectTempSensor
#define RelayExp
#define SingleATOSetup
#define StandardLightSetup
*/

#define DateTimeSetup
#define ATOSetup
#define WavemakerSetup

//Custom colors
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>

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

/*
#define Box1_Port1    11    Fuge LED
#define Box1_Port2    12    Carbon Reactor
#define Box1_Port3    13   
#define Box1_Port4    14    Vortech
#define Box1_Port5    15    WC Heater
#define Box1_Port6    16    WC Pump
#define Box1_Port7    17    Actinic LED
#define Box1_Port8    18   
*/

/*
//#include <avr/pgmspace.h>
prog_char id_label[] PROGMEM = "wolfpack1206";
prog_char probe1_label[] PROGMEM = "Water";
prog_char probe2_label[] PROGMEM = "Room";
prog_char probe3_label[] PROGMEM = "Not%20Used";
prog_char relay1_label[] PROGMEM = "ATO";
prog_char relay2_label[] PROGMEM = "Moonlight";
prog_char relay3_label[] PROGMEM = "Actinic";
prog_char relay4_label[] PROGMEM = "Halide";
prog_char relay5_label[] PROGMEM = "Sump%20Light";
prog_char relay6_label[] PROGMEM = "Powerhead";
prog_char relay7_label[] PROGMEM = "Heater";
prog_char relay8_label[] PROGMEM = "Return";
#ifdef RelayExp
#if InstalledRelayExpansionModules >= 1
prog_char relay11_label[] PROGMEM = "Box1%20Port1";
prog_char relay12_label[] PROGMEM = "Box1%20Port2";
prog_char relay13_label[] PROGMEM = "Box1%20Port3";
prog_char relay14_label[] PROGMEM = "Box1%20Port4";
prog_char relay15_label[] PROGMEM = "Box1%20Port5";
prog_char relay16_label[] PROGMEM = "Box1%20Port6";
prog_char relay17_label[] PROGMEM = "Box1%20Port7";
prog_char relay18_label[] PROGMEM = "Box1%20Port8";
#endif  // InstalledRelayExpansionModules >= 1
#if InstalledRelayExpansionModules >= 2
prog_char relay21_label[] PROGMEM = "Box2%20Port1";
prog_char relay22_label[] PROGMEM = "Box2%20Port2";
prog_char relay23_label[] PROGMEM = "Box2%20Port3";
prog_char relay24_label[] PROGMEM = "Box2%20Port4";
prog_char relay25_label[] PROGMEM = "Box2%20Port5";
prog_char relay26_label[] PROGMEM = "Box2%20Port6";
prog_char relay27_label[] PROGMEM = "Box2%20Port7";
prog_char relay28_label[] PROGMEM = "Box2%20Port8";
#endif  // InstalledRelayExpansionModules >= 2
#if InstalledRelayExpansionModules >= 3
prog_char relay31_label[] PROGMEM = "Box3%20Port1";
prog_char relay32_label[] PROGMEM = "Box3%20Port2";
prog_char relay33_label[] PROGMEM = "Box3%20Port3";
prog_char relay34_label[] PROGMEM = "Box3%20Port4";
prog_char relay35_label[] PROGMEM = "Box3%20Port5";
prog_char relay36_label[] PROGMEM = "Box3%20Port6";
prog_char relay37_label[] PROGMEM = "Box3%20Port7";
prog_char relay38_label[] PROGMEM = "Box3%20Port8";
#endif  // InstalledRelayExpansionModules >= 3
#if InstalledRelayExpansionModules >= 4
prog_char relay41_label[] PROGMEM = "Box4%20Port1";
prog_char relay42_label[] PROGMEM = "Box4%20Port2";
prog_char relay43_label[] PROGMEM = "Box4%20Port3";
prog_char relay44_label[] PROGMEM = "Box4%20Port4";
prog_char relay45_label[] PROGMEM = "Box4%20Port5";
prog_char relay46_label[] PROGMEM = "Box4%20Port6";
prog_char relay47_label[] PROGMEM = "Box4%20Port7";
prog_char relay48_label[] PROGMEM = "Box4%20Port8";
#endif  // InstalledRelayExpansionModules >= 4
#if InstalledRelayExpansionModules >= 5
prog_char relay51_label[] PROGMEM = "Box5%20Port1";
prog_char relay52_label[] PROGMEM = "Box5%20Port2";
prog_char relay53_label[] PROGMEM = "Box5%20Port3";
prog_char relay54_label[] PROGMEM = "Box5%20Port4";
prog_char relay55_label[] PROGMEM = "Box5%20Port5";
prog_char relay56_label[] PROGMEM = "Box5%20Port6";
prog_char relay57_label[] PROGMEM = "Box5%20Port7";
prog_char relay58_label[] PROGMEM = "Box5%20Port8";
#endif  // InstalledRelayExpansionModules >= 5
#if InstalledRelayExpansionModules >= 6
prog_char relay61_label[] PROGMEM = "Box6%20Port1";
prog_char relay62_label[] PROGMEM = "Box6%20Port2";
prog_char relay63_label[] PROGMEM = "Box6%20Port3";
prog_char relay64_label[] PROGMEM = "Box6%20Port4";
prog_char relay65_label[] PROGMEM = "Box6%20Port5";
prog_char relay66_label[] PROGMEM = "Box6%20Port6";
prog_char relay67_label[] PROGMEM = "Box6%20Port7";
prog_char relay68_label[] PROGMEM = "Box6%20Port8";
#endif  // InstalledRelayExpansionModules >= 6
#if InstalledRelayExpansionModules >= 7
prog_char relay71_label[] PROGMEM = "Box7%20Port1";
prog_char relay72_label[] PROGMEM = "Box7%20Port2";
prog_char relay73_label[] PROGMEM = "Box7%20Port3";
prog_char relay74_label[] PROGMEM = "Box7%20Port4";
prog_char relay75_label[] PROGMEM = "Box7%20Port5";
prog_char relay76_label[] PROGMEM = "Box7%20Port6";
prog_char relay77_label[] PROGMEM = "Box7%20Port7";
prog_char relay78_label[] PROGMEM = "Box7%20Port8";
#endif  // InstalledRelayExpansionModules >= 7
#if InstalledRelayExpansionModules >= 8
prog_char relay81_label[] PROGMEM = "Box8%20Port1";
prog_char relay82_label[] PROGMEM = "Box8%20Port2";
prog_char relay83_label[] PROGMEM = "Box8%20Port3";
prog_char relay84_label[] PROGMEM = "Box8%20Port4";
prog_char relay85_label[] PROGMEM = "Box8%20Port5";
prog_char relay86_label[] PROGMEM = "Box8%20Port6";
prog_char relay87_label[] PROGMEM = "Box8%20Port7";
prog_char relay88_label[] PROGMEM = "Box8%20Port8";
#endif  // InstalledRelayExpansionModules >= 8
#endif  // RelayExp

PROGMEM const char *webbanner_items[] = {
    id_label, probe1_label, probe2_label, probe3_label,
    relay1_label, relay2_label, relay3_label, relay4_label,
    relay5_label, relay6_label, relay7_label, relay8_label,
#ifdef RelayExp
#if InstalledRelayExpansionModules >= 1
    relay11_label, relay12_label, relay13_label, relay14_label,
    relay15_label, relay16_label, relay17_label, relay18_label,
#endif  // InstalledRelayExpansionModules >= 1
#if InstalledRelayExpansionModules >= 2
    relay21_label, relay22_label, relay23_label, relay24_label,
    relay25_label, relay26_label, relay27_label, relay28_label,
#endif  // InstalledRelayExpansionModules >= 2
#if InstalledRelayExpansionModules >= 3
    relay31_label, relay32_label, relay33_label, relay34_label,
    relay35_label, relay36_label, relay37_label, relay38_label,
#endif  // InstalledRelayExpansionModules >= 3
#if InstalledRelayExpansionModules >= 4
    relay41_label, relay42_label, relay43_label, relay44_label,
    relay45_label, relay46_label, relay47_label, relay48_label,
#endif  // InstalledRelayExpansionModules >= 4
#if InstalledRelayExpansionModules >= 5
    relay51_label, relay52_label, relay53_label, relay54_label,
    relay55_label, relay56_label, relay57_label, relay58_label,
#endif  // InstalledRelayExpansionModules >= 5
#if InstalledRelayExpansionModules >= 6
    relay61_label, relay62_label, relay63_label, relay64_label,
    relay65_label, relay66_label, relay67_label, relay68_label,
#endif  // InstalledRelayExpansionModules >= 6
#if InstalledRelayExpansionModules >= 7
    relay71_label, relay72_label, relay73_label, relay74_label,
    relay75_label, relay76_label, relay77_label, relay78_label,
#endif  // InstalledRelayExpansionModules >= 7
#if InstalledRelayExpansionModules >= 8
    relay81_label, relay82_label, relay83_label, relay84_label,
    relay85_label, relay86_label, relay87_label, relay88_label,
#endif  // InstalledRelayExpansionModules >= 8
#endif  // RelayExp
};
*/

void DrawCustomMain()
{
  // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
  ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 45, 2, "Alex's Cube");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
                            ReefAngel.PWM.GetDaylightValue(),
                            ReefAngel.PWM.GetActinicValue());
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph(5, 10);
}



void setup()
{
    ReefAngel.Init();  //Initialize controller
    //ReefAngel.LoadWebBanner(pgm_read_word(&(webbanner_items[0])), SIZE(webbanner_items));

    // Initialize and start the timer
    ReefAngel.Timer[4].SetInterval(120);  // set interval to 180 seconds
    ReefAngel.Timer[4].Start();

    ReefAngel.FeedingModePorts = B10101000;
    //ReefAngel.WaterChangePorts = B10000010;
    ReefAngel.WaterChangePorts = B00000001;
    ReefAngel.OverheatShutoffPorts = B00000110;

    // Ports that are always on
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port8);
   
    ReefAngel.Relay.On(Box1_Port1);
    ReefAngel.Relay.On(Box1_Port2);
    ReefAngel.Relay.On(Box1_Port4);
}

void loop()
{
    ReefAngel.ShowInterface();

    // Specific functions
    // ReefAngel.SingleATOHigh(Port1);
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.On(Port1);
        ReefAngel.Relay.On(Box1_Port6);
    }
    if(ReefAngel.HighATO.IsActive()==false)
    {
        ReefAngel.Relay.Off(Port1);
        ReefAngel.Relay.Off(Box1_Port6);
    }
    if(ReefAngel.LowATO.IsActive())
        ReefAngel.Relay.On(Port6);
    if(ReefAngel.LowATO.IsActive()==false)
        ReefAngel.Relay.Off(Port6);
   
    ReefAngel.StandardLights(Port2);
    ReefAngel.MHLights(Port3);
    ReefAngel.Wavemaker1(Port4);
    ReefAngel.StandardFan(Port5);
    ReefAngel.StandardHeater(Port7);
   
    ReefAngel.StandardLights(Box1_Port7,12,15,21,45);
}
User avatar
Posts: 2745
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Mon Jun 13, 2011 10:56 am
It works great for me.

You gotta make sure you add in the 2 extra define statements in your Features file....
Code: Select all
#define COLORS_PDE
#define CUSTOM_MAIN

That will fix it for you.

You got PM with PDE, Features & Colors files.

curt

Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA
PostPosted: Mon Jun 13, 2011 8:36 pm
Thanks Curt! Problem was that I had an older library without this in my features file
Code: Select all
#define CUSTOM_MAIN


thanks for PM and all of the code! One thing down, now to the skimmer delay and automatic water change! Oh and I just ordered an LED set... so that too.
User avatar
Posts: 2745
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Tue Jun 14, 2011 5:02 am
alexwbush wrote:Thanks Curt! Problem was that I had an older library without this in my features file
Code: Select all
#define CUSTOM_MAIN


thanks for PM and all of the code! One thing down, now to the skimmer delay and automatic water change! Oh and I just ordered an LED set... so that too.


The skimmer delay is in the latest library. Just use the DelayedOn function inside the loop instead of the On function inside setup.

curt
Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron