VortechMenu

Related to the development libraries, released by Curt Binder
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Sorry.

Code: Select all

void MenuEntry7()
{
  // TODO complete this function
  /*
 Need to have an override variable inside the loop that forces a specific mode whenever
   the menu is toggled. This should mimic the PWM override.
   */
  /*
 Cycle through the modes.
   Use the Internal Memory values OR create a switch statement that has default values
   for Speed and Duration based on the modes being switched to.
   Once at the end of the modes,
   return to constant mode (begining)
   resume normal operations
   */
   if (!fOverrideRF && vtechmode == 9)
   {
     vtechmode=0;
     ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
   }
   else
   {
     vtechmode++;
   }
     
  fOverrideRF = true;
  if ( vtechmode == 7 ) vtechmode = 9;
  if ( vtechmode > 9 ) { 
    vtechmode = 0; 
    fOverrideRF = false; 
  }
  
  // 1st parameter is Mode, 2nd is speed, 3rd is duration
  ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

So I have tried this one

Still doesnt change the modes.
Any other Ideas?

The closest one was Binders suggestion, as it changed for a split second.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Does it change on screen and not on the module, or it doesn't even change on screen?
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

It does not change on screen , or on module.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Can you post your latest entire code?
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

HI Roberto

Here is my current config - a few items are // out, as I am waiting for rufessor to complete the comms between the PWM module, and the RA

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 <ReefAngel.h>
#include <avr/pgmspace.h>>
//***************************************************************************************************************************************************************************
//-------------------------------------------------------------------------- Screen set-up ---------------------------------------------------------------------------------
#define NumScreens 6
int ScreenID=0;
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------- Start of Global Variables ---------------------------------------------------------------------------
bool fOverrideRF = false;
byte vtechmode = 0;
boolean bFeeding=false;
byte x,y;
byte TempRelay =15;
byte TempRelay2=15;
//***************************************************************************************************************************************************************************
//----------------------------------------------------------------------- Custom Menu Code ----------------------------------------------------------------------------------
prog_char menu1_label[] PROGMEM = "Food!!";
prog_char menu2_label[] PROGMEM = "Cleanup";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Storm";
prog_char menu5_label[] PROGMEM = "pH Cal";
prog_char menu6_label[] PROGMEM = "Salinity Cal";
prog_char menu7_label[] PROGMEM = "Vortech Mode";
prog_char menu8_label[] PROGMEM = "Sump On";
prog_char menu9_label[] PROGMEM = "Sump Off";

void MenuEntry1()
{
   ReefAngel.DisplayMenuEntry("Food!!");
   ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
   ReefAngel.DisplayMenuEntry("Cleanup");
   ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
    ReefAngel.DisplayMenuEntry("ATO Clear"); 
    ReefAngel.ATOClear();
}
void MenuEntry4()
{
    ReefAngel.DisplayMenuEntry("Storm");
    ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
void MenuEntry5()
{
    ReefAngel.DisplayMenuEntry("pH Cal");
    ReefAngel.SetupCalibratePH();
    ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
    ReefAngel.DisplayMenuEntry("Salinity Cal");
    ReefAngel.SetupCalibrateSalinity();
    ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
  // TODO complete this function
  /*
 Need to have an override variable inside the loop that forces a specific mode whenever
   the menu is toggled. This should mimic the PWM override.
   */
  /*
 Cycle through the modes.
   Use the Internal Memory values OR create a switch statement that has default values
   for Speed and Duration based on the modes being switched to.
   Once at the end of the modes,
   return to constant mode (begining)
   resume normal operations
   */
   if (!fOverrideRF && vtechmode == 9)
   {
     vtechmode=0;
     ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
   }
   else
   {
     vtechmode++;
   }
     
  fOverrideRF = true;
  if ( vtechmode == 7 ) vtechmode = 9;
  if ( vtechmode > 9 ) { 
    vtechmode = 0; 
    fOverrideRF = false; 
  }
  
  // 1st parameter is Mode, 2nd is speed, 3rd is duration
  ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}


void MenuEntry8()
{
    ReefAngel.DisplayMenuEntry("Sump On");
    ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
    #ifdef RelayExp
    for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ ) 
     {
       ReefAngel.Relay.RelayMaskOnE[i] = ReefAngel.LightsOnPortsE[i];
     }
    #endif  // RelayExp
    ReefAngel.Relay.Write();
}

void MenuEntry9()
{
    ReefAngel.DisplayMenuEntry("Sump Off");
    ReefAngel.Relay.RelayMaskOn = 0;
    #ifdef RelayExp
    for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
     {
      ReefAngel.Relay.RelayMaskOnE[i] = 0;
     }
    #endif  // RelayExp
    ReefAngel.Relay.Write();
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------- Grouped Menu Entries ----------------------------------------------------------------------------
PROGMEM const char *menu_items[] =
{
    menu1_label, menu2_label, menu3_label,
    menu4_label, menu5_label, menu6_label,
    menu7_label,menu8_label,menu9_label
};
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------- Custom Main -------------------------------------------------------------------------------
void DrawCircleOutline(byte x, byte y, byte radius, byte bordercolor);
void FillCircle(byte x, byte y, byte radius, byte fillcolor);
void DrawCircleOutletBox(byte x, byte y, byte RelayData, bool reverse = false);
//***************************************************************************************************************************************************************************
//-------------------------------------------------------------------------- Analog Clock constants -------------------------------------------------------------------------
const float pi = 3.141592653;
byte clock_center_x = 65;
byte clock_center_y = 65;
byte clock_radius = 55;
byte secondhand_radius = 33;
float secondangle;
byte secondend_x;
byte secondend_y;
float minuteangle;
float hourangle;
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------- Analog Clock Structure ------------------------------------------------------------------------
int minutebase_radius = 3;
int minutehand_radius = 33;
int hourbase_radius = 3;
int hourhand_radius = 25;
int seconds_hand_x, seconds_hand_y, minutes_hand_x, minutes_hand_y, hours_hand_x, hours_hand_y;
int hours_hand_base_x, hours_hand_base_y, hours_hand_base_x1, hours_hand_base_y1;
int minutes_hand_base_x, minutes_hand_base_y, minutes_hand_base_x1, minutes_hand_base_y1;
int minutebase_x, minutebase_y, minutebase_x1, minutebase_y1;
int minuteend_x, minuteend_y;
int hourbase_x, hourbase_y, hourbase_x1, hourbase_y1;
int hourend_x, hourend_y;
float minfloat;
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------------Time Stamp --------------------------------------------------------------------------------
time_t tsmax=now();
time_t tsmin=now();
time_t PHmax=now();
time_t PHmin=now();
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Minutes Hand --------------------------------------------------------------------------
void draw_minute(int color)
{
    Drawline(minutebase_x, minutebase_y, minutebase_x1, minutebase_y1, color);
    Drawline(minutebase_x, minutebase_y, minuteend_x, minuteend_y, color);
    Drawline(minutebase_x1, minutebase_y1, minuteend_x, minuteend_y, color);
}
//***************************************************************************************************************************************************************************
//--------------------------------------------------------------------------- Draw Hour Hand --------------------------------------------------------------------------------
void draw_hour(int color)
{
    Drawline(hourbase_x, hourbase_y, hourbase_x1, hourbase_y1, color);
    Drawline(hourbase_x, hourbase_y, hourend_x, hourend_y, color);
    Drawline(hourbase_x1, hourbase_y1, hourend_x, hourend_y, color);
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Line ----------------------------------------------------------------------------------
void Drawline (int x0, int y0, int x1, int y1, int color)
{
    int dy = y1 - y0;
    int dx = x1 - x0;
    int stepx, stepy;
    if (dy < 0)
    {
        dy = -dy;
        stepy = -1;
    }
    else
    {
        stepy = 1;
    }
    if (dx < 0)
    {
        dx = -dx;
        stepx = -1;
    }
    else
    {
        stepx = 1;
    }
    dy <<= 1; // dy is now 2*dy
    dx <<= 1; // dx is now 2*dx
    ReefAngel.LCD.PutPixel(color, x0, y0);
    if (dx > dy)
    {
        int fraction = dy - (dx >> 1); // same as 2*dy - dx
        while (x0 != x1)
        {
            if (fraction >= 0)
            {
                y0 += stepy;
                fraction -= dx; // same as fraction -= 2*dx
            }
            x0 += stepx;
            fraction += dy; // same as fraction -= 2*dy
            ReefAngel.LCD.PutPixel(color, x0, y0);
        }
    }
    else
    {
        int fraction = dx - (dy >> 1);
        while (y0 != y1)
        {
            if (fraction >= 0)
            {
                x0 += stepx;
                fraction -= dy;
            }
            y0 += stepy;
            fraction += dx;
            ReefAngel.LCD.PutPixel(color, x0, y0);
        }
    }
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Time ----------------------------------------------------------------------------------
void DrawTime(byte x, byte y, byte FGcolor, byte BGcolor, time_t ts)
{
    char text[13];
    char temp[]="  ";
    strcpy(text,"");
    itoa(hourFormat12(ts),temp,10);
    if (temp[1]==0) strcat(text,"0");
    strcat(text,temp);
    strcat(text,":");
    itoa(minute(ts),temp,10);
    if (temp[1]==0) strcat(text,"0");
    strcat(text,temp);
    strcat(text,":");
    itoa(second(ts),temp,10);
    if (temp[1]==0) strcat(text,"0");
    strcat(text,temp);
    if (isAM(ts))
    {
        strcat(text," AM");
    }
    else
    {
        strcat(text," PM");
    }
    ReefAngel.LCD.DrawText(FGcolor, BGcolor, x, y, text);
}
//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Draw Circle --------------------------------------------------------------------------------
void DrawCircle(int a, int b, int r, byte color)
{
    int f = 1 - r;
    int ddF_x = 1;
    int ddF_y = -2 * r;
    int x = 0;
    int y = r;

    ReefAngel.LCD.PutPixel(color, a, b+r);
    ReefAngel.LCD.PutPixel(color ,a, b-r);
    ReefAngel.LCD.PutPixel(color, a+r, b);
    ReefAngel.LCD.PutPixel(color, a-r, b);
    while (x<y)
    {
        if (f >= 0)
        {
            y--;
            ddF_y += 2;
            f += ddF_y;
        }
        x++;
        ddF_x += 2;
        f += ddF_x;

        ReefAngel.LCD.PutPixel(color, a + x, b + y);
        ReefAngel.LCD.PutPixel(color, a - x, b + y);
        ReefAngel.LCD.PutPixel(color, a + x, b - y);
        ReefAngel.LCD.PutPixel(color, a - x, b - y);
        ReefAngel.LCD.PutPixel(color, a + y, b + x);
        ReefAngel.LCD.PutPixel(color, a - y, b + x);
        ReefAngel.LCD.PutPixel(color, a + y, b - x);
        ReefAngel.LCD.PutPixel(color, a - y, b - x);
    }
}
//***************************************************************************************************************************************************************************

void DrawCustomMain()
{
    // Refresh is called at start of ShowInterface.
    // ShowInterface calls DrawCustomMain
    switch (ScreenID)
    {
//---------------------------------------------------------------------------- Screen Code 1--------------------------------------------------------------------------------
        case 0:
            //Top Banner
            ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank   ", Font8x8); //Top Banner
            // Display T1 Header Text
            ReefAngel.LCD.DrawLargeText(COLOR_STEELBLUE,255,5,15,"Sump Temp", Font8x8);
            // Display the T1 Temp Value
            char text[7];
            ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
            ReefAngel.LCD.Clear(255, 10, 25, 50, 60);
            if (ReefAngel.Params.Temp[T1_PROBE]>290) ReefAngel.LCD.DrawHugeNumbers(COLOR_RED, 255, 10, 25, text);
            else if (ReefAngel.Params.Temp[T1_PROBE]>270) ReefAngel.LCD.DrawHugeNumbers(COLOR_ORANGE, 255, 10, 25, text);
            else ReefAngel.LCD.DrawHugeNumbers(COLOR_MIDNIGHTBLUE, 255, 10, 25, text);
            // Display the T2 Header Text
            ReefAngel.LCD.DrawLargeText(0,255,5,45,"Room Temp", Font8x8);
            // Display the T2 Temp Value
            ReefAngel.LCD.Clear(255, 90, 50, 132, 60);
            ConvertNumToString(text, ReefAngel.Params.Temp[T2_PROBE], 10);
            ReefAngel.LCD.DrawLargeText(COLOR_MIDNIGHTBLUE, 255, 90, 45, text, Num8x8);
            // Display pH Header Text
            ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,95,15,"pH", Font8x8);
            // Display pH Value
            ConvertNumToString(text, ReefAngel.Params.PH, 100);
            ReefAngel.LCD.Clear(0, 65, 62 , 65, 62);
            if (ReefAngel.Params.PH>840 || ReefAngel.Params.PH<790) ReefAngel.LCD.DrawLargeText(COLOR_RED, 255, 85, 25, text, Num8x8);
            else if (ReefAngel.Params.PH>830 || ReefAngel.Params.PH<800) ReefAngel.LCD.DrawLargeText(COLOR_ORANGE, 255, 85, 25, text, Num8x8);
            else ReefAngel.LCD.DrawLargeText(COLOR_MIDNIGHTBLUE, 255, 85, 25, text, Num8x8);
            
//****************************************************************************************************************************************************************************
//------------------------------------------------------------------ Display Vortech Mode ------------------------------------------------------------------------------------

            ReefAngel.LCD.DrawLargeText(0,255,5,55,"Vortech", Font8x8); 
            
//****************************************************************************************************************************************************************************            
//---------------------------------------------------------------- Display EcoSmart Mode Value -------------------------------------------------------------------------------

            ReefAngel.LCD.Clear(255, 66, 60, 132, 70);
            if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255, 66, 55,"Constant");
            else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255, 66, 55,"Lagoon");
            else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255, 80, 55,"RCM");
            else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255, 80, 55,"Short");
            else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255, 66, 55,"Long");
            else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255, 80, 55,"NTM");
            else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255, 80, 55,"TSM");
            else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_GRAY,255, 80, 55,"Night");
            
