VortechMenu

Related to the development libraries, released by Curt Binder
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

VortechMenu

Post by JNieuwenhuizen »

Hi.

How would I ceate a custom Vortech Menu?

I want to be able to go to my menu's and select what mode the Vortechs are in.

Have this already :

Code: Select all

// Custom Menu Code
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Salinity Calibration";
prog_char menu7_label[] PROGMEM = "Vortech Setup";
prog_char menu8_label[] PROGMEM = "Date / Time";
prog_char menu9_label[] PROGMEM = "Version";
// Group the menu entries together
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label,
menu4_label, menu5_label, menu6_label,
menu7_label,menu8_label,menu9_label
};

Code: Select all

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
  ReefAngel.SetupCalibrateSalinity();
  ReefAngel.DisplayMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
  ????? - Vortech Modes Menu
}
void MenuEntry8()
{
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.DisplayVersion();
}
Any ideas ??
Last edited by JNieuwenhuizen on Thu Mar 29, 2012 5:38 pm, edited 1 time in total.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

Anyone that can help with this one? binder is looking at at, I think the more inut we have the better.

This is a menu with a submenu.. so it gets tricky.

When you go to >> Menu , you will have VortechMode. Under VortechMode , the different modes.

So >>Menu
1.Feed >> Feed code
2.Water Change >> Waterchange code
3.ATO Clear >> Clear ATO code
4.Overheat Clear >> Clear overheat code
5.pH Calibrate >> Calibration code
6.Salinity Calibrate >> Calibration code
7.Vortech Mode >> Submenus code ???
Tidel Swell >> RF Module code ???
Nutrient Transport >> RF Module code ???
Reef Crest >> RF Module code ???
Lagoon >> RF Module Code ???
Short Wave >> RF Module Code ???
Long Wave >> RF Module Code ???
Feed Mode >> RF Module Code ???
NightMode >> RF Module Code ???
8.Date / Time
9.Version

rimai - any ideas?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

It's much easier to do that with smart phone, but if you want something like this on the controler, you could do something like another user has done for his LED lights.
You could make it so the mode increments everytime you visit that menu option and then cycle back to first when it reaches the last mode.
Or maybe having another custom screen just for picking modes? Just like jsclownfish did for his alternate custom screens: http://forum.reefangel.com/viewtopic.php?f=11&t=923
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

rimai wrote:It's much easier to do that with smart phone, but if you want something like this on the controler, you could do something like another user has done for his LED lights.
You could make it so the mode increments everytime you visit that menu option and then cycle back to first when it reaches the last mode.
That could work. Do you perhaps have a link to that users code?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

Feeding Mode is automatically set when you place the controller in feeding mode. So that mode isn't really needed.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

Here's something that cycles through the modes from 1 through 9. The cycle is as follows:

Lagoon -> Reef Crest -> Short Wave -> Long Wave -> Nutrient -> Tidal Swell -> Night Mode

Code: Select all

// this goes above the menu entries
byte vtmode = 0;

void MenuEntry7()
{
	vtmode++;
	if ( vtmode == 7 ) vtmode = 9;
	if ( vtmode > 9 ) vtmode = 1;
	// 1st parameter is Mode, 2nd is speed, 3rd is duration
	ReefAngel.RF.SetMode(vtmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
	ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;	
}
The only problem with the vortech modes and having a menu entry on the controller for them is they have a Pump Speed and a Duration variable. Right now, I have it set to use the Speed and Duration from the internal memory settings.
It could easily be changed to use a specific Speed and Duration for each one of the modes. Since I don't have one of these modules, nor have I used them before, I do not know what the ideal settings would or should be. I'm just coding a generic function that should handle a majority of the cases.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

Thank You binder.

How do I set the speed and Duration for each mode? I guess that will be in the memory file? So do I have to define each mode and set the Speed And Duration?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

If you know what speed and duration you want for each mode, that's really easy to solve. It can be hard coded into the function (unable to change unless you reload the code) OR we could pick some new memory locations for the different modes and then you could change them via wifi commands. It's completely up to you and would be pretty simple either way.

Side note. The memory file is simply a file that sets the values in the internal memory. Once it is loaded, it is not needed to be loaded again. You can add / update the values in the locations via the web interface (it has to be manually done though) or you can use the Java Status app or the Android Status app.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

I use my android phone from anywhere to change mode, speed and duration :)
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

