Page 1 of 1

how to code jebao

Posted: Sun Dec 28, 2014 9:46 am
by Ademster
this is the code I am using from a member here on the board.

I want it to be random through out the day,
not just at midnight it changes or upon reboot.

Code: Select all

   ////// Place your custom code below here
     static int rmode;
    static boolean changeMode=true;


    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, LongPulse, Else, Gyre };

    if (now()%SECS_PER_DAY==0 || changeMode==true) { // Change at midnight or if controller rebooted
    rmode=random(100)%sizeof(modes); // Change the mode once per day to pick from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3600) {
    // Continue NTM for the 60 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Constant;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }

Re: how to code jebao

Posted: Sun Dec 28, 2014 10:36 am
by lnevo
Change SECS_PER_DAY to whatever time in seconds you want it to switch modes

Re: how to code jebao

Posted: Sun Dec 28, 2014 4:00 pm
by Ademster
awesome thanks greatly appreciated