//****************************************************************************************************************************************************************************            
//------------------------------------------------------------------- Display Salinity ---------------------------------------------------------------------------------------

            ReefAngel.LCD.DrawLargeText(0,255,64,114,"Salinity", Font8x8);
            
//****************************************************************************************************************************************************************************
//----------------------------------------------------------------- Display Salinity Value -----------------------------------------------------------------------------------

            ReefAngel.LCD.Clear(255, 82, 85, 65, 95);
            ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
            ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 85, 122, text, Num8x8);
            
//*****************************************************************************************************************************************************************************
//-----------------------------------------------------------Start Moon Phase,Cloud or Storm Display---------------------------------------------------------------------------
/* if (ReefAngel.PWM.Channel[5] > 0);
  {
    ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,70,105,MoonPhaseLabel());

  }
           if (ReefAngel.PWM.ExpansionChannel[0] > 0 && (hour() < 14 ) )
            {
               ReefAngel.LCD.DrawLargeText(COLOR_ORANGERED,255,3,65, "Sunrise",Font8x8);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,3,75, ReefAngel.PWM.ExpansionChannel[0]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,20,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,24,75, ReefAngel.PWM.ExpansionChannel[1]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,41,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,45,75, ReefAngel.PWM.ExpansionChannel[2]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,66,75, "|");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,70,75, ReefAngel.PWM.ExpansionChannel[3]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,87,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,91,75, ReefAngel.PWM.ExpansionChannel[4]);
            }
           else if (ReefAngel.PWM.ExpansionChannel[0] > 0 && (hour() > 14 ))
            {
               ReefAngel.LCD.DrawLargeText(COLOR_ORANGERED,255,3,65, "Sunrise",Font8x8);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,3,75, ReefAngel.PWM.ExpansionChannel[0]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,20,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,24,75, ReefAngel.PWM.ExpansionChannel[1]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,41,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,45,75, ReefAngel.PWM.ExpansionChannel[2]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,66,75, "|");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,70,75, ReefAngel.PWM.ExpansionChannel[3]);
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,87,74, ":");
               ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,91,75, ReefAngel.PWM.ExpansionChannel[4]);
            }
  */         
