Page 1 of 1

Custom display

Posted: Thu Jul 19, 2012 10:39 am
by Appleseed

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 <ReefAngel.h>

////// Place global variable code below here
  // Globals Needed for RF Mode on Custom Main
    byte vtechmode;
    byte vtechspeed;
    byte vtechpercent;
    boolean bFeeding=false;
    
      byte x = 6;
      byte y = 2;
      byte t;
      char text[7];

    //Custom Main, Graph & Menu

    void DrawCustomMain()
    {
//      ReefAngel.LCD.DrawDate(6, 2);
      ReefAngel.LCD.DrawText(3,255,6,2," Reef of Low");

      ReefAngel.LCD.DrawDate(7, 99);
      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,21,"EcoSmart Vortech");
      if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,"Constant");
      else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,31,"Lagoon");
      else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,31,"Reef Crest");
      else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,31,"Short Pulse");
      else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,31,"Long Pulse");
      else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,31,"Nutrient Trnsp.");
      else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,31,"Tidal Swell");
      else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,31,"Night");

      ReefAngel.LCD.DrawText(0,255,10,50,"Tank");
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
      ReefAngel.LCD.DrawLargeText(COLOR_RED, 255, 10, 60, text, Num8x8);
      pingSerial();

      ReefAngel.LCD.DrawText(0,255,100,50,"pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);
      ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 85, 60, text, Num8x8);
      pingSerial();


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

    }
    void DrawCustomGraph()
    {
    }


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


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

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit | Port7Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 290 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1,251,261 );
    ReefAngel.StandardHeater( Port2,251,261 );
    ReefAngel.StandardFan( Port3,271,281 );
    ReefAngel.StandardLights( Port5,20,0,5,0 );
    ReefAngel.StandardLights( Port6,20,0,0,0 );
    ////
    ReefAngel.RF.UseMemory = false;

/////// CHANGE MODE @ TIMES
if ( ReefAngel.RF.Mode != Feeding_Start)
  
          if (hour()==10)
            ReefAngel.RF.SetMode( ReefCrest,30,20);
         else if (hour()>=6 || hour()<9)
            ReefAngel.RF.SetMode(ReefCrest,20,10);            
         else if (hour()>=9 && hour()<10)
            ReefAngel.RF.SetMode(ReefCrest,30,10);
         else if (hour()>=10 && hour()<11)
            ReefAngel.RF.SetMode(ReefCrest,40,10);
          else if (hour()>=11 && hour()<12)
            ReefAngel.RF.SetMode(Smart_NTM,50,6);
          else if (hour()>=12 && hour()<13)
            ReefAngel.RF.SetMode(Smart_NTM,60,10);
          else if (hour()>=13 && hour()<14)
            ReefAngel.RF.SetMode(Smart_NTM,70,12);
          else if (hour()>=14 && hour()<15)
            ReefAngel.RF.SetMode(Smart_NTM,60,10);
          else if (hour()>=15 && hour()<16)
            ReefAngel.RF.SetMode(Smart_NTM,50,8);
          else if (hour()>=16 && hour()<17)
            ReefAngel.RF.SetMode(Constant,50,10);
          else if (hour()>=17 && hour()<18)
            ReefAngel.RF.SetMode(Constant,40,10);            
          else if (hour()>=18 && hour()<19)
            ReefAngel.RF.SetMode(Constant,30,10);                        
          else if (hour()>=19 && hour()<20)
            ReefAngel.RF.SetMode(Constant,40,10);                        
          else if (hour()>=20 && hour()<21)
            ReefAngel.RF.SetMode(Constant,30,10);                        
          else if (hour()>=21 && hour()<22)
            ReefAngel.RF.SetMode(Constant,40,10);
          else if (hour()>=22 || hour()<23)
            ReefAngel.RF.SetMode(Constant,50,10);
          else if (hour()>=23 || hour()<0)
            ReefAngel.RF.SetMode(ReefCrest,60,10);            
          else if (hour()>=0 || hour()<1)
            ReefAngel.RF.SetMode(ReefCrest,50,10);           
          else if (hour()>=1 || hour()<3)
            ReefAngel.RF.SetMode(ReefCrest,40,10);            
         else if (hour()>=3 || hour()<6)
            ReefAngel.RF.SetMode(ReefCrest,30,10);            
          else
            ReefAngel.RF.SetMode(ReefCrest,40,10);
            
    ////// Place your custom code below here
    

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

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


Hello all,

