Upgrading from v1.0.2 libs to v1.1.0 libs any caveats?

Related to the development libraries, released by Curt Binder
Post Reply
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Upgrading from v1.0.2 libs to v1.1.0 libs any caveats?

Post by 00Warpig00 »

Been away from here for quite a while. Recently I reloaded my Windows 7 Box. With that I re-installed my Reef Angel Software. Latest Libraries with my fresh install are v1.1.0. Last time I played with my code or with uploading a sketch to my RA+ I believe I was compiling with v1.0.1 or v1.0.2 but I am not 100% sure which.

Have been poking around here for a few weeks again considering recompiling with my current (~2 year old) sketch. I do backups so I have all my sketches. I have restored them (only the sketches) from backup into the latest Reef Angel install and I believe they are compiling ok when I test compile them with 1.1.0 without modification.

Although I still have some issues with my controller I have learned to live with them. Although it looks as if 1.1.0 *may* resolve some of them so I am considering the recompile. To be frank I am kind of scared to upload into my controller with the new libs being ~7+ revisions newer than what I believe I am currently running in my controller. Keeping up with this stuff along the way is always the better idea, which I have failed to do. I do not now how extreme the changes in the libs have gotten. Not being a programmer reading the change log on here is only somewhat useful as I cant always define what a specific change as noted in the log means in relation to my setup. My controller has been mostly doing it's job for the past two years. :) I currently have the ATO disabled (floats switches unplugged) because on random occasion the ATO puts 44 additional gallons of RODI into a ~36 Gallon sump that already had ~25 gallons in it (seems to be a coding issue but I have not nailed it down). I have gone to manually topping off daily using the android app to force my ato pump on/off for as long as it takes. Also at least once day I need to reset my overheat flag as my High\low temp readout on my display that I added ages ago when this problem surfaced reports that it was 137.6 degrees in the tank today/everyday. Here is my current running code in my controller. If any one that loves to look at code more than myself sees anything in here that looks like it will cause a problem in 1.1.0 libs It would be great to know. :)

Thanks for any insight anyone can provide :)

Nick

