Page 1 of 1

simulate mode idea

Posted: Sun Apr 27, 2014 5:24 am
by AlanM
Seems like an interesting idea would be to add a define statement for the .ino file that can make it run hours as minutes and dump all changes in state to Serial.println as it goes through the simulation. Having looked through the code it might be a ton of print statements and ifdef statements, though.

Re: simulate mode idea

Posted: Sun Apr 27, 2014 5:39 am
by lnevo
What would happen to code that is in seconds already? Any specific function your trying to test?

Re: simulate mode idea

Posted: Sun Apr 27, 2014 7:17 am
by AlanM
Mostly lights and powerheads throughout the day, but dosers and water change and stuff like that could be neat too.

Maybe could do the ifdef that changes all calls to millis() to micros() and watch it all happen at 1000x faster. 8)

Re: simulate mode idea

Posted: Sun Apr 27, 2014 7:20 am
by lnevo
The problem with that is that it scales badly. loop() takes a number of miliseconds to run, so while you can usually be assured that your loop is called at least once per second the same cannot be said for millis and certainly not macros.

I would maybe say for a particular function you could add a scale variable that you could define along with the serial.println based on your ifdef but not globally.

Re: simulate mode idea

Posted: Sun Apr 27, 2014 8:08 am
by rimai
Here is my suggestion.
Implement a disable method to the RTC sync and then you can move in time freely.
We have a RTC sync set to every 6 hours, which means that RA will sync itself with the RTC time every 6 hours. So, if you stray 6 hours from the last time it synced, RA would communicate with the RTC and put you back in the correct time.
This is the line:

Code: Select all

setSyncInterval(SECS_PER_HOUR*6);  // Changed to sync every 6 hours.
It's locate in the file Arduino\libraries\ReefAngel\Plus\init.h
If you simply comment that line for now, you can move in time at will and RA would never sync its clock.
One way to do that is to add a global variable to hold the sync time period and a function to change this variable.
Then, you can use this function from the time library:

Code: Select all

void    adjustTime(long adjustment);
So, every loop or every x numbers of millis you can call it with an increment 1 by setting adjustment to 1, which would add 1 second to RA time or -1, which would decrease one second to RA time.

Re: simulate mode idea

Posted: Sun Apr 27, 2014 8:52 am
by AlanM
Hey, neat idea. So every time through the loop you advance however much you want to get a "fast" mode without editing much code at all.