rimai wrote:It's much easier to do that with smart phone, but if you want something like this on the controler, you could do something like another user has done for his LED lights.
You could make it so the mode increments everytime you visit that menu option and then cycle back to first when it reaches the last mode.
Or maybe having another custom screen just for picking modes? Just like jsclownfish did for his alternate custom screens: http://forum.reefangel.com/viewtopic.php?f=11&t=923

Thank You.
Last edited by JNieuwenhuizen on Thu Apr 12, 2012 11:53 am, edited 1 time in total.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

binder wrote:Here's something that cycles through the modes from 1 through 9. The cycle is as follows:

Lagoon -> Reef Crest -> Short Wave -> Long Wave -> Nutrient -> Tidal Swell -> Night Mode

Code: Select all

// this goes above the menu entries
byte vtmode = 0;

void MenuEntry7()
{
	vtmode++;
	if ( vtmode == 7 ) vtmode = 9;
	if ( vtmode > 9 ) vtmode = 1;
	// 1st parameter is Mode, 2nd is speed, 3rd is duration
	ReefAngel.RF.SetMode(vtmode, InternalMemory.RFSpeed_read(), InternalMemory.RFDuration_read());
	ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;	
}
The only problem with the vortech modes and having a menu entry on the controller for them is they have a Pump Speed and a Duration variable. Right now, I have it set to use the Speed and Duration from the internal memory settings.
It could easily be changed to use a specific Speed and Duration for each one of the modes. Since I don't have one of these modules, nor have I used them before, I do not know what the ideal settings would or should be. I'm just coding a generic function that should handle a majority of the cases.
Hi Binder.

I have tried the code and it does not cycle the modes. It stays on the internal memory mode.

Also, I see Roberto mentioned in his initial thread when the RF was released, that modes 10 and 11 are there, can I change the 9 in the code to 11?
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

If it stays on the Internal Memory mode, what does the rest of your INO file look like? Do you have something that sets it elsewhere? I'm just curious because nothing in the code I posted would use the Internal Memory for the modes.
Does the mode get set properly when you enter Feeding mode?
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

Hi binder.

My code has a few places it sets internal memory values. The complete code is here - I can always set my internal memory to no values?? i dont know if that would work. If I go to feeding mode, it does set the pumps to feeding mode.
http://forum.reefangel.com/viewtopic.ph ... 8654#p8654
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

Hi binder.

Did you see the reply I posted?

- Jean
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

JNieuwenhuizen wrote:Hi binder.

Did you see the reply I posted?

- Jean
I briefly looked at it for a second but have not really looked at it yet. Will try to do so today.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

See my comment on the other thread:
http://forum.reefangel.com/viewtopic.ph ... 8722#p8722
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

Re: VortechMenu

Post by Poiromaniax »

Hey all,

Im also looking into doing this,

Is there a way of changing the modes via web interface? or even the iphone app?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

I do it with my android.
Which smart phone do you have?

Sent from my SPH-D700 using Tapatalk 2
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Sorry, I just reread your post and saw you have iPhone.
It seems there is a bug on the iPhone app that causes it to crash if you try to change the mode with it.
http://forum.reefangel.com/viewtopic.php?p=8822#p8822
Roberto.
Poiromaniax
Posts: 180
Joined: Thu Apr 05, 2012 6:20 am
Location: JHB, South Africa

VortechMenu

Post by Poiromaniax »

Cool,

Any other way to change modes? Considering my vortech will now become the slave
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: VortechMenu

Post by binder »

Poiromaniax wrote:Cool,

Any other way to change modes? Considering my vortech will now become the slave
You can manually change the modes via the web interface. This is the same way that the iPhone and Android apps work.

Code: Select all

// RF Mode
http://YOURIPADDRESS:2000/mb855,X

// RF Speed
http://YOURIPADDRESS:2000/mb856,X

// RF Duration
http://YOURIPADDRESS:2000/mb857,X
You simply use your IP address and port. Then, you would use the value you want in place of X. This is just like what was mentioned earlier.

Or you can use the java status app to change the memory locations:
http://forum.reefangel.com/viewtopic.php?f=8&t=246
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

So I have tested the code with the changes suggested, It still only changes the mode for a second and then returns to normal operation.

Any chance we could re-visit this to see if we can get it going? :)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Try this:

Code: Select all

// this goes above the menu entries
byte vtmode = 0;

Code: Select all