//*****************************************************************************************************************************************************************************
//---------------------------------------------------------- Display Main and Expansion Relay Box -----------------------------------------------------------------------------

            TempRelay = ReefAngel.Relay.RelayData;
            TempRelay &= ReefAngel.Relay.RelayMaskOff;
            TempRelay |= ReefAngel.Relay.RelayMaskOn;
            ReefAngel.LCD.DrawCircleOutletBox(10,90, TempRelay);
            pingSerial();

            TempRelay2 = ReefAngel.Relay.RelayDataE[0];
            TempRelay2 &= ReefAngel.Relay.RelayMaskOffE[0];
            TempRelay2 |= ReefAngel.Relay.RelayMaskOnE[0];
            ReefAngel.LCD.DrawCircleOutletBox(40,90, TempRelay2);
            pingSerial();
            break;
            
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 2---------------------------------------------------------------------------------

        case 1:  //PWM Module Info
  ReefAngel.LCD.Clear(BtnActiveColor,5,0,127,11);
  ReefAngel.LCD.DrawText(DefaultBGColor,BtnActiveColor,30,3,"My Reef Angel");
  ReefAngel.LCD.DrawDate(6, 122);
  pingSerial();
//ReefAngel.LCD.DrawMonitor(15, 20, ReefAngel.Params,
//ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
  pingSerial();
  ReefAngel.LCD.Clear(DefaultFGColor,5,52,127,52);
  ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,30,55,"PWM Expansion");
  x=15;
  y=68;
  for (int a=0;a<6;a++)
  {
    if (a>2) x=75;
    if (a==3) y=68;
    ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :");
    ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a);
  //ConvertNumToString(text, ReefAngel.PWM.GetChannelValue(a), 1);
    strcat(text,"  ");
    ReefAngel.LCD.DrawText(COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,text);
    y+=10;
  }
  break;

