Acclimation Button on Menu

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Acclimation Button on Menu

Post by Sacohen »

I want to make a modified standard menu.
I like the standard menu the way it is, but I want to add a button on the menu, the portal or the Andriod app that will disable the Water Level Expansion ATO while I'm dripping water into a holding bucket for my newly acquired tank inhabitants.

The way I acclimate is I drip water from the tank to a gallon jug that had a portion of 1 side cut off and a hole poked into it about 2-3" below the top of the cut in the jug.

As water drips into the jug the level is going to go down in the sump, until the water level in the jug starts flowing out of the hole back into the sump.

I don't want the ATO to kick in when the sump is lowered because of acclimation.

The way I do it now is I just plug the plug out of Port6 (the ATO pump port) or turn off the relay from the App or the Portal.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

What would be different then disabling the relay through the app?

It would be pretty easy to add a menu item to just mask off the relay to prevent the ato from running.

I hope your doing this in your qt! I would never drip lfs water back into a tank!! Anyway water police mode off...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

I guess it would be the same.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

You can use the menu generator that curt has somewhere or copy the standard menu code in the libraries. You can also look at my menu entries i think i only have one or two entries extra.

What i would put in your menu entry is this:

Code: Select all

ReefAngel.Relay.Override(Port6,0);
We could add more code to make it a toggle. With that You'll have to clear the override from phone or portal.

I'll try and write you up a full function later.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

I think I have the menu generator on my laptop at home.
I'll look when I get home.

What do you mean by make it toggle, kind of like the water change mode?
Click it to turn off the pump then click it again when you are done to turn it back on.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Yeah
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Haha I got it :) Took a little thinking about to get the math correct.

This should toggle the RelayMaskOff between Off and Auto...

Code: Select all

ReefAngel.Relay.Override(Port6, ~bitRead(ReefAngel.Relay.RelayMaskOff, Port6Bit)*2);
To break that down...

If the RelayMaskOff bit is unset it is normally 1. So we will get the bitwise opposite (~) which would equal 0 and multiply that by 2 which would still equal 0. When we pass that to the Override function, it will set that port to always off.

If the RelayMaskOff bit is set, it would be 0, so when we get the bitwise opposite, it would return 1. When we multiply that by 2 we would get 2. When we pass 2 to the Override function, it sets the port back to auto mode.

Enjoy.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

Thanks. I'll look at the menu generator when I get home, in the meantime I may look at your custom menu.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

I think the only things different on my custom menu are a similar toggle I use for my fuge light and another that cycles the modes on my Vortechs. So should be fairly easy to customize.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

I'm looking at your code and I think it is making sense.
Can I see what your menu looks like?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

If you look at the top of my code where I have the prog_char lines...that's what my menu looks like...exactly in that order.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

That's what I thought.
We can't have nested menu's like the Standard Menu actually is, correct.
I think I rad that somewhere before.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Nope.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

OK. Things are making a little sense.
As you're probably aware, I'm the type that has lots of questions about things I have a little knowledge of so here goes....

I noticed at the 2 Custom menu entries that you have (Vortech Mode and Refugium Lighting) there is this code after it...

Code: Select all

ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
What does this do?
Does it return the screen to the main menu?

Thanks.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Exactly
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

Unless I'm missing it, I don't see anything for turning your lights on and off in your menu.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

MenuEntry4()
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

That is listed as your Refugium Light.
Does it toggle you main lights too?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

No i only toggle the fuge light when Im down there doing maintenance
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

Ok. I'm missing something then.

When I put prog_char menu4_label[] PROGMEM = "Refugium Light"; in under // Custom menus

And then

void MenuEntry4() {
// Toggle refugium light between on/auto.
ReefAngel.Relay.Override(Refugium, ReefAngel.Relay.Status(Refugium)+1);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}

under // Menu code

I get the following error when I try to compile it..

Steves_Custom_Menu_Test.cpp: In function 'void MenuEntry4()':
Steves_Custom_Menu_Test:127: error: 'Refugium' was not declared in this scope


Here is my code...

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

// Custom menus
#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Acclimation";
prog_char menu4_label[] PROGMEM = "Refugium Light";
prog_char menu5_label[] PROGMEM = "ATO Clear";
prog_char menu6_label[] PROGMEM = "Overheat Clear";
prog_char menu7_label[] PROGMEM = "PH Calibration";
prog_char menu8_label[] PROGMEM = "WLS Calibration";
prog_char menu9_label[] PROGMEM = "Date / Time";

// 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
};

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

unsigned long ATOUpdate=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.FeedingModePorts = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 825 );


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

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


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