I have been trying to get my display to show the mode that my vortechs are in (using code borrowed from people on here much smarter than me), the code currently only ever displays tha tthe pumps are in Constant mode but the led on the rf module shows that actual mode being not constant.
Can some one advise where I am going wrong?

cheers
Andy

Re: Custom display

Posted: Thu Jul 19, 2012 2:14 pm
by rimai
You need to assign the rf mode to the variable vortechmode:

Code: Select all

vtechmode=ReefAngel.RF.Mode;
Try this:

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 <ReefAngel.h>

////// Place global variable code below here
// Globals Needed for RF Mode on Custom Main
byte vtechmode;
byte vtechspeed;
byte vtechpercent;
boolean bFeeding=false;

byte x = 6;
byte y = 2;
byte t;
char text[7];

//Custom Main, Graph & Menu

void DrawCustomMain()
{
  //      ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.DrawText(3,255,6,2," Reef of Low");

  ReefAngel.LCD.DrawDate(7, 99);
  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, "|");

  vtechmode=ReefAngel.RF.Mode;

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

  ReefAngel.LCD.DrawText(0,255,10,50,"Tank");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_RED, 255, 10, 60, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,50,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 85, 60, text, Num8x8);
  pingSerial();


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

}
void DrawCustomGraph()
{
}


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


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

  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port4Bit | Port7Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = 0;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = 0;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 290 );

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

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


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

void loop()
{
  ReefAngel.StandardHeater( Port1,251,261 );
  ReefAngel.StandardHeater( Port2,251,261 );
  ReefAngel.StandardFan( Port3,271,281 );
  ReefAngel.StandardLights( Port5,20,0,5,0 );
  ReefAngel.StandardLights( Port6,20,0,0,0 );
  ////
  ReefAngel.RF.UseMemory = false;

  /////// CHANGE MODE @ TIMES
  if ( ReefAngel.RF.Mode != Feeding_Start)

    if (hour()==10)
      ReefAngel.RF.SetMode( ReefCrest,30,20);
    else if (hour()>=6 || hour()<9)
      ReefAngel.RF.SetMode(ReefCrest,20,10);            
    else if (hour()>=9 && hour()<10)
      ReefAngel.RF.SetMode(ReefCrest,30,10);
    else if (hour()>=10 && hour()<11)
      ReefAngel.RF.SetMode(ReefCrest,40,10);
    else if (hour()>=11 && hour()<12)
      ReefAngel.RF.SetMode(Smart_NTM,50,6);
    else if (hour()>=12 && hour()<13)
      ReefAngel.RF.SetMode(Smart_NTM,60,10);
    else if (hour()>=13 && hour()<14)
      ReefAngel.RF.SetMode(Smart_NTM,70,12);
    else if (hour()>=14 && hour()<15)
      ReefAngel.RF.SetMode(Smart_NTM,60,10);
    else if (hour()>=15 && hour()<16)
      ReefAngel.RF.SetMode(Smart_NTM,50,8);
    else if (hour()>=16 && hour()<17)
      ReefAngel.RF.SetMode(Constant,50,10);
    else if (hour()>=17 && hour()<18)
      ReefAngel.RF.SetMode(Constant,40,10);            
    else if (hour()>=18 && hour()<19)
      ReefAngel.RF.SetMode(Constant,30,10);                        
    else if (hour()>=19 && hour()<20)
      ReefAngel.RF.SetMode(Constant,40,10);                        
    else if (hour()>=20 && hour()<21)
      ReefAngel.RF.SetMode(Constant,30,10);                        
    else if (hour()>=21 && hour()<22)
      ReefAngel.RF.SetMode(Constant,40,10);
    else if (hour()>=22 || hour()<23)
      ReefAngel.RF.SetMode(Constant,50,10);
    else if (hour()>=23 || hour()<0)
      ReefAngel.RF.SetMode(ReefCrest,60,10);            
    else if (hour()>=0 || hour()<1)
      ReefAngel.RF.SetMode(ReefCrest,50,10);           
    else if (hour()>=1 || hour()<3)
      ReefAngel.RF.SetMode(ReefCrest,40,10);            
    else if (hour()>=3 || hour()<6)
      ReefAngel.RF.SetMode(ReefCrest,30,10);            
    else
      ReefAngel.RF.SetMode(ReefCrest,40,10);

  ////// Place your custom code below here


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

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

Re: Custom display

Posted: Fri Jul 20, 2012 12:02 am
by Appleseed
Thanks Roberto that's sorted it.

One more question on this topic if I may? Is it possible to display the speed and duration as well?

thanks
Andy

Re: Custom display

Posted: Fri Jul 20, 2012 7:30 am
by rimai
Yeah, you can use ReefAngel.RF.Speed and ReefAngel.RF.Duration in your DrawCustomMain() function.

Re: Custom display

Posted: Fri Jul 20, 2012 11:54 am
by Appleseed

Code: Select all

      vtechmode=ReefAngel.RF.Mode;
      vtechspeed=ReefAngel.RF.Speed;
      vtechpercent=ReefAngel.RF.Duration
      
      ReefAngel.LCD.DrawText(0,255,18,21,"EcoSmart Vortech");
      if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,"Constant");
      else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,31,"Lagoon");
      else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,31,"Reef Crest");
      else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,31,"Short Pulse");
      else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,31,"Long Pulse");
      else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,31,"Nutrient Trnsp.");
      else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,31,"Tidal Swell");
      else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,31,"Night");