//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 3---------------------------------------------------------------------------------
        case 2:  //relay box key
            ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
            TempRelay = ReefAngel.Relay.RelayData;
            TempRelay &= ReefAngel.Relay.RelayMaskOff;
            TempRelay |= ReefAngel.Relay.RelayMaskOn;
            ReefAngel.LCD.DrawCircleOutletBox(56,46,TempRelay);
            pingSerial();
            ReefAngel.LCD.DrawLargeText(0,255,27,20,"RelayBox 1", Font8x8);
            ReefAngel.LCD.DrawLargeText(0,255,3,44,"LDFan", Font8x8); //1
            ReefAngel.LCD.DrawLargeText(0,255,7,54,"N/A", Font8x8); //3
            ReefAngel.LCD.DrawLargeText(0,255,7,64,"ATU", Font8x8); //5
            ReefAngel.LCD.DrawLargeText(0,255,7,74,"Salty", Font8x8); //7
            ReefAngel.LCD.DrawLargeText(0,255,75,44,"Skimer", Font8x8);  //2
            ReefAngel.LCD.DrawLargeText(0,255,75,54,"Reactr", Font8x8);  //4
            ReefAngel.LCD.DrawLargeText(0,255,75,64,"Heatr", Font8x8); //6
            ReefAngel.LCD.DrawLargeText(0,255,75,74,"Relay", Font8x8);  //8
            break;
            
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 4---------------------------------------------------------------------------------
        case 3:  //relay box key
            ReefAngel.Refresh();
            ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
            TempRelay2 = ReefAngel.Relay.RelayDataE[0];
            TempRelay2 &= ReefAngel.Relay.RelayMaskOffE[0];
            TempRelay2 |= ReefAngel.Relay.RelayMaskOnE[0];
            ReefAngel.LCD.DrawCircleOutletBox(56,46,TempRelay2);
            pingSerial();
            ReefAngel.LCD.DrawLargeText(0,255,27,20,"RelayBox 2", Font8x8);
            ReefAngel.LCD.DrawLargeText(0,255,7,44,"VTech", Font8x8);//1
            ReefAngel.LCD.DrawLargeText(0,255,3,54,"Return", Font8x8);//3
            ReefAngel.LCD.DrawLargeText(0,255,7,64,"N/A", Font8x8);//5
            ReefAngel.LCD.DrawLargeText(0,255,7,74,"PWM", Font8x8);//7
            ReefAngel.LCD.DrawLargeText(0,255,75,44,"VTech", Font8x8);//2
            ReefAngel.LCD.DrawLargeText(0,255,75,54,"SumpL", Font8x8);//4
            ReefAngel.LCD.DrawLargeText(0,255,75,64,"Heatr", Font8x8);//6
            ReefAngel.LCD.DrawLargeText(0,255,75,74,"LED", Font8x8);//8
            break;
            
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 5---------------------------------------------------------------------------------

        case 4:  //setclock
            // Analog clock is modified from the original source by Jeff Miller
            // Author: Jeff Miller   http://arduinofun.blogspot.com/
            ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
            // Frame
            DrawCircle(clock_center_x, clock_center_y, clock_radius, COLOR_CORNFLOWERBLUE);
            DrawCircle(clock_center_x, clock_center_y, clock_radius - 1, COLOR_CORNFLOWERBLUE);
            DrawCircle(clock_center_x, clock_center_y, clock_radius - 2, COLOR_CORNFLOWERBLUE);
            // Face Tick Marks  (x = r cos theta, y = r sin theta)
            for (byte r=0; r < 12; r++)
            {
                float angle = (2 * pi / 12)*r;
                int tick_x_out = (clock_radius - 8) * cos (angle) + clock_center_x;
                int tick_y_out = (clock_radius - 8) * sin (angle) + clock_center_y;
                int tick_x_in = clock_radius *.72 * cos (angle) + clock_center_x;
                int tick_y_in = clock_radius * .72 * sin (angle) + clock_center_y;
                Drawline(tick_x_in, tick_y_in, tick_x_out, tick_y_out, COLOR_CORNFLOWERBLUE);
            }
            // Face Characters
            ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 8,106," 6", Font8x8);
            ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 8, 25,"12", Font8x8);
            ReefAngel.LCD.DrawLargeText(0,255,clock_center_x + 34,clock_center_y," 3", Font8x8);
            ReefAngel.LCD.DrawLargeText(0,255,clock_center_x - 50, clock_center_y - 4,"9 ", Font8x8);
            // Draw Seconds Hand
            secondangle = (2 * pi / 60) * second();
            if (second() > 15)
            {
                secondangle = secondangle -1.57;
            }
            else
            {
                secondangle = secondangle +4.71;
            }
            Drawline(clock_center_x, clock_center_y, secondend_x, secondend_y, WHITE);
            secondend_x = secondhand_radius * cos (secondangle) + clock_center_x;
            secondend_y = secondhand_radius * sin (secondangle) + clock_center_y;
            Drawline(clock_center_x, clock_center_y, secondend_x, secondend_y, BLACK);