void loop()
{
ReefAngel.StandardLights( Port1,12,0,22,0 );
ReefAngel.StandardLights( Port2,13,0,21,0 );
ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port1 ) );
ReefAngel.StandardLights( Port7,13,0,21,0 );
ReefAngel.Relay.Set(Port5,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
ReefAngel.Relay.Set(Port8,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
ReefAngel.WaterLevelATO(Port6,720,30,30); // Enable ATO the ATO
if (ReefAngel.Relay.Status(Port5)) // Check to see if port 5 is on and update time is empty
{ 
ATOUpdate = now(); // If so, set the update time to now
} 

if (now() - ATOUpdate < 120) // If it hasnt been 120 seconds turn off the port
{ 
ReefAngel.WaterLevelATO(Port6,720,0,1);
}
ReefAngel.PWM.SetActinic(MyCustomWave(50));
if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(0);
if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);
if (hour()<12 || hour()>=22) ReefAngel.PWM.SetActinic(30);
////// Place your custom code below here


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

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

// Menu Code
void MenuEntry1() {
  ReefAngel.FeedingModeStart();
}
void MenuEntry2() {
  ReefAngel.WaterChangeModeStart();
}
void MenuEntry3() {
  ReefAngel.Relay.Override(Port6,0);
  ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry4() {
  // Toggle refugium light between on/auto.
  ReefAngel.Relay.Override(Refugium, ReefAngel.Relay.Status(Refugium)+1);
  ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry5() {
  ReefAngel.ATOClear();
  ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry6() {
  ReefAngel.OverheatClear();
  ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry7() {
  ReefAngel.SetupCalibratePH();
  ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry8() {
  ReefAngel.SetupCalibrateWaterLevel();
  ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9() {
  ReefAngel.SetupDateTime();
  ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,66, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel() );
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
byte MyCustomWave(byte maxspeed)
{
static byte randomspeed=0;
if (now()%11<5)
{
return randomspeed;
}
else if (now()%11>=5 && now()%11<10)
{
return maxspeed;
}
else
{
randomspeed=random(35,maxspeed);
return 0;
}
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Was Refugium from my code or yours? It's saying that Refugium is not defined.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

It was from yours.

I copied all of this....

// Custom menus
#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Vortech Mode";
prog_char menu4_label[] PROGMEM = "Refugium Light";
prog_char menu5_label[] PROGMEM = "ATO Clear";
prog_char menu6_label[] PROGMEM = "Overheat Clear";
prog_char menu7_label[] PROGMEM = "PH Calibration";
prog_char menu8_label[] PROGMEM = "WLS Calibration";
prog_char menu9_label[] PROGMEM = "Date / Time";

// 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
};

And changed prog_char menu3_label[] PROGMEM = "Vortech Mode"; to prog_char menu3_label[] PROGMEM = "Acclimation";

Then I took this from yours

// Menu Code
void MenuEntry1() {
ReefAngel.FeedingModeStart();
}
void MenuEntry2() {
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3() {
NextRFMode();
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry4() {
// Toggle refugium light between on/auto.
ReefAngel.Relay.Override(Refugium, ReefAngel.Relay.Status(Refugium)+1);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry5() {
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry6() {
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry7() {
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry8() {
ReefAngel.SetupCalibrateWaterLevel();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9() {
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

And changed

void MenuEntry3() {
NextRFMode();
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}

to

void MenuEntry3() {
ReefAngel.Relay.Override(Port6,0);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}

That's why I was asking how you turn you main light on and off?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Gotcha, yeah change Refugium to your Refugium or main light port :) and it should toggle on/auto for you
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

I know what you are saying, but I'm not sure what to change or the correct syntax.

void MenuEntry4() {
// Toggle refugium light between on/auto.
ReefAngel.Relay.Override(Refugium, ReefAngel.Relay.Status(Refugium)+1);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}

My Lights are on Port1 and Port2.

Do both of the Refugium's above change to Port1, Port2 like this?

Code: Select all

void MenuEntry4() {
// Toggle refugium light between on/auto.
ReefAngel.Relay.Override(Port1, Port2, ReefAngel.Relay.Status(Port1, Port2)+1);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

No put each port on a separate line. Form my code Refugium = Port7

The code you see says set the refugium port to 1+ the status of the refugium port.

So if port7 is off (0) then set the refugium port to on (1)
If port7 is on (1) then set the port to auto (2)

Pretty much the same as what we are gonna do with the your acclimation but toggling 0/2 instead of 1/2
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

I actually spotted an error in my original toggle code.

Code: Select all

ReefAngel.Relay.Override(Port6, ~bitRead(ReefAngel.Relay.RelayMaskOff, Port6Bit)*2);
Port6Bit should be just "5"

I have this bad habit of wanting to use the PortXBit variables.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

Thanks Lee. I actually abandoned that idea.
It really wasn't necessary.
But if I were going to revisit it you're saying it should be like this?

Code: Select all

ReefAngel.Relay.Override(Port6, ~bitRead(ReefAngel.Relay.RelayMaskOff, 5)*2);
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Acclimation Button on Menu

Post by lnevo »

Yep. That will cycle between Off and Auto. So regardless of the port state at the time, it would get masked off or unmasked and revert to automatic mode.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Acclimation Button on Menu

Post by Sacohen »

Thank again. I may revisit it.
Maybe you can help me with this?
I posted this a couple of days ago and no one replied...
http://forum.reefangel.com/viewtopic.php?f=12&t=3540
Post Reply