//
ReefAngel.LCD.DrawText(0,255,18,21,"Vortech Speed");  //ignore x,y for now
//    if (vtechspeed )ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,"Some Text");

ReefAngel.LCD.DrawText(0,255,18,21,"Vortech Duration"); //ignore x,y for now
//    if (vtechpercent) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,"Some Text");
thanks for the info, but I am not sure how to do this :oops: I am guessing the code above is a start but I have no clue what to do...

Also when the mode text changes it leaves some of the previous text in the "background" I know I read somewhere that this is easy to sort out but I could not find the thread. So it would be good if you can point me in the right direction :oops: i am guessing ReefAngel.LCD.Clear is the way forward but again dummy here has no clue :cry:

Re: Custom display

Posted: Fri Jul 20, 2012 12:59 pm
by rimai
You are getting there.
Just replace "Some Text" with vtechspeed and vtechpercent :)
To erase previous draw, you can use:

Code: Select all

ReefAngel.LCD.Clear (255,35,32,60,42);
255= 8 bit color code
35 = x1
32 = y1
60 = x2
42 = y2
where x1 and y1 is the left top point of the rectangular you want to clear and x2 and y2 is the bottom right point.

Re: Custom display

Posted: Fri Jul 20, 2012 12:59 pm
by rimai

Re: Custom display

Posted: Mon Jul 23, 2012 11:49 am
by Appleseed
rimai wrote:You are getting there.
Just replace "Some Text" with vtechspeed and vtechpercent :)
Hi Roberto,

I must be missing something as I tried the following;

ReefAngel.LCD.DrawText(2,255,32,42,"Speed");
if (vtechspeed) ReefAngel.LCD.DrawLargeText(0,255,35,51,"vtechspeed");

ReefAngel.LCD.DrawText(23,255,32,62,"Duration");
if (vtechpercent) ReefAngel.LCD.DrawLargeText(0,255,35,70,"vtechpercent");

But the screen displays vtechspeed and vtechpercent instead of the actual values.

Re: Custom display

Posted: Mon Jul 23, 2012 12:47 pm
by rimai
Remove of the quote marks.
Quote marks means text.

Code: Select all

if (vtechspeed) ReefAngel.LCD.DrawLargeText(0,255,35,51,vtechspeed);

Re: Custom display

Posted: Mon Jul 23, 2012 3:35 pm
by Appleseed
I tried that but I got the following error;

Seventh_attempt.cpp: In function 'void DrawCustomMain()':
Seventh_attempt:81: error: invalid conversion from 'byte' to 'char*'
Seventh_attempt:81: error: initializing argument 5 of 'void RA_NokiaLCD::DrawLargeText(byte, byte, byte, byte, char*, byte)'
Seventh_attempt:84: error: invalid conversion from 'byte' to 'char*'
Seventh_attempt:84: error: initializing argument 5 of 'void RA_NokiaLCD::DrawLargeText(byte, byte, byte, byte, char*, byte)'

Re: Custom display

Posted: Mon Jul 23, 2012 3:58 pm
by rimai
Sorry.
I just realized that you are using DrawLargeText.
Use this then:

Code: Select all

  char text[10];

  ReefAngel.LCD.DrawText(0,255,18,21,"Vortech Speed");  //ignore x,y for now
  ConvertNumToString(text, vtechspeed, 1);
  if (vtechspeed )ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,text);

  ReefAngel.LCD.DrawText(0,255,18,21,"Vortech Duration"); //ignore x,y for now
  ConvertNumToString(text, vtechpercent, 1);
  if (vtechpercent) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,32,text);

Re: Custom display

Posted: Mon Jul 23, 2012 11:26 pm
by Appleseed
Thanks for that Roberto is working just how I wanted it :D :D :D