// Redraw minutes hand since the section closest to the center gets erased by the seconds hand
            draw_minute(BLACK);
// Redraw hour hand
            draw_hour(BLACK);
// Draw Minutes Hand
            minuteangle = (2 * pi / 60) * minute();
            if (minute() > 15)
            {
                minuteangle = minuteangle -1.57;
            }
            else
            {
                minuteangle = minuteangle +4.71;
            }
            // Erase old minutes Hand
            draw_minute(WHITE);
            // Calculate Minute Hand Base
            minutebase_x = minutebase_radius * cos (minuteangle - pi/2) + clock_center_x;
            minutebase_y = minutebase_radius * sin (minuteangle - pi/2) + clock_center_y;
            minutebase_x1 = minutebase_radius * cos (minuteangle + pi/2) + clock_center_x;
            minutebase_y1 = minutebase_radius * sin (minuteangle + pi/2) + clock_center_y;
// Calculate Minute Hand Point
            minuteend_x = minutehand_radius * cos (minuteangle) + clock_center_x;
            minuteend_y = minutehand_radius * sin (minuteangle) + clock_center_y;
// Draw new minutes Hand
            draw_minute(BLACK);
// Redraw hour hand
            draw_hour(BLACK);
// Draw Hour Hand
            minfloat = minute(); // Convert minute short to float
            hourangle = (2 * pi / 12) * ((hourFormat12()) + (minfloat/60)); // Find angle for hour hand
            hourangle = hourangle -1.57;
