1. Have a defined runtime, offset, delay (like DelayedPort), repeat - Easy stuff
2. Have a defined StartTime and StopTime (say you want to shut off a pump but only for 10 minutes...) or you want to manually trigger a relay but only want it to run for 5 minutes (when it's normal programming is for 20)
3. Pause/Resume
4. Load/Save settings to/from memory
In the future, I would like to extend this class to a DosingPump class so that it could have parameters like Volume, and Rate and Calibration.
To start off, you will need to define the class
Code: Select all
TimedPort mainPump;
void setup() {
mainPump.Init();
mainPump.ID=Box1_Port1;
mainPump.Time=60;
mainPump.Repeat=120;
mainPump.StartTime=720;
mainPump.StopTime=15;
mainPump.Scale=60; // in minutes (use 1 for seconds, 360 for hours...)
mainPump.Save(100); // Will save in memory location 100-115 (16 bytes are required)
}
Code: Select all
void loop() {
mainPump.Load(100);
mainPump.Run();
}
If you wanted a 10 minutes offset, it's easy
Code: Select all
mainPump.Offset=10;
Code: Select all
mainPump.Delay=5;
Code: Select all
if (ReefAngel.Relay.isMaskOn(Port1)) {
mainPump.Start();
ReefAngel.Relay.Auto(Port1);
}
The same could be done for Stop()
Code: Select all
if (ReefAngel.Relay.isMaskOff(Port1)) {
mainPump.Stop();
ReefAngel.Relay.Auto(Port1);
}
Now, the Run() command I mentioned earlier is only needed for managing the timed operations for start/stop and to auto run the schedule. You can also use this without using Run by using the normal Relay commands.
mainPump.On();
mainPump.Off();
mainPump.DelayedOn();
and another usage that is nice is Osc. Osc is similar to the Apex usage.
mainPump.Osc(0,60,60,true);
This will run with 0 offset, for 60 minutes on then 60 minutes off, and true for ON. This is actually called by the Run() command along with the other timer monitoring.
There is more commands that I did not discuss, but most are self explanatory, such as the following.
Toggle(), Pause(), Resume(), SetActive(), IsRunning(), IsStarted(), IsStopped(), IsActive()
Hope this helps people get started with this functionality.