Lee's Feature Complete PDE
Re: Lee's Feature Complete PDE
Ok, the new version is posted in the second post (http://forum.reefangel.com/viewtopic.php?p=17807#p17807) This version incorporates the Automated Water change mode using my Reactor pump (Media Rinsing and Water change in one!!) It also incorporates the new Tide class and a custom RF mode to use it. The tidal gap (difference between high and low tide) is affected by the current MoonPhase() and the Sync / Anti-Sync pumps will switch direction based on Ebb and Flood of the tide. I also add a PWMSlope to transition to Night Mode and maintain the tidal effect.
Any questions, please ask. Testing so far is going well
Any questions, please ask. Testing so far is going well
Re: Lee's Feature Complete PDE
Had my night speed PWMSlope getting set wrong... all fixed now
Re: Lee's Feature Complete PDE
I have turned all my custom code into functions so it should be much easier to borrow bits and pieces. Later, I'll move some of the variables into the functions that don't need to be global to make it even more self-contained.
Re: Lee's Feature Complete PDE
Added the anti-sync part of the ReefCrestMode function into play. Added moonrise/set calculation.
Re: Lee's Feature Complete PDE
Implemented Roberto's clever multiple screen display feature
Roberto... I'm using LCD.DrawGraph and getting a lot of flicker... is there a better way to call that function?
Roberto... I'm using LCD.DrawGraph and getting a lot of flicker... is there a better way to call that function?
Re: Lee's Feature Complete PDE
Graph has it's own custom section...
You need to do this:
You need to do this:
Code: Select all
void DrawCustomGraph()
{
if (ScreenID==1)
ReefAngel.LCD.DrawGraph(5, 10);
}
Roberto.
Re: Lee's Feature Complete PDE
Not working right if I navigate away from the screen and come back it doesn't redraw.... If I make that the default screen then it draws until I leave... how can I trigger it to draw once
Re: Lee's Feature Complete PDE
You can't have it being called inside DrawCustomMain() at all.
Just on DrawCustomGraph()
Just on DrawCustomGraph()
Roberto.
Lee's Feature Complete PDE
Yeah i took it out...if i navigate off the screen and back its blank...how can i trigger it to draw when switching screens.
Re: Lee's Feature Complete PDE
Try this:
Code: Select all
//declare this on global
boolean DrawGraph=true;
// This goes in DrawCustomMain()
switch (ScreenID)
{
case 0:
{
break;
}
case 1:
if (DrawGraph)
{
ReefAngel.LCD.DrawGraph(5, 10);
DrawGraph=false;
}
break;
}
if (ReefAngel.Joystick.IsLeft())
{
ReefAngel.ClearScreen(DefaultBGColor);
DrawGraph=true;
ScreenID--;
}
if (ReefAngel.Joystick.IsRight())
{
ReefAngel.ClearScreen(DefaultBGColor);
DrawGraph=true;
ScreenID++;
}
if (ScreenID<0) ScreenID=NumScreens-1;
if (ScreenID>=NumScreens) ScreenID=0;
Roberto.
Re: Lee's Feature Complete PDE
And what will trigger the refresh if I don't switch screens?
Re: Lee's Feature Complete PDE
You can't leave me hanging like that! What was the problem and fix?lnevo wrote:Nevermind..
Lee's Feature Complete PDE
I still am drawing the graph on DrawCustomGraph()
Lee's Feature Complete PDE
I currently have screen 0 as my graph, screen 1 is ato and rf status, screen 3 is sun/moon info
Re: Lee's Feature Complete PDE
Very cool. I'll let you get it all sorted and out check back later today. Then I'll copy your code
Re: Lee's Feature Complete PDE
So I did a lot of cleaning up I haven't yet compiled or uploaded anything so for now this post is just a preview of what's to come.
First off, I cleaned up a lot of the functions. The only global variables I have are basically the vortech varialbes and my Tide and SunLocation classes. The big benefit is that most of my functions are 100% self-contained and can be copied pretty easily. My setup() custom code is now like 3 lines and my loop() is also extremely clean as everything has been moved to subroutines.
I have also moved a lot of stuff into memory locations. I really need to make this standard practice so that nothing needs to be hard-coded. To support that, I wrote my own init_memory function so that I could re-arrange the variables, make sure new ones are initialized properly, etc. I'm using memory location 199 as the flag bit to trigger the memory reset. I only run this in setup() so you'll have to flip the flag and reboot the controller. Or flip the flag and upload new code. I also changed a lot of the memory locations and variables to use true/false instead of 1=on 0=off, since it cleans up a lot of code. One of the reasons I needed the init_memory function
So, what else is new in the coming version? I've added a few things
1) CalibrateDosingPumps() - I wrote this function as I'm about to finally enable my dosers. You flip the memory bit to true and it will turn on both pumps for 10 minutes. Then you can measure how much fluid was pumped and set your pumps accordingly. It will get used once in a blue moon, but hopefully someone will find it useful.
2) runSwabbie() - This function will run my swabbie (using the DosingPumpRepeat() function but I also added a "manual" mode. If you override the default status of the swabbie port, it will clear the override and run the swabbie for 1 minute. Will be fun to demo for people
3) runFeeder() - This uses a memory location as a trigger, but basically will StartFeedingMode() and then wait for a specified delay (stored in memory) and then "press" the auto-feeder button for 5 seconds. I have integrated it into my vacation() mode by flipping on the memory location at 7pm when vacation is enabled. I may change the behavior later on after I get my auto-feeder and mod it and I decide I want it running daily
That's it for now. I'll probably have some time this weekend to debug the code (written with Textastic on my iPad) and get it uploaded to the controller. My swabbie is going to be a while and I'm waiting for a bracket for the dosing pumps so still some hardware pending
First off, I cleaned up a lot of the functions. The only global variables I have are basically the vortech varialbes and my Tide and SunLocation classes. The big benefit is that most of my functions are 100% self-contained and can be copied pretty easily. My setup() custom code is now like 3 lines and my loop() is also extremely clean as everything has been moved to subroutines.
I have also moved a lot of stuff into memory locations. I really need to make this standard practice so that nothing needs to be hard-coded. To support that, I wrote my own init_memory function so that I could re-arrange the variables, make sure new ones are initialized properly, etc. I'm using memory location 199 as the flag bit to trigger the memory reset. I only run this in setup() so you'll have to flip the flag and reboot the controller. Or flip the flag and upload new code. I also changed a lot of the memory locations and variables to use true/false instead of 1=on 0=off, since it cleans up a lot of code. One of the reasons I needed the init_memory function
So, what else is new in the coming version? I've added a few things
1) CalibrateDosingPumps() - I wrote this function as I'm about to finally enable my dosers. You flip the memory bit to true and it will turn on both pumps for 10 minutes. Then you can measure how much fluid was pumped and set your pumps accordingly. It will get used once in a blue moon, but hopefully someone will find it useful.
2) runSwabbie() - This function will run my swabbie (using the DosingPumpRepeat() function but I also added a "manual" mode. If you override the default status of the swabbie port, it will clear the override and run the swabbie for 1 minute. Will be fun to demo for people
3) runFeeder() - This uses a memory location as a trigger, but basically will StartFeedingMode() and then wait for a specified delay (stored in memory) and then "press" the auto-feeder button for 5 seconds. I have integrated it into my vacation() mode by flipping on the memory location at 7pm when vacation is enabled. I may change the behavior later on after I get my auto-feeder and mod it and I decide I want it running daily
That's it for now. I'll probably have some time this weekend to debug the code (written with Textastic on my iPad) and get it uploaded to the controller. My swabbie is going to be a while and I'm waiting for a bracket for the dosing pumps so still some hardware pending
Re: Lee's Feature Complete PDE
Hey Lee,
This actually triggered a very nice idea
I'm going to create a handful of function calls that can be triggered using the wifi commands.
Just like /mf that starts feeding mode.
This way, you can call custom functions through the web browser and we harass Curt to implement in the app too
By having those function calls, you can start CalibrateDosingPumps() or runSwabbie() for example without having to trigger it through memory bit set.
This actually triggered a very nice idea
I'm going to create a handful of function calls that can be triggered using the wifi commands.
Just like /mf that starts feeding mode.
This way, you can call custom functions through the web browser and we harass Curt to implement in the app too
By having those function calls, you can start CalibrateDosingPumps() or runSwabbie() for example without having to trigger it through memory bit set.
Roberto.
Lee's Feature Complete PDE
Sounds good I'm all about saving writes to memory locations i should consolidate some though...its kind of a waste of a byte when you only need a bit...anyway off-track
What i wanted to share was however we call the function or memory. It's still a http call. I've made myself a bit of a "control panel" html page with all the links I use as shortcuts. Basically a glorified bookmark page. This way I never need to remember what bit to flip
What i wanted to share was however we call the function or memory. It's still a http call. I've made myself a bit of a "control panel" html page with all the links I use as shortcuts. Basically a glorified bookmark page. This way I never need to remember what bit to flip
Re: Lee's Feature Complete PDE
Ok, the code compiles. Only a few syntax errors Anyway, it's posted in the 2nd post. Enjoy
Re: Lee's Feature Complete PDE
Nice work, Lee! I need to dial in my wave patterns and wave maker code this weekend. I'll be digging through your code for ideas while I'm at it
Lee's Feature Complete PDE
Instead of creating stub functions or hard coded function names that need to be defined and then needing to be added by curt and whoever on the iPhone app...why not have it take the name of a function and we can have it call a pointer to the function by name?rimai wrote:Hey Lee,
This actually triggered a very nice idea
I'm going to create a handful of function calls that can be triggered using the wifi commands.
Just like /mf that starts feeding mode.
This way, you can call custom functions through the web browser and we harass Curt to implement in the app too
By having those function calls, you can start CalibrateDosingPumps() or runSwabbie() for example without having to trigger it through memory bit set.
Lee's Feature Complete PDE
Maybe not exactly call by name...you'd need either a struct or object to hold properties of the function, like a name / index...
If you made "functions" a linked list or even just an array of object that you could push and pop new functions. It old have a variable property name. A case would go through the list of objects until name="passed" name and then you would execute object.function();
Anyway this could be used for a lot of things...adding screens, menus, callbacks for timers..(assign a function to a TimerClass to run when timer is triggered...
Code: Select all
Store your callback functions in an array like this.
// 2 can be from a #define num_functions 2
typedef void (*FunctionPointer) ();
FunctionPointer functions[2];
// user defines their functions, whatever name they want
void DoFunction1(void) {
// do whatever here
};
void DoFunction2(void) {
// do whatever here
};
// user assigns their functions to global variable, ie. ReefAngel.CustomFunctions[]
functions[0]=DoFunction1;
functions[1]=DoFunction2;
// add to web code (pseudo)
If http command == run_function {
functions[x]();
}
Code: Select all
struct _Object {
void (* functionPointer)();
int value;
char [] name;
};
/* create struct */
struct _Object Object;
Object.value = 1;
Object.name = "DoFunction1";
Object.function = DoFunction1;
Lee's Feature Complete PDE
Here's a good demo for a timer made for Arduino that calls a function when complete.
http://playground.arduino.cc/Code/SimpleTimer
http://playground.arduino.cc/Code/SimpleTimer
- jsclownfish
- Posts: 378
- Joined: Mon Oct 24, 2011 7:52 pm
- Location: Saint Louis
Lee's Feature Complete PDE
Calling functions through the wifi would be nice for things like triggering the remote feeding. It would be easier than changing a memory location like I am doing now. On your feeder, I eventually changed mine to feed small amounts every hour through the day. I don't know if it really helps the fish, but it sure did train them quickly to swim to a certain spot whenever the wavemakers stop.
-Jon
-Jon
Re: Lee's Feature Complete PDE
I'm still not convinced that keeping all the pointer and function arrays and names will be much benefit.
It seems to me that it uses a lot of RAM for little benefit.
I can see how power users may get some benefit, but I don't see anybody else even understanding it, let alone using it.
It's much simpler to just add fixed function calls. just like Curt did with the menu entries.
Like define DoFunction1() on h file and code it inside the INO code, so when the wifi command comes in, it goes and process what's inside DoFunction1() in your INO code.
It seems to me that it uses a lot of RAM for little benefit.
I can see how power users may get some benefit, but I don't see anybody else even understanding it, let alone using it.
It's much simpler to just add fixed function calls. just like Curt did with the menu entries.
Like define DoFunction1() on h file and code it inside the INO code, so when the wifi command comes in, it goes and process what's inside DoFunction1() in your INO code.
Roberto.