// Erase old Hour Hand
            draw_hour(WHITE);
// Calculate hour Hand Base
            hourbase_x = hourbase_radius * cos (hourangle - pi/2) + clock_center_x;
            hourbase_y = hourbase_radius * sin (hourangle - pi/2) + clock_center_y;
            hourbase_x1 = hourbase_radius * cos (hourangle + pi/2) + clock_center_x;
            hourbase_y1 = hourbase_radius * sin (hourangle + pi/2) + clock_center_y;
// Calculate hour Hand Point
            hourend_x = hourhand_radius * cos (hourangle) + clock_center_x;
            hourend_y = hourhand_radius * sin (hourangle) + clock_center_y;
// Draw new hours Hand
            draw_hour(BLACK);
            ReefAngel.LCD.DrawDate(5,121);
            break;
            
//***************************************************************************************************************************************************************************
//---------------------------------------------------------------------------- Screen Code 6---------------------------------------------------------------------------------

        case 5: // Vortech Setup
            ReefAngel.LCD.DrawLargeText(COLOR_WHITE, COLOR_CORNFLOWERBLUE, 0, 1, " Drop Reef Tank ", Font8x8); //Top Banner
            ReefAngel.LCD.DrawText(0,255,20,50,"Assigning Slaves");
            ReefAngel.RF.SetMode(Slave_Start,0,0);
            if (ReefAngel.Joystick.IsButtonPressed())
            {
                ReefAngel.RF.SetMode(Slave_Stop,0,0);
                ReefAngel.LCD.DrawText(0,255,50,60,"Done");
            }
            break;

    }
}