void MenuEntry7()
{
   vtmode++;
   if ( vtmode == 7 ) vtmode = 9;
   if ( vtmode > 9 ) vtmode = 1;
   InternalMemory.RFMode_write(vtmode);
   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 »

Hi

I tried the code you suggested, now it does not switch modes at all.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

Try this:

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.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

While trying out your code, I noticed a bug in your DrawTime() function that was causing the wdt to kick in.
Change this:

Code: Select all

  char temp[]=" ";
To this:

Code: Select all

  char temp[]="  ";
Roberto.
jpalmer
Posts: 31
Joined: Tue May 01, 2012 11:49 pm

Re: VortechMenu

Post by jpalmer »

binder wrote:
Poiromaniax wrote:Cool,

Any other way to change modes? Considering my vortech will now become the slave
You can manually change the modes via the web interface. This is the same way that the iPhone and Android apps work.

Code: Select all

// RF Mode
http://YOURIPADDRESS:2000/mb855,X

// RF Speed
http://YOURIPADDRESS:2000/mb856,X

// RF Duration
http://YOURIPADDRESS:2000/mb857,X
You simply use your IP address and port. Then, you would use the value you want in place of X. This is just like what was mentioned earlier.

Or you can use the java status app to change the memory locations:
http://forum.reefangel.com/viewtopic.php?f=8&t=246
Curious, are all of the URL options for the RA documented somewhere?

I know about /r1, /r99, /wifi, and now these few. Is there an authoratative source I can use to tell me all the different options without diving into a bunch of code? Alternately.. if I do need to dig through code, where would I start my search?
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: VortechMenu

Post by rimai »

It's on RA_Wifi.cpp
This is the extraction from the file:

Code: Select all

            if (strncmp("GET / ", m_pushback, 6)==0) reqtype = REQ_ROOT;
            else if (strncmp("GET /wifi", m_pushback, 9)==0) reqtype = REQ_WIFI;
            else if (strncmp("GET /r", m_pushback, 6)==0) reqtype = -REQ_RELAY;
            else if (strncmp("GET /mb", m_pushback, 7)==0) { reqtype = -REQ_M_BYTE; weboption2 = -1; bHasSecondValue = false; bCommaCount = 0; }
            else if (strncmp("GET /mi", m_pushback, 7)==0) { reqtype = -REQ_M_INT; weboption2 = -1; bHasSecondValue = false; bCommaCount = 0; }
            else if (strncmp("GET /ma", m_pushback, 7)==0) reqtype = -REQ_M_ALL;
            else if (strncmp("GET /mr", m_pushback, 7)==0) reqtype = -REQ_M_RAW;
            else if (strncmp("GET /v", m_pushback, 6)==0) reqtype = -REQ_VERSION;
            else if (strncmp("GET /d", m_pushback, 6)==0) { reqtype = -REQ_DATE; weboption2 = -1; weboption3 = -1; bCommaCount = 0; }
            else if (strncmp("HTTP/1.", m_pushback, 7)==0) reqtype = -REQ_HTTP;
            else if (strncmp("GET /sr", m_pushback, 7)==0) reqtype = -REQ_R_STATUS;
            else if (strncmp("GET /sa", m_pushback, 7)==0) reqtype = -REQ_RA_STATUS;
            else if (strncmp("GET /bp", m_pushback, 7)==0) reqtype = -REQ_BTN_PRESS;
            else if (strncmp("GET /mf", m_pushback, 7)==0) reqtype = -REQ_FEEDING;
            else if (strncmp("GET /mw", m_pushback, 7)==0) reqtype = -REQ_WATER;
//            else if (strncmp("GET /cr", m_pushback, 7)==0) reqtype = -REQ_CAL_RELOAD;
            else if (strncmp("GET /mt", m_pushback, 7)==0) reqtype = -REQ_ALARM_ATO;
            else if (strncmp("GET /mo", m_pushback, 7)==0) reqtype = -REQ_ALARM_OVERHEAT;
            //else reqtype = -REQ_UNKNOWN;
There isn't any documentation on the codes yet.
Roberto.
User avatar
JNieuwenhuizen
Posts: 96
Joined: Thu Feb 16, 2012 12:39 am
Location: South Africa

Re: VortechMenu

Post by JNieuwenhuizen »

rimai wrote:Try this:

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;
}
I get an error now - "Else without a previous If"
Post Reply