simulate mode idea

Request new hardware or ideas for the controller
Post Reply
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

simulate mode idea

Post 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.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: simulate mode idea

Post by lnevo »

What would happen to code that is in seconds already? Any specific function your trying to test?
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: simulate mode idea

Post 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)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: simulate mode idea

Post 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.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: simulate mode idea

Post 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.
Roberto.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: simulate mode idea

Post 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.
Post Reply