void DrawCustomGraph()
{}

//***************************************************************************************************************************************************************************
//------------------------------------------------------------------------------ Begin Setup --------------------------------------------------------------------------------
void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Timer[LCD_TIMER].SetInterval(180);
    ReefAngel.Timer[LCD_TIMER].Start();  // start timer
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
    ReefAngel.SetTemperatureUnit(1);
    ReefAngel.FeedingModePorts = 0;
    ReefAngel.WaterChangePorts = Port2Bit | Port4Bit | Port5Bit | Port6Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    ReefAngel.OverheatShutoffPorts = Port6Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port6Bit;
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port4Bit;
//------------------------------------------------------------------------- Ports that are always on ------------------------------------------------------------------------
  ReefAngel.Relay.On(Port1);
  ReefAngel.Relay.On(Port4);
  ReefAngel.Relay.On(Port7);
  ReefAngel.Relay.On(Port8);
  ReefAngel.Relay.On(Box1_Port1);
  ReefAngel.Relay.On(Box1_Port2);
  ReefAngel.Relay.On(Box1_Port3);
  ReefAngel.Relay.On(Box1_Port7);
  ReefAngel.Relay.On(Box1_Port8);
}
//***************************************************************************************************************************************************************************
void loop()
{
//--------------------------------------------------------------------------- Specific Functions ----------------------------------------------------------------------------
    ReefAngel.Relay.DelayedOn(Port2, 2);
    ReefAngel.Relay.DelayedOn(Box1_Port1, 2);
    ReefAngel.Relay.DelayedOn(Box1_Port2, 2);
    ReefAngel.StandardATO( Port5,80 );
    ReefAngel.StandardHeater( Port6,247,255 );
    ReefAngel.StandardHeater( Box1_Port6,247,255 );
    ReefAngel.MoonLights(Box1_Port4);//SumpLight
    ReefAngel.Portal("JNieuwenhuizen");
//------------------------------------------------------------------------------ Multiple Screens ----------------------------------------------------------------------------

    if (ReefAngel.Joystick.IsLeft())
    {
        ReefAngel.ClearScreen(DefaultBGColor);
        ScreenID--;
    }
    if (ReefAngel.Joystick.IsRight())
    {
        ReefAngel.ClearScreen(DefaultBGColor);
        ScreenID++;
    }
    if (ScreenID<0) ScreenID=NumScreens;
    if (ScreenID>=NumScreens) ScreenID=0;

//***************************************************************************************************************************************************************************
//------------------------------------------------------------------ Start Time-of-Day Based Functions ----------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These are the mode numbers for the RF Expansion Module for reference ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //#define Constant      0
    //#define Random1       1 // Lagoonal
    //#define Random2       2 // Reef Crest
    //#define ShortWave     3
    //#define LongWave      4
    //#define Smart_NTM     5 // Nutrient Transport Mode
    //#define Smart_TSM     6 // Tidal Swell Mode
    //#define Feeding_Start 7
    //#define Feeding_Stop  8
    //#define Night         9
    //#define Slave_Start   97
    //#define Slave_Stop    98
    //#define None          99
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//----------------------------------------------------------------- Start RF Daytime Control ------------------------------------------------------------------------------
        if (hour() >8 && hour() < 14)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
        }
       else if (hour() >14 && hour() < 22)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Random2,60,7);
            vtechmode = Random2;
        }