Code: Select all

    #include <ReefAngel_Features.h>
    #include <Globals.h>
    #include <RA_Wifi.h>
    #include <Wire.h>
    #include <OneWire.h>
    #include <Time.h>
    #include <DS1307RTC.h>
    #include <InternalEEPROM.h>
    #include <RA_NokiaLCD.h>
    #include <RA_ATO.h>
    #include <RA_Joystick.h>
    #include <LED.h>
    #include <RA_TempSensor.h>
    #include <Relay.h>
    #include <RA_PWM.h>
    #include <Timer.h>
    #include <Memory.h>
    #include <RA_Colors.h>
    #include <RA_CustomColors.h>
    #include <Salinity.h>
    #include <RF.h>
    #include <IO.h>
    #include <ORP.h>
    #include <AI.h>
    #include <PH.h>
    #include <WaterLevel.h>
    #include <ReefAngel.h>

    ////// Place global variable code below here


    // Initialize Alert variables
    byte AlertNonCritical=0;
    byte AlertCritical=0;
    byte overheatflag=0;
    byte atoflag=0;
    byte iochannel0flag=0;
    byte iochannel1flag=0;
    byte iochannel2flag=0;
    byte iochannel3flag=0;
    byte iochannel4flag=0;
    byte iochannel5flag=0;

    //*****Begin reporting of Maximum\Minimum Temperature on probe T1 Additions
    int T1MinTemp=9999;
    int T1MaxTemp=1;
    int T1Temp=1;

    //*****End reporting of Maximum\Minimum Temperature on probe T1 Additions

    //*****Begin WaterChange Additions

    // skimmer port
    byte SkimmerPort = Port4;
    // return port
    byte ReturnPort = Port3;
    // sump drain port
    byte SumpDrainPort = Port8;
    // SaltWater brute pump
    byte SWBrutePort = Port7;
    // Timer for countdowns
    TimerClass tm;

    //*****End WaterChange Additions


    //*****Begin ATO By Salinity Additions

    byte ATOBrutePort = Port2;

    //*****End ATO By Salinity Additions


    //*****Begin Custom IO Expander Additions

    byte CustomIOExpander = 255;

    //*****End Custom IO Expander Additions


    ////// Place global variable code above here


    //*****Begin Custom Menu Additions

    #include <avr/pgmspace.h>
    prog_char menu1_label[] PROGMEM = "Mask LED's On";
    prog_char menu2_label[] PROGMEM = "Mask LED's Off";
    prog_char menu3_label[] PROGMEM = "Mask LED's Clear";
    prog_char menu4_label[] PROGMEM = "Water Change";
    prog_char menu5_label[] PROGMEM = "Clear ATO Timeout";
    prog_char menu6_label[] PROGMEM = "Overheat Clear";
    prog_char menu7_label[] PROGMEM = "PH Calibration";
    prog_char menu8_label[] PROGMEM = "Date / Time";

    // Group the menu entries together
    PROGMEM const char *menu_items[] =
      {
        menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_label, menu8_label,
      };

    //*****End Custom Menu Additions


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller

        //_Running_Config_Revision_104
        InternalMemory.write(100, 104);


        //*****Begin Custom Menu Additions... Initialize Custom Menu

        ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));   
        InternalMemory.write(199, 0); //sets the controller to non masked LED mode upon boot.   

        //*****End Custom Menu Additions


        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = 0;
        ReefAngel.FeedingModePortsE[0] = 0;
        // Ports toggled when Lights On / Off menu entry selected
        ReefAngel.LightsOnPorts = 0;
        ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port4Bit | Port5Bit | Port6Bit;
        ReefAngel.OverheatShutoffPortsE[0] = 0;
        // Use T1 probe as temperature and overheat functions
        ReefAngel.TempProbe = T1_PROBE;
        ReefAngel.OverheatProbe = T1_PROBE;
        // Set the Overheat temperature setting
        InternalMemory.OverheatTemp_write( 850 );


        // Ports that are always on
        ReefAngel.Relay.On( Port3 );
        ReefAngel.Relay.On( Box1_Port5 );
        ReefAngel.Relay.On( Box1_Port6 );
        ReefAngel.Relay.On( Box1_Port7 );


        ////// Place additional initialization code below here

        ReefAngel.CustomVar[0]=0;
        ReefAngel.CustomVar[1]=0;
        ReefAngel.CustomVar[2]=0;
        ReefAngel.CustomVar[3]=0;
        ReefAngel.CustomVar[4]=0;
        ReefAngel.CustomVar[5]=0;
        ReefAngel.CustomVar[6]=0;   
        ReefAngel.CustomVar[7]=0;   


        ////// Place additional initialization code above here
    }

    void loop()
    {
        ReefAngel.StandardFan( Port1,790,820 );
        ReefAngel.Relay.DelayedOn( Port4,1 );
        ReefAngel.WavemakerRandom( Port5,30,100 );
        ReefAngel.StandardHeater( Port6,750,760 );
        ReefAngel.StandardLights( Box1_Port1,13,0,23,0 );
        ReefAngel.StandardLights( Box1_Port2,13,0,23,0 );
        ReefAngel.StandardHeater( Box1_Port3,750,760 );
        ReefAngel.StandardHeater( Box1_Port4,750,760 );


    //*****Begin Custom Menu Additions

      // Removes LED's from a "MASKED" State
      if ( InternalMemory.read(199) == 0 )
        {
          ReefAngel.PWM.SetChannel( 0, PWMParabola(14,0,23,59,1,100,1) ); //Sets LED Drivers on Ch0 to Parabola math
          ReefAngel.PWM.SetChannel( 1, PWMParabola(14,0,23,59,1,100,1) ); //Sets LED Drivers on Ch1 to Parabola math
          ReefAngel.PWM.SetChannel( 3, PWMSlope(2,0,7,30,0,50,0,0) ); //Opens/closes 5V relay on Ch3 that shorts\opens dimmer leads on Ch0 LED driver to turn Driver on/off
          ReefAngel.PWM.SetChannel( 4, PWMSlope(0,0,14,0,0,50,0,0) ); //Opens/closes 5V relay on Ch4 that shorts\opens dimmer leads on Ch1 LED driver to turn Driver on/off
        }

      // MASKS LED's Off
      if ( InternalMemory.read(199) == 1 )
        {
          ReefAngel.PWM.SetChannel( 0, 0 ); //Sets LED Drivers on Ch0 to 0%
          ReefAngel.PWM.SetChannel( 1, 0 ); //Sets LED Drivers on Ch1 to 0%
          ReefAngel.PWM.SetChannel( 3, 50 ); //closes 5V relay on Ch3 that shorts dimmer leads on Ch0 LED driver to turn Driver off
          ReefAngel.PWM.SetChannel( 4, 50 ); //closes 5V relay on Ch4 that shorts dimmer leads on Ch1 LED driver to turn Driver off
        }

      if ( InternalMemory.read(199) == 2 )
        {
          ReefAngel.PWM.SetChannel( 0, 100 ); //Sets LED Drivers on Ch0 to 100%
          ReefAngel.PWM.SetChannel( 1, 100 ); //Sets LED Drivers on Ch1 to 100%
          ReefAngel.PWM.SetChannel( 3, 0 ); //Opens 5V relay on Ch3 that removes short on dimmer leads on Ch0 LED driver to turn Driver on
          ReefAngel.PWM.SetChannel( 4, 0 ); //Opens 5V relay on Ch4 that removes short on dimmer leads on Ch1 LED driver to turn Driver on
        }

      else
        {
        }
           
    //*****End Custom Menu Additions


    //*****Begin reporting of Maximum\Minimum Temperature on probe T1 Additions


        T1Temp=ReefAngel.Params.Temp[T1_PROBE];

    //T1MaxTemp = T1Temp;
    //T1MinTemp = T1Temp;

          if ( T1Temp > T1MaxTemp ) T1MaxTemp = T1Temp;
              InternalMemory.write(102, T1MaxTemp);
           
          if ( T1Temp < T1MinTemp ) T1MinTemp = T1Temp;
              InternalMemory.write(101, T1MinTemp);

       
    //*****End reporting of Maximum\Minimum Temperature on probe T1 Additions

       
        overheatflag = InternalMemory.read( Overheat_Exceed_Flag );
        atoflag = InternalMemory.read( ATO_Exceed_Flag );
        iochannel0flag = ! ReefAngel.IO.GetChannel( 0 );
        iochannel1flag = ! ReefAngel.IO.GetChannel( 1 );
        iochannel2flag = ! ReefAngel.IO.GetChannel( 2 );
        iochannel3flag = ! ReefAngel.IO.GetChannel( 3 );
        iochannel4flag = ! ReefAngel.IO.GetChannel( 4 );
        iochannel5flag = ! ReefAngel.IO.GetChannel( 5 );
        AlertNonCritical = atoflag + iochannel2flag + iochannel3flag + iochannel4flag + iochannel5flag;
        AlertCritical = overheatflag + iochannel0flag + iochannel1flag;   
        if ( AlertNonCritical >= 1 ) AlertNonCritical = 5;
        if ( AlertCritical >= 1 ) AlertCritical = 5;   
        ReefAngel.PWM.SetActinic(millis()%60000<100?AlertNonCritical:0);
        ReefAngel.PWM.SetDaylight(millis()%60000<100?AlertNonCritical:0);
        if ( AlertCritical >= 1 ) ReefAngel.PWM.SetActinic(millis()%300<100?AlertCritical:0);
        if ( AlertCritical >= 1 ) ReefAngel.PWM.SetDaylight(millis()%300<100?AlertCritical:0);   

       
        ////// Place your custom code below here

        ReefAngel.CustomVar[0]=InternalMemory.read(ATO_Exceed_Flag);
        ReefAngel.CustomVar[1]=InternalMemory.read(Overheat_Exceed_Flag);
        ReefAngel.CustomVar[2]=CustomIOExpander;
        ReefAngel.CustomVar[3]=0;
        ReefAngel.CustomVar[4]=InternalMemory.read(199);
        ReefAngel.CustomVar[5]=AlertNonCritical;
        ReefAngel.CustomVar[6]=AlertCritical;   
        ReefAngel.CustomVar[7]=ATOBrutePort;
       
        if ( ReefAngel.CustomVar[0]== 1 )
          {
            ReefAngel.Relay.RelayMaskOff=~(Port4Bit);
          }

        //*****Begin WC Additions

        // If menu equals waterchange mode
        // then we start the automatic water change
        // Otherwise we ignore and proceed
        if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
          {
            AutoWaterChange();
          }
       
        //*****End WC Additions
       
       
        //*****Begin ATO By Salinity Additions
       
        if (ReefAngel.Params.Salinity<300)
          {
            ATOBrutePort=Port7;
          }
        else
          {
            ATOBrutePort=Port2;
          }
        ReefAngel.StandardATO(ATOBrutePort,40 );
        if (iochannel2flag == 1)
          {
            ReefAngel.Relay.RelayMaskOff=~(Port7Bit);
          }
        if (iochannel4flag == 1)
          {
            ReefAngel.Relay.RelayMaskOff=~(Port2Bit);
          }
         
        //*****End ATO By Salinity Additions


        //*****Begin Custom IO Expander Additions

        //*****End Custom IO Expander Additions


        ////// Place your custom code above here

        // This should always be the last line
        ReefAngel.Portal( "00Warpig00" );
        ReefAngel.ShowInterface();
    }


    //*****Begin Custom Menu Additions

    //Mask LED's On. Forces LED's On Full Blast
    void MenuEntry1()
      {
        InternalMemory.write(199, 2);
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Mask Lights On"); waitForTime(2);
        ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
      }

    //Mask LED's Off. Forces LED's Off
    void MenuEntry2()
      {
        InternalMemory.write(199, 1);
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Mask Lights Off"); waitForTime(2);
        ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
      }

    //Mask LED's Clear. Remove LED Masking Returns LED's To Normal Schedule
    void MenuEntry3()
      {
        InternalMemory.write(199, 0);
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Mask Lights Clear"); waitForTime(2);
        ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
      }
     
    //Start Waterchange Mode
    void MenuEntry4()
      {
        ReefAngel.WaterChangeModeStart();
      }

    //Clear ATO Timeout Flag
    void MenuEntry5()
      {
        ReefAngel.ATOClear();
        ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
      }

    //Clear Overheat Flag
    void MenuEntry6()
      {
        ReefAngel.OverheatClear();
        ReefAngel.DisplayMenuEntry("Clear Overheat");
      }

    //Calibrate PH Probe
    void MenuEntry7()
      {
        ReefAngel.SetupCalibratePH();
        ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
      }

    //Set clock Date & Time
    void MenuEntry8()
      {
        ReefAngel.SetupDateTime();
        ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
      }
     
    //*****End Custom Menu Additions


    //*****Begin WC Additions

    void AutoWaterChange()
    {
        // auto water change mode
        // Display Starting Water Change"
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Starting Water Change"); waitForTime(3);

        // Check Saltwater BRUTE for sufficient saltwater on IO Module Port2
        if ( isSWBruteEmpty() )
          {
            ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
            ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Not Enough Saltwater"); waitForTime(3);

            //Abort Water Change if insufficient saltwater
            // Handles the cleanup to return to the main screen
            ReefAngel.ClearScreen(DefaultBGColor);
            ReefAngel.DisplayedMenu = DEFAULT_MENU;
            DrawCustomGraph();
            return;
          }
       
        //Display Disabling ATO Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");   
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Disabling ATO Pump"); waitForTime(3);

        // turn off ATO pump port to prevent ATO from trying to fill a sump being drained intentionally
        ReefAngel.Relay.RelayMaskOff=~(Port2Bit);
       
        //Display Stopping Skimmer
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Stopping Skimmer"); waitForTime(3);

        // turn off the skimmer port
        ReefAngel.Relay.Off(SkimmerPort);
        ReefAngel.Relay.Write();
       
        //Display Skimmer Draining
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Skimmer Draining"); waitForTime(3);   

        // wait for 1 minute
        waitForTime(60);

        //Display Skimmer Done Draining
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Skimmer Done Draining"); waitForTime(3);
       
        //display Stopping Return Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Stopping Return Pump"); waitForTime(3);

        //Stop Return Pump
        ReefAngel.Relay.Off(ReturnPort);
        ReefAngel.Relay.Write();
       
        //Display Draining To Sump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Draining To Sump"); waitForTime(3);

        //display Sump Filling
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Filling"); waitForTime(3);

        // wait for IO Mod Port 1 to be active
        waitForIOChannel(1);

        //display Sump Is Full
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Is Full"); waitForTime(3);

        //Display Sump Settling
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settling"); waitForTime(3);

        // wait for sump to settle
        waitForTime(30);
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settled"); waitForTime(3);

        // display Draining Sump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Start Draining Sump"); waitForTime(3);

        //turn on sump drain pump
        ReefAngel.Relay.On(SumpDrainPort);
        ReefAngel.Relay.Write();

        //display Sump Draining
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Draining"); waitForTime(3);

        // wait for sump empty port active, IO Mod Port 0
        waitForIOChannel(0);
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Is Empty"); waitForTime(3);

        //display Stopping Sump Draining
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Stopping Sump Drain"); waitForTime(3);

        // turn off sump drain
        ReefAngel.Relay.Off(SumpDrainPort);
        ReefAngel.Relay.Write();

        //Display Sump Settling
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settling"); waitForTime(3);

        // wait for sump to settle
        waitForTime(30);

        //display Sump Settled
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settled"); waitForTime(3);

        //display Starting Saltwater Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Start Saltwater Pump"); waitForTime(3);

        //turn on Saltwater Pump
        ReefAngel.Relay.On(SWBrutePort);
        ReefAngel.Relay.Write();

        //display Saltwater Pumping
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Saltwater Pumping"); waitForTime(3);

        // wait for sump full float switch active, IO Mod Port 1
        waitForIOChannel(1);

        //display Stop Saltwater Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Stop Saltwater Pump"); waitForTime(3);

        // turn off sw brute pump
        ReefAngel.Relay.Off(SWBrutePort);
        ReefAngel.Relay.Write();   

        //diasplay Sump is Full
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Is Full"); waitForTime(3);

        //Display Sump Settling
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settling"); waitForTime(3);

        // wait for sump to settle
        waitForTime(30);

        //display Sump Settled
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Sump Settled"); waitForTime(3);
       
        //display Starting Return Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Starting Return Pump"); waitForTime(3);

        // turn on return pump
        ReefAngel.Relay.On(ReturnPort);
        ReefAngel.Relay.Write();

        //display Return Pump Started
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Return Pump Started"); waitForTime(3);

        //display Normalizing Waterlevel
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Normalizing Waterlevel"); waitForTime(3);

        //waiting 2 minutes for waterlevel to normalize
        waitForTime(120);
       
        //display Starting Skimer
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Starting Skimmer"); waitForTime(3);

        //turn on skimmer
        ReefAngel.Relay.On(SkimmerPort);
        ReefAngel.Relay.Write();

        //display Normalizing Skimmer
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Normalizing Skimmer"); waitForTime(3);

        //wait for 2 minutes for skimmer to normalize
        waitForTime(120);

        //display Skimmer Normalized
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Skimmer Normalized"); waitForTime(3);

        //display Enabling ATO Pump
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Enabling ATO Pump"); waitForTime(3);

        //Enable ATO pump
        ReefAngel.Relay.RelayMaskOff = B11111111;
        ReefAngel.Relay.Write();

        //display Water Change Complete
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "                      ");
        ReefAngel.LCD.DrawText(ModeScreenColor, DefaultBGColor, 2, 30, "Water Change Complete"); waitForTime(3);

        // Handles the cleanup to return to the main screen
        ReefAngel.ClearScreen(DefaultBGColor);
        ReefAngel.DisplayedMenu = DEFAULT_MENU;
        DrawCustomGraph();
    }

    bool isSWBruteEmpty()
    {
      // check status of IO Mod Port 2
      if ( ! ReefAngel.IO.GetChannel(2) )
          return true;
      return false;
    }

    void waitForTime(int seconds)
    {
        bool done = false;
        tm.SetInterval(seconds);
        tm.Start();
        int t = tm.Trigger - now();
        do
        {
          // check the wifi interface
          pingSerial();
          // wait for specified seconds
          if ( (t >= 0) && ! tm.IsTriggered() )
            {
              // TODO finish countdown on screen
              // show countdown on screen
              //LCD.Clear(DefaultBGColor,60+(intlength(t)*5),100,100,108);
              //LCD.DrawText(DefaultFGColor,DefaultBGColor,60,100,t);
              wdt_reset();
              delay(200);
            }
            else
            {
              done = true;
            }
        } while ( !done );
        return;
    }

    void waitForIOChannel(byte channel)
    {
        // TODO complete this function
        do
        {
          wdt_reset();
          // display something on screen
          // check the wifi interface
          pingSerial();
          delay(200);
          // TODO check the IO channel logic
        } while ( ReefAngel.IO.GetChannel(channel) );
    }

    //*****End WC Additions


    //*****Begin Custom IO Expander Additions

        byte expanderRead()
        {
          byte _data=0;
          Wire.requestFrom(0x27, 1);
          if(Wire.available())
            {
            _data = Wire.read();
            CustomIOExpander = _data;
            }
          delay(10);
          return _data;
        }
       
        boolean expanderReadGetChannel(byte channel)
        {
          return bitRead(expanderRead(),channel);
        }

    //*****End Custom IO Expander Additions
       

    void DrawCustomMain()
    {
        int x,y;
        char text[10];
        // Dimming Expansion
        x = 15;
        y = 2;
        for ( int a=0;a<6;a++ )
        {
          if ( a>2 ) x = 75;
          if ( a==3 ) y = 2;
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :   " );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
          y += 10;
        }
        pingSerial();

        // I/O Expansion
        byte bkcolor;
        x = 14;
        y = 34;
        for ( int a=0;a<6;a++ )
        {
          ReefAngel.LCD.DrawCircleOutline( x+(a*20),y,4,COLOR_MEDIUMORCHID );
          if ( ReefAngel.IO.GetChannel(a) ) bkcolor=COLOR_WHITE; else bkcolor=COLOR_GRAY;
          ReefAngel.LCD.FillCircle( x+(a*20),y,2,bkcolor );
        }
        pingSerial();

        // Parameters
    #if defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params,
        ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
    #else // defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 44, ReefAngel.Params );
    #endif // defined DisplayLEDPWM && ! defined RemoveAllLights
        pingSerial();

        // Salinity
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,76, "SAL:" );
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,60,76, "L" );   
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,90,76, "H" );       
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,76, ReefAngel.Params.Salinity );
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,69,76, T1MinTemp );
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,98,76, T1MaxTemp );   
        pingSerial();

        // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 90, TempRelay );
        pingSerial();

        // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
        TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
        ReefAngel.LCD.DrawOutletBox( 12, 104, TempRelay );
        pingSerial();

        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 122 );
        pingSerial();
    }

    void DrawCustomGraph()
    {
    }

180G FOWLR
20GH QT#1
29G QT#2

Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Upgrading from v1.0.2 libs to v1.1.0 libs any caveats?

Post by rimai »

I think your code looks fine :)
Roberto.
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Upgrading from v1.0.2 libs to v1.1.0 libs any caveats?

Post by 00Warpig00 »

Thanks Roberto,

Upgrade seems to have gone well so far and not a single false overheat in two days so far :)

Nick
180G FOWLR
20GH QT#1
29G QT#2

Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Upgrading from v1.0.2 libs to v1.1.0 libs any caveats?

Post by rimai »

Awesome!!
Roberto.
Post Reply