Custom Main Screens

Would you like to help?
Share your walkthrough tutorial with others
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Custom Main Screens

Post by Bo0sted_Rafi »

im trying to use the custom screen that showed here but when I upload the code, still showing the graph of the standard screen. Where in the code i remove that graph?
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Custom Main Screens

Post by cosmith71 »

Bo0sted_Rafi wrote:im trying to use the custom screen that showed here but when I upload the code, still showing the graph of the standard screen. Where in the code i remove that graph?
Add this to the very end of the code posted above:

Code: Select all

void DrawCustomGraph()
{
}
Did that fix it?

--Colin
Bo0sted_Rafi
Posts: 75
Joined: Thu Mar 21, 2013 12:11 pm

Re: Custom Main Screens

Post by Bo0sted_Rafi »

I wrote that but give me an error when i tried to compile

Code: Select all

#define SIMPLE_MENU
    #define NUMBERS_8x16

    #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
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

    ////// Place global variable code above here


    void setup()
    {
      // This must be the first line
      ReefAngel.Init(); //Initialize controller
      // Ports toggled in Feeding Mode
      ReefAngel.UseFlexiblePhCalibration();
      ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port3Bit | Port3Bit;
      // Ports toggled in Water Change Mode
      ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port3Bit | Port6Bit;
      // Ports toggled when Lights On / Off menu entry selected
      ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
      // Ports turned off when Overheat temperature exceeded
      ReefAngel.OverheatShutoffPorts = 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( 830 );

      // Ports that are always on
      ReefAngel.Relay.On( Port1 );
      ReefAngel.Relay.On( Port5 );

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

      for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

    void loop()
    {
      totalavgph=0;
      avgph[avgindex]=analogRead(PHPin);
      avgindex++;
      if (avgindex==10) avgindex=0;
      for (int a=0;a<10;a++)
        totalavgph+=avgph[a];
      totalavgph/=10;

      totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
      totalavgph=constrain(totalavgph,100,1400);

      if (totalavgph <= 645) ReefAngel.Relay.Off(Port3); 
      if (totalavgph >= 660) ReefAngel.Relay.On(Port3); 

      ReefAngel.Relay.DelayedOn( Port2 );
      //    ReefAngel.CO2Control( Port3,645,660 );
      ReefAngel.StandardFan( Port4,780,788 );
      ReefAngel.WavemakerRandom( Port6,600,180 );
      ReefAngel.StandardLights( Port7,0,30,12,30 );
      ReefAngel.StandardLights( Port8,12,0,2,30 );
      ////// Place your custom code below here
      ////// Place your custom code above here

      // This should always be the last line
      ReefAngel.Portal( "Bo0sted_Rafi" );
      ReefAngel.ShowInterface();
       }
     void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;        // Color for drawing temperature
      boolean FanOn = ReefAngel.Relay.Status(Port4);    // Get the status of the fan relay
      boolean HeatOn = ReefAngel.Relay.Status(Port7);   // Get the status of the heater relay
      if (HeatOn) 
      {
        TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
      }
      if (FanOn)   
      {
          TempColor = COLOR_RED;   // Red text, too warm, fan is on
      }
      if (!HeatOn && !FanOn) 
      {
          TempColor = COLOR_GREEN;  // Green text, no fan or heater on
      }
      // ***********************************************************************************
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");       // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                      // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);                                    // Draw a black line under the banner
      x = 12;
      y += MENU_START_ROW+1;                                                               // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp    CA pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                  // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16);    // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                       // Get T1 temp and convert
      y += MENU_START_ROW*2;
      x = 10;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += (16*4) + 8;
      
      // Code for drawing the relay box
      byte TempRelay = ReefAngel.Relay.RelayData;
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);

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


Dont let me erase the last code
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Custom Main Screens

Post by cosmith71 »

Take that code out of loop() and put it under your #includes (after "Place global variable code below here").

Try this:

Code: Select all

#define SIMPLE_MENU
    #define NUMBERS_8x16

    #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
    int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;        // Color for drawing temperature
      boolean FanOn = ReefAngel.Relay.Status(Port4);    // Get the status of the fan relay
      boolean HeatOn = ReefAngel.Relay.Status(Port7);   // Get the status of the heater relay
      if (HeatOn) 
      {
        TempColor = COLOR_NAVY;    // Blue text, too cold, heater is on
      }
      if (FanOn)   
      {
          TempColor = COLOR_RED;   // Red text, too warm, fan is on
      }
      if (!HeatOn && !FanOn) 
      {
          TempColor = COLOR_GREEN;  // Green text, no fan or heater on
      }
      // ***********************************************************************************
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Rafi's Reef");       // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                      // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);                                    // Draw a black line under the banner
      x = 12;
      y += MENU_START_ROW+1;                                                               // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp    CA pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                  // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16);    // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                       // Get T1 temp and convert
      y += MENU_START_ROW*2;
      x = 10;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, TempColor, x, y, text);                   // Draw the temperature, white numbers on a colored background
      x += (16*4) + 8;
      
      // Code for drawing the relay box
      byte TempRelay = ReefAngel.Relay.RelayData;
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);

   }
