alexwbush wrote:
I agree... but it seems the only way I can run this off of the menu is by modifying the reefanel.cpp file.
I am using the latest file with simplified menu and have only had to mod two sections, which I am keeping track of for future change to the file.
I'm still working on a way to have you be able to create your own menu (like with the main screen), so when that happens you will definitely be able to do this easier.
DelayedOn(...,...) requires it to be called repeatedly in order for it to know when to turn the port on. So you can't just call it once and not ever call it again.
Once you enter into your WaterChangeMode loop, the main StandardInterface function is processing all the additional events. So the WaterChangeStart just does all the initial prep work for water change mode (like with feeding mode) and then, like Roberto said, the DisplayedMenu variable is set to indicate which mode we are in and processes accordingly. Take a look at the ShowInterface function to see what I'm talking about.
There are 2 ways you can proceed until I get my own custom menu created:
1. Make your water change procedure it's own function and handle everything you do in there, but you lose all of the ability to respond to wifi requests and events. The upside is all of your code is contained within a single function and it's easier to replicate, meaning you just copy your function into your PDE file and then add 2 lines of code to the libraries and you are done.
2. Change the menu item to act like a feeding mode or water change mode click (like in ProcessButtonPressMain()). You choose another DisplayedMenu value and change it to that. Then inside your PDE, you check for the DisplayedMenu value to equal your own value and perform all of your functions. The downside with this is you need to make sure that the other functions don't interfere / override what you are doing.
Roberto is correct, ReefAngel.DisplayedMenu is a private variable and cannot be accessed from within the PDE file.
I know you want this water change to happen automatically. You also want your controller to be responsive to wifi requests during the water change. My first quick thought about how to do this is like I do the CustomMain. So it's 2 fold. Create a function prototype inside ReefAngel.h and then call the function from the menu. Then define and create your function inside your PDE file. You will have to do everything inside the function and you will not have wifi connectivity from the function. Then when the function exits, the controller will resume operations. I know it doesn't sound exactly like you want it, but it's a start. It also allows time to think things through better while you are getting something to function. It won't be any different than the previous water change mode not responding to wifi requests.
Inside ReefAngel.cpp in the ProcessButtonPressMain function, change the water change mode case to this:
Code: Select all
case MainMenu_WaterChangeMode:
{
YourCustomFunction();
// then act like the exit button was pressed
SelectedMenuItem = DEFAULT_MENU_ITEM;
DisplayedMenu = DEFAULT_MENU;
showmenu = false;
#ifdef CUSTOM_MAIN
DrawCustomGraph();
#else
LCD.DrawGraph(5, 5); // Redraw graphic of params
#endif // CUSTOM_MAIN
}
Then you must handle everything inside your function. Like I said, it's a start, not the most elegant but it works and requires minimal changes to the libraries. I'm sure there is a better way to handle it but I have to think about it more.
I'll have to keep working on it with my custom menu stuff too but that may not be until the weekend at the earliest.
curt