//--------------------------------------------------------------- Start RF Nightmode Control -----------------------------------------------------------------------------
       else if (hour()>=22 || hour()<8) // Defining "Nightmode" hours for VorTech = between 10 PM and 8 AM
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,10,0);
            vtechmode = Night;
        }
        else
        {
            ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
            ReefAngel.RF.SetMode(vtechmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
        } 

    ReefAngel.ShowInterface();
}

//***************************************************************************************************************************************************************************

rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Sorry man...
Got busy and forgot to look at it.
I found out why :)
You forgot to check for fOverrideRF in your schedule.
use this:

Code: Select all

    if (!fOverrideRF)
    {
        if (hour() >8 && hour() < 14)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
        }
       else if (hour() >14 && hour() < 22)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Random2,60,7);
            vtechmode = Random2;
        }

//--------------------------------------------------------------- Start RF Nightmode Control -----------------------------------------------------------------------------
       else if (hour()>=22 || hour()<8) // Defining "Nightmode" hours for VorTech = between 10 PM and 8 AM
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,10,0);
            vtechmode = Night;
        }
        else
        {
            ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
            ReefAngel.RF.SetMode(vtechmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
        } 
    }
Also, just a minor bug too on the screen checking...
You will go out of bound if you use ScreenID=NumScreens.

Code: Select all

    if (ScreenID<0) ScreenID=NumScreens-1;
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

Thank you Roberto.

We are getting somewhere

It changes modes on the screen now, not on the RF module
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Try this one:

Code: Select all

    if (!fOverrideRF)
    {
        if (hour() >8 && hour() < 14)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
        }
       else if (hour() >14 && hour() < 22)
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Random2,60,7);
            vtechmode = Random2;
        }

//--------------------------------------------------------------- Start RF Nightmode Control -----------------------------------------------------------------------------
       else if (hour()>=22 || hour()<8) // Defining "Nightmode" hours for VorTech = between 10 PM and 8 AM
        {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,10,0);
            vtechmode = Night;
        }
        else
        {
            ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Smart_NTM,80,7);
            vtechmode = Smart_NTM;
            ReefAngel.RF.SetMode(vtechmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
        } 
    }
    else
    {
          ReefAngel.RF.UseMemory=false;
          ReefAngel.RF.SetMode(vtechmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
    }
Roberto.
Post Reply