void DrawCustomGraph()
{
}
    ////// Place global variable code above here


    void setup()
    {
      // This must be the first line
      ReefAngel.Init(); //Initialize controller
      // Ports toggled in Feeding Mode
      ReefAngel.UseFlexiblePhCalibration();
      ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port5Bit | Port3Bit | Port3Bit;
      // Ports toggled in Water Change Mode
      ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port3Bit | Port6Bit;
      // Ports toggled when Lights On / Off menu entry selected
      ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
      // Ports turned off when Overheat temperature exceeded
      ReefAngel.OverheatShutoffPorts = 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( 830 );

      // Ports that are always on
      ReefAngel.Relay.On( Port1 );
      ReefAngel.Relay.On( Port5 );

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

      for (int a=0;a<10;a++) avgph[a]=analogRead(PHPin);

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

    void loop()
    {
      totalavgph=0;
      avgph[avgindex]=analogRead(PHPin);
      avgindex++;
      if (avgindex==10) avgindex=0;
      for (int a=0;a<10;a++)
        totalavgph+=avgph[a];
      totalavgph/=10;

      totalavgph=map(totalavgph, ReefAngel.PHMin, ReefAngel.PHMax, 700, 1000); // apply the calibration to the sensor reading
      totalavgph=constrain(totalavgph,100,1400);

      if (totalavgph <= 645) ReefAngel.Relay.Off(Port3); 
      if (totalavgph >= 660) ReefAngel.Relay.On(Port3); 

      ReefAngel.Relay.DelayedOn( Port2 );
      //    ReefAngel.CO2Control( Port3,645,660 );
      ReefAngel.StandardFan( Port4,780,788 );
      ReefAngel.WavemakerRandom( Port6,600,180 );
      ReefAngel.StandardLights( Port7,0,30,12,30 );
      ReefAngel.StandardLights( Port8,12,0,2,30 );
      ////// Place your custom code below here
      ////// Place your custom code above here

      // This should always be the last line
      ReefAngel.Portal( "Bo0sted_Rafi" );
      ReefAngel.ShowInterface();
       }
     

Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Re: Custom Main Screens

Post by Poiromaniax »

Heres my custom main.
IMG_2170.jpg
IMG_2170.jpg (36.99 KiB) Viewed 7967 times

Code: Select all

// Autogenerated file by RAGen (v1.2.2.171), (05/14/2012 18:11)
// RA_051412_1811.ino
//
// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define VersionMenu
#define DisplayLEDPWM
#define wifi
#define SIMPLE_MENU
#define CUSTOM_MAIN
#define RFEXPANSION
#define FONT_8x8
*/


#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 <RF.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 122);
    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();
  ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,DefaultBGColor,15,5,"Ariel's Reef");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,1,30,"Vortech:");
    byte vtechmode = InternalMemory.RFMode_read();
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,DefaultBGColor,50,30,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_PURPLE,DefaultBGColor,50,30,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,DefaultBGColor,50,30,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,DefaultBGColor,50,30,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,DefaultBGColor,50,30,"Long Pulse");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,DefaultBGColor,50,30,"Night");
    pingSerial();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 97, TempRelay);
}

void DrawCustomGraph()
{
}



void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.SetTemperatureUnit(1);  // set to Celsius Temperature

    // Ports that are always on
    ReefAngel.Relay.On(Port5);
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
    ////// Place additional initialization code below here
    

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

void loop()
{
    // Specific functions that use Internal Memory values
    ReefAngel.MHLights(Port1);
    ReefAngel.MHLights(Port2);
    ReefAngel.StandardHeater(Port3);
    ReefAngel.StandardHeater(Port4);
    ////// Place your custom code below here
    

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

    // This should always be the last line
    ReefAngel.ShowInterface();
}

Im not the best at coding so i have chopped quite a bit from other people

Ideally i would love to take out the bottom two rows and have:

Tank Name
Vortech
2 LED Channels (got a vertex illumilux)
Temp
PH
Relays
ATO - Plan on getting one of the new ones - so if theres a way to see how full the reservoir is

if anyone is willing to help me, you would be awesome in my eyes :geek:

Oh, and no peripherals are connected right now as im in the process of switching tanks - incase youre wondering ;)
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Custom Main Screens

Post by binder »

One thing I noticed is that you will want to make all these strings the same length:

Code: Select all

  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,DefaultBGColor,50,30,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_PURPLE,DefaultBGColor,50,30,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,DefaultBGColor,50,30,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,DefaultBGColor,50,30,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,DefaultBGColor,50,30,"Long Pulse");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,DefaultBGColor,50,30,"Night");
The "Constant", "Lagoon", etc. should be the same length and if they are not, then you should pad them. Looks like "Short Pulse" is the longest at 11 chars.

Code: Select all

So "Constant" should be "Constant   " and "Lagoon" should be "Lagoon     ".
The reason for this is when you change the modes and go from a larger text string to a smaller text string, there will be "ghosting" occurring from the extra characters not being overwritten.

Secondly, you say you want to change the layout of what is displayed? Do you not like having the 3 rows of 2 columns in the middle? Does that need to be changed for you?

Did you still want the date to be at the bottom of the screen? If not, you just need to remove this line:

Code: Select all

ReefAngel.LCD.DrawDate(6, 122);
from the DrawCustomMain() function and the date will no longer be displayed.
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Re: Custom Main Screens

Post by Poiromaniax »

binder wrote:One thing I noticed is that you will want to make all these strings the same length:

Code: Select all

  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,DefaultBGColor,50,30,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_PURPLE,DefaultBGColor,50,30,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,DefaultBGColor,50,30,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,DefaultBGColor,50,30,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,DefaultBGColor,50,30,"Long Pulse");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,DefaultBGColor,50,30,"Night");
The "Constant", "Lagoon", etc. should be the same length and if they are not, then you should pad them. Looks like "Short Pulse" is the longest at 11 chars.

Code: Select all

So "Constant" should be "Constant   " and "Lagoon" should be "Lagoon     ".
The reason for this is when you change the modes and go from a larger text string to a smaller text string, there will be "ghosting" occurring from the extra characters not being overwritten.

Thanks for pointing that out! So let me just make sure i understand, I should rather have all the vortech modes lined up in the code? (im not so savvy when it comes to coding and terms used, what is padding? the gap between the end of the word and the quotations? )

E.G:
"Lagoon "
"Constant "
"Reef Crest "


Secondly, you say you want to change the layout of what is displayed? Do you not like having the 3 rows of 2 columns in the middle? Does that need to be changed for you?

I like the 3x2 layout, just would like to be able to change the paramaters viewed to something like this:
Ariel's Reef
Vortech : Reef Crest
Temp 1: 26 PH: 8.3
White : 70% Blue: 20%
ATO level : 65% etc

(ATO level will get its data from the pressure sensor)


Did you still want the date to be at the bottom of the screen? If not, you just need to remove this line:

Code: Select all

ReefAngel.LCD.DrawDate(6, 122);
from the DrawCustomMain() function and the date will no longer be displayed.
Yeah i like the date and time at the bottom :) thanks though

Replies in red :)

EDIT - well my beautiful formatting has been destroyed by vBulletin/PHPBB

click edit the post and it will all look correct :P
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Custom Main Screens

Post by binder »

Thanks for pointing that out! So let me just make sure i understand, I should rather have all the vortech modes lined up in the code? (im not so savvy when it comes to coding and terms used, what is padding? the gap between the end of the word and the quotations? )

E.G:
"Lagoon "
"Constant "
"Reef Crest "
yes, the gap between the end of the word and quotation mark. the padding is simply just spaces. so count the letters and use spaces to fill in the extras like i mentioned.
I like the 3x2 layout, just would like to be able to change the paramaters viewed to something like this:
Ariel's Reef
Vortech : Reef Crest
Temp 1: 26 PH: 8.3
White : 70% Blue: 20%
ATO level : 65% etc

(ATO level will get its data from the pressure sensor)
the 3x2 layout you like will have to be created manually with copying and updating the function that displays it. i can help with it later tonight or tomorrow when i get home and can have access to a keyboard and look things up better with formatting. you can look at the DrawMonitor function inside the nokialcd.cpp file to get an idea.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Post by binder »

Ok, here's some code for you based on what you were wanting. I added comments to it and cleaned up things as well (I fixed the spacing issue). Here's the DrawCustomMain function as well as a helper function for drawing your custom monitor box. So just copy and paste these 2 functions into your INO file and replace the existing DrawCustomMain().

Code: Select all

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 122);

    // Draw the custom monitor, function listed below
    DrawCustomMonitor(15, 60);

    ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,DefaultBGColor,15,5,"Ariel's Reef");
    ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,1,30,"Vortech:");

    byte vtechmode = InternalMemory.RFMode_read();
    if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,DefaultBGColor,50,30,"Constant   ");
    else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_PURPLE,DefaultBGColor,50,30,"Lagoon     ");
    else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,DefaultBGColor,50,30,"Reef Crest ");
    else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,DefaultBGColor,50,30,"Short Pulse");
    else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,DefaultBGColor,50,30,"Long Pulse ");
    else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,DefaultBGColor,50,30,"Night      ");

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

void DrawCustomMonitor(byte x, byte y) {

    // To change the column (move it right or left), you will need to adjust the value for X
    // The Labels start at X and the values for them start at X+18. 
    // If you have to move them farther right (making 18 a larger number), you will need to adjust the values for X below for the second column. 
    // The 2nd column labels start at X+60 and the values start at X+78
    // left column - top item
    ReefAngel.LCD.DrawText(T1TempColor,DefaultBGColor,x,y,"T1:");
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], T1TempColor, x+18, y,10);
    // left column - middle item, White LED is on DP Channel
    ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x,y+10,"White:");
    // you may have to move the value farther to the right
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+18, y+10,1);
    // left column - bottom item
    ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x,y+20,"ATO Level:");
    // you may have to move the value farther to the right
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.WaterLevel.GetLevel(), T3TempColor, x+18, y+20,0);

    // right column - top item
    ReefAngel.LCD.DrawText(PHColor,DefaultBGColor,x+60,y,"PH:");
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, x+78, y,100);
    // right column - middle item, Blue LED is on AP Channel
    ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+60,y+10,"Blue:");
    // you may have to move the value farther to the right
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+78, y+10,1);
    // right column - bottom item (not used)
    //DrawText(APColor,DefaultBGColor,x+60,y+20,"AP:");
    //DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+78, y+20,1);
}
The colors may need to be adjusted for you, but that's really easy to change. Also, I assumed that your Blue LED were on the AP channel and the White LED were on the DP channel. They can be flipped if needed. We may also need to adjust the spacing of the column based on the size of the text labels. You will just have to adjust it accordingly and experiment with it.

EDIT: Fixed my typo errors with the code
Last edited by binder on Wed May 01, 2013 3:33 pm, edited 1 time in total.
Reason: Fixed typos in code
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Re:

Post by Poiromaniax »

binder wrote:Ok, here's some code for you based on what you were wanting. I added comments to it and cleaned up things as well (I fixed the spacing issue). Here's the DrawCustomMain function as well as a helper function for drawing your custom monitor box. So just copy and paste these 2 functions into your INO file and replace the existing .

Wow, thanks dude - You have saved me days of work :D

Il fiddle around with it a bit and post a screenshot when its working nicely :)

Edit - its throwing up this error
Screen Shot 2013-05-01 at 7.08.51 PM.png
Screen Shot 2013-05-01 at 7.08.51 PM.png (55.84 KiB) Viewed 7895 times
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Custom Main Screens

Post by binder »

I just fixed up my code in the previous post. I know the WHITE and Params errors should be gone now. I'm not sure why it is giving you the error about the WaterLevel member. It should be available because it found the Water Level Expansion Module.
Make sure you are running the latest libraries. Perhaps Roberto can shed some more light on this error.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Main Screens

Post by rimai »

Make sure you add this in your includes up top:

Code: Select all

#include <WaterLevel.h>
Roberto.
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Custom Main Screens

Post by Poiromaniax »

Thanks guys, will give a shot in a bit later :)
Image
ReeferBee
Posts: 55
Joined: Wed May 08, 2013 6:23 pm
Location: North GA

Re: Custom Main Screens

Post by ReeferBee »

Code: Select all


//*********************************************************************************************************************************
//Custom Main, Graph & Menu
void DrawCustomMain()
{
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];
  static byte vtechmode=0;

  ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 126, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 123, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 123, "|");


  ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,22,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");

  ReefAngel.LCD.DrawText(0,255,10,30,"Display");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,30,"pH");
  ConvertNumToString(text, ReefAngel.Params. PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
  pingSerial();

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

  ReefAngel.LCD.DrawText(0,255,8,68,"Sump");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_CORNFLOWERBLUE, 40, 68, 10);

  ReefAngel.LCD.DrawText(0,255,70,68,"Room");
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], COLOR_CORNFLOWERBLUE, 99, 68, 10);

}
void DrawCustomGraph()
{
}
Is it possible to mod this code to display the mode that my WP40 is running?
Barry

Current tank info: 150g mixed reef

"Some of the worst mistakes of my life were hair cuts" -Jim Morrison
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Custom Main Screens

Post by DrewPalmer04 »

That will display the mode your mp40 is running? Only if you're controlling it via the RF module? The RA sets the mode and then that code displays it on your custom main. I hope you have the RA+ or you'll run out of space quickly.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
ReeferBee
Posts: 55
Joined: Wed May 08, 2013 6:23 pm
Location: North GA

Re: Custom Main Screens

Post by ReeferBee »

DrewPalmer04 wrote:That will display the mode your mp40 is running? Only if you're controlling it via the RF module? The RA sets the mode and then that code displays it on your custom main. I hope you have the RA+ or you'll run out of space quickly.
Yes, using this part of the coding.

Code: Select all

 ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,22,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");
I believe this only works with the RF module though. I want it to display the mode my WP40 are in, through the use of the wp40 harness and dimming ports. Yep, the plus was a must!
Barry

Current tank info: 150g mixed reef

"Some of the worst mistakes of my life were hair cuts" -Jim Morrison
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Main Screens

Post by rimai »

You can do that.... Can you open a new thread and post your code?
Roberto.
ReeferBee
Posts: 55
Joined: Wed May 08, 2013 6:23 pm
Location: North GA

Re: Custom Main Screens

Post by ReeferBee »

It's not my code. Anther member posted it in this thread. I just wanted to change it up a litte bit. Should I still open another thread with it? Thanks
Barry

Current tank info: 150g mixed reef

"Some of the worst mistakes of my life were hair cuts" -Jim Morrison
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom Main Screens

Post by lnevo »

Yes, but post your code and that code seperately so we can see how it needs to be integrated.
ReeferBee
Posts: 55
Joined: Wed May 08, 2013 6:23 pm
Location: North GA

Re: Custom Main Screens

Post by ReeferBee »

After a day of tweaking the code I think i finally have it the way I like it.

Image

Code: Select all

//Custom Main, Graph & Menu
void DrawCustomMain()
{
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];

  ReefAngel.LCD.DrawDate(6, 4);
  ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
  pingSerial();

  ReefAngel.LCD.DrawLargeText(0,255,10,16,"  WP40 Mode:");
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,27,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,26,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,26,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,26,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,26,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,26,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,26,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,255,45,26,"Night");

  ReefAngel.LCD.DrawLargeText(0,255,17,49,"Sump");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawHugeText(COLOR_RED, 255, 12, 65, text, Num12x16);
  pingSerial();

  ReefAngel.LCD.DrawLargeText(0,255,100,40,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_BLUE, 255, 89, 55, text, Num8x8);
  pingSerial();
  
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,15,89, "WP40L"); 
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,20,100, ReefAngel.PWM.GetDaylightValue());
  ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,88,89, "WP40R"); 
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,95,100, ReefAngel.PWM.GetActinicValue());

  pingSerial();
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 113, TempRelay);
  
  
}
void DrawCustomGraph()
{
}
I cant take credit, I mostly copied and pasted others codes from this thread.

Thanks!
Last edited by ReeferBee on Tue May 21, 2013 9:22 pm, edited 1 time in total.
Barry

Current tank info: 150g mixed reef

"Some of the worst mistakes of my life were hair cuts" -Jim Morrison
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Main Screens

Post by rimai »

Super cool!!!
Can you post the code?
Roberto.
ReeferBee
Posts: 55
Joined: Wed May 08, 2013 6:23 pm
Location: North GA

Re: Custom Main Screens

Post by ReeferBee »

Thanks!
Done :)
Barry

Current tank info: 150g mixed reef

"Some of the worst mistakes of my life were hair cuts" -Jim Morrison
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Custom Main Screens

Post by binder »

ReeferBee wrote:Thanks!
Done :)
Very nice looking screen! Great job!
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Custom Main Screens

Post by Poiromaniax »

binder wrote:
ReeferBee wrote:Thanks!
Done :)
Very nice looking screen! Great job!

Agreed! Good job ReeferBee

I'm gonna use the basic layout and change a few parameters
Image
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Custom Main Screens

Post by jegillis »

IMAG0800.jpg
IMAG0800.jpg (54.87 KiB) Viewed 10278 times

Code: Select all

byte ActinicPWMValue=0;
byte DaylightPWMValue=0;
void DrawCustomMain()
{
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];
  //static byte vtechmode=0;

  ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
  pingSerial();
  
  ReefAngel.LCD.DrawLargeText(3,255,8,16,"Redneck Reefin!", Font8x8);
  ReefAngel.LCD.DrawLargeText(3,255,8,56,"Jason & Sarah's", Font8x8);
  ReefAngel.LCD.DrawLargeText(3,255,32,65,"Money Pit", Font8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 6, 126, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 2, 123, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_BLACK,255, 126, 123, "|");


  ReefAngel.LCD.DrawText(0,255,10,30,"Display");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_BLACK, 255, 10, 40, text, Num8x16);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,30,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_BLACK, 255, 85, 40, text, Num8x16);
  pingSerial();

  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 77, TempRelay);

  ReefAngel.LCD.DrawText(0,255,8,109, "CWLED");  
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,15,119, ReefAngel.PWM.GetDaylightValue());
  //ReefAngel.PWM.GetDaylightValue(), 
  ReefAngel.LCD.DrawText(0,255,88,108, "RBLED");  
  ReefAngel.LCD.DrawText(COLOR_BLACK,255,90,119, ReefAngel.PWM.GetActinicValue());
  //ReefAngel.PWM.GetActinicValue());
  
  //ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
                            //ReefAngel.PWM.GetDaylightValue(), 
                            //ReefAngel.PWM.GetActinicValue());

}
void DrawCustomGraph()
{
}
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Main Screens

Post by rimai »

I like it :)
Roberto.
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Custom Main Screens

Post by jegillis »

IMAG0801.jpg
IMAG0801.jpg (45.11 KiB) Viewed 10268 times
Well that didn't last long before I had to tinker would anyone have an idea on how I could have the temps change color if they are over a set limit?

Code: Select all

#define SIMPLE_MENU
#define NUMBERS_8x16
#define FONT_8x8

#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
byte ActinicPWMValue=0;
byte DaylightPWMValue=0;
void DrawCustomMain()
{
  byte x = 6;
  byte y = 2;
  byte t;
  char text[7];
  //static byte vtechmode=0;

  ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
  pingSerial();
  
  ReefAngel.LCD.DrawLargeText(3,255,8,14,"Redneck Reefin!", Font8x8);
  ReefAngel.LCD.DrawLargeText(3,255,8,55,"Jason & Sarah's", Font8x8);
  ReefAngel.LCD.DrawLargeText(3,255,32,64,"Money Pit", Font8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(COLOR_RED,255, 6, 88, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 6, 125, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 2, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 2, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 2, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 2, 123, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 126, 93, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 126, 103, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 126, 113, "|");
  ReefAngel.LCD.DrawText(COLOR_RED,255, 126, 123, "|");

  ReefAngel.LCD.DrawLargeText(0,255,8,25,"TANK", Font8x8);
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(224, 255, 42, 25, text, Font8x8);
  pingSerial();
  
  ReefAngel.LCD.DrawLargeText(0,255,8,35,"HOOD", Font8x8);
  ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(153, 255, 42, 35, text, Font8x8);
  pingSerial();
  
  ReefAngel.LCD.DrawLargeText(0,255,8,45,"ROOM", Font8x8);
  ConvertNumToString(text, ReefAngel.Params.Temp[T3_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(66, 255, 42, 45, text, Font8x8);

  ReefAngel.LCD.DrawText(0,255,100,25,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_BLACK, 255, 85, 35, text, Num8x16);
  pingSerial();

  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 75, TempRelay);
  pingSerial();
  
    ReefAngel.LCD.DrawText(0,255,8,96, "White=");  
  ReefAngel.LCD.DrawText(197,255,46,96, ReefAngel.PWM.GetDaylightValue());
  //ReefAngel.PWM.GetDaylightValue()), 
  ReefAngel.LCD.DrawText(0,255,72,96, "Blue=");   
  ReefAngel.LCD.DrawText(3,255,106,96, ReefAngel.PWM.GetActinicValue());
  //ReefAngel.PWM.GetActinicValue());


}
void DrawCustomGraph()
{
}


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
 
    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.SingleATOLow( Port1 );
    ReefAngel.Relay.Set( Port2, !ReefAngel.Relay.Status( Port3 ) );
    ReefAngel.ActinicLights( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.Wavemaker1( Port5 );
    ReefAngel.Wavemaker2( Port6 );
    ReefAngel.DosingPumpRepeat1( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.DaylightPWMSlope();
    ReefAngel.PWM.ActinicPWMSlope();
    
    // Calculate your regular sunrise/sunset PWM value
    ActinicPWMValue=PWMSlope(12,15,22,45,15,100,60,ActinicPWMValue);
    DaylightPWMValue=PWMSlope(13,0,22,0,15,100,60,DaylightPWMValue);
    CheckCloud();
    ReefAngel.PWM.SetActinic(ActinicPWMValue);
    ReefAngel.PWM.SetDaylight(DaylightPWMValue);

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

    // This should always be the last line
    ReefAngel.Portal( "jegillis" );
    ReefAngel.ShowInterface();
}
//*********************************************************************************************************************************
// Random Cloud/Thunderstorm effects function
void CheckCloud()
{

  // ------------------------------------------------------------
  // Change the values below to customize your cloud/storm effect

  // Frequency in days based on the day of the month - number 2 means every 2 days, for example (day 2,4,6 etc)
  // For testing purposes, you can use 1 and cause the cloud to occur everyday
#define Clouds_Every_X_Days 1 

  // Percentage chance of a cloud happening today
  // For testing purposes, you can use 100 and cause the cloud to have 100% chance of happening
#define Cloud_Chance_per_Day 100

  // Minimum number of minutes for cloud duration.  Don't use max duration of less than 6
#define Min_Cloud_Duration 7

  // Maximum number of minutes for the cloud duration. Don't use max duration of more than 255
#define Max_Cloud_Duration 15

  // Minimum number of clouds that can happen per day
#define Min_Clouds_per_Day 3

  // Maximum number of clouds that can happen per day
#define Max_Clouds_per_Day 5

  // Only start the cloud effect after this setting
  // In this example, start could after 11:30am
#define Start_Cloud_After NumMins(15,00)

  // Always end the cloud effect before this setting
  // In this example, end could before 8:00pm
#define End_Cloud_Before NumMins(22,00)

  // Percentage chance of a lightning happen for every cloud
  // For testing purposes, you can use 100 and cause the lightning to have 100% chance of happening
#define Lightning_Change_per_Cloud 100

  // Note: Make sure to choose correct values that will work within your PWMSLope settings.
  // For example, in our case, we could have a max of 5 clouds per day and they could last for 50 minutes.
  // Which could mean 250 minutes of clouds. We need to make sure the PWMSlope can accomodate 250 minutes of effects or unforseen resul could happen.
    // Also, make sure that you can fit double those minutes between Start_Cloud_After and End_Cloud_Before.
  // In our example, we have 510 minutes between Start_Cloud_After and End_Cloud_Before, so double the 250 minutes (or 500 minutes) can fit in that 510 minutes window.
    // It's a tight fit, but it did.

  //#define printdebug // Uncomment this for debug print on Serial Monitor window
  #define forcecloudcalculation // Uncomment this to force the cloud calculation to happen in the boot process. 


  // Change the values above to customize your cloud/storm effect
  // ------------------------------------------------------------
  // Do not change anything below here

  static byte cloudchance=255;
  static byte cloudduration=0;
  static int cloudstart=0;
  static byte numclouds=0;
  static byte lightningchance=0;
  static byte cloudindex=0;
  static byte lightningstatus=0;
  static int LastNumMins=0;
  // Every day at midnight, we check for chance of cloud happening today
  if (hour()==0 && minute()==0 && second()==0) cloudchance=255;

#ifdef forcecloudcalculation
    if (cloudchance==255)
#else
    if (hour()==0 && minute()==0 && second()==1 && cloudchance==255) 
#endif
    {
      //Pick a random number between 0 and 99
      cloudchance=random(100); 
      // if picked number is greater than Cloud_Chance_per_Day, we will not have clouds today
      if (cloudchance>Cloud_Chance_per_Day) cloudchance=0;
      // Check if today is day for clouds. 
      if ((day()%Clouds_Every_X_Days)!=0) cloudchance=0; 
      // If we have cloud today
      if (cloudchance)
      {
        // pick a random number for number of clouds between Min_Clouds_per_Day and Max_Clouds_per_Day
        numclouds=random(Min_Clouds_per_Day,Max_Clouds_per_Day);
        // pick the time that the first cloud will start
        // the range is calculated between Start_Cloud_After and the even distribuition of clouds on this day. 
        cloudstart=random(Start_Cloud_After,Start_Cloud_After+((End_Cloud_Before-Start_Cloud_After)/(numclouds*2)));
        // pick a random number for the cloud duration of first cloud.
        cloudduration=random(Min_Cloud_Duration,Max_Cloud_Duration);
        //Pick a random number between 0 and 99
        lightningchance=random(100);
        // if picked number is greater than Lightning_Change_per_Cloud, we will not have lightning today
        if (lightningchance>Lightning_Change_per_Cloud) lightningchance=0;
      }
    }
  // Now that we have all the parameters for the cloud, let's create the effect

  if (cloudchance)
  {
    //is it time for cloud yet?
    if (NumMins(hour(),minute())>=cloudstart && NumMins(hour(),minute())<(cloudstart+cloudduration))
    {
      DaylightPWMValue=ReversePWMSlope(cloudstart,cloudstart+cloudduration,DaylightPWMValue,15,180);
      if (lightningchance && (NumMins(hour(),minute())==(cloudstart+(cloudduration/2))) && second()<5)
      {
        if (random(100)<20) lightningstatus=1; 
        else lightningstatus=0;
        if (lightningstatus)
        {
          DaylightPWMValue=100; 
          ActinicPWMValue=100;
        }
        else 
        {
          DaylightPWMValue=0;
          ActinicPWMValue=15;
        }
        delay(1);
      }
    }
    if (NumMins(hour(),minute())>(cloudstart+cloudduration))
    {
      cloudindex++;
      if (cloudindex < numclouds)
      {
        cloudstart=random(Start_Cloud_After+(((End_Cloud_Before-Start_Cloud_After)/(numclouds*2))*cloudindex*2),(Start_Cloud_After+(((End_Cloud_Before-Start_Cloud_After)/(numclouds*2))*cloudindex*2))+((End_Cloud_Before-Start_Cloud_After)/(numclouds*2)));
        // pick a random number for the cloud duration of first cloud.
        cloudduration=random(Min_Cloud_Duration,Max_Cloud_Duration);
        //Pick a random number between 0 and 99
        lightningchance=random(100);
        // if picked number is greater than Lightning_Change_per_Cloud, we will not have lightning today
        if (lightningchance>Lightning_Change_per_Cloud) lightningchance=0;
      }
    }
  }
  
  if (LastNumMins!=NumMins(hour(),minute()))
  {
    LastNumMins=NumMins(hour(),minute());
    ReefAngel.LCD.Clear(255,0,120,132,132);
    ReefAngel.LCD.DrawText(0,255,8,108,"Cloud");
    ReefAngel.LCD.DrawText(0,255,8,118,"00:00");
    ReefAngel.LCD.DrawText(0,255,90,108,"Storm");
    ReefAngel.LCD.DrawText(0,255,48,108,"Length");
    ReefAngel.LCD.DrawText(0,255,90,118,"00:00");
    if (cloudchance && (NumMins(hour(),minute())<cloudstart))
    {
      int x=0;
      if ((cloudstart/60)>=10) x=8; else x=14;
      ReefAngel.LCD.DrawText(37,255,x,118,(cloudstart/60));
      if ((cloudstart%60)>=10) x=58; else x=64;
      ReefAngel.LCD.DrawText(37,255,x,118,(cloudstart%60));
    }
    if (lightningchance) 
    {
      int x=0;
      if (((cloudstart+(cloudduration/2))/60)>=10) x=90; else x=96;
      ReefAngel.LCD.DrawText(37,255,x,118,((cloudstart+(cloudduration/2))/60));
      if (((cloudstart+(cloudduration/2))%60)>=10) x=108; else x=114;
      ReefAngel.LCD.DrawText(37,255,x,118,((cloudstart+(cloudduration/2))%60));
    }
  }   
}

byte ReversePWMSlope(long cstart,long cend,byte PWMStart,byte PWMEnd, byte clength)
{
  long n=elapsedSecsToday(now());
  cstart*=60;
  cend*=60;
  if (n<cstart) return PWMStart;
  if (n>=cstart && n<=(cstart+clength)) return map(n,cstart,cstart+clength,PWMStart,PWMEnd);
  if (n>(cstart+clength) && n<(cend-clength)) return PWMEnd;
  if (n>=(cend-clength) && n<=cend) return map(n,cend-clength,cend,PWMEnd,PWMStart);
  if (n>cend) return PWMStart;
}
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom Main Screens

Post by lnevo »

I know someone did some code to base their temp color off the value, but I can't find it at the moment.

I did help add a function to the library so that if you go over a certain limit it will flash. Take a look at this thread:

http://forum.reefangel.com/viewtopic.ph ... nitoralarm

Oh and here is the post in this thread where someone changed the temp colors to be based on range

http://forum.reefangel.com/viewtopic.php?p=23651#p23651
jegillis
Posts: 86
Joined: Sat Jan 04, 2014 10:26 am

Re: Custom Main Screens

Post by jegillis »

Thanks, I used the color change the flashing is cool but I had no idea what I was looking at on that code
Image
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Custom Main Screens

Post by jsclownfish »

Here is the code I used. I don't know if it ever went into the libraries...

Code: Select all

//function to flash warning (parameter, high limt, low limit, x, y, decimal)
void Warningflash(int param, int high, int low, byte x, byte y, byte z)
{
  int mod=second()%2;
  if (param > high || param < low) 
 {
     if (mod==0) ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+40,y+10);
     else ReefAngel.LCD.DrawSingleMonitor(param, COLOR_RED, x, y, z);
 }
 else ReefAngel.LCD.DrawSingleMonitor(param, DefaultFGColor, x, y, z);
}
Post Reply