My code - now with RAnet

Share you PDE file with our community

Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm
PostPosted: Wed Jan 07, 2015 3:00 pm
so after adding the RAnet into my code the "clear ATO" from the menu no longer functions and just stays stuck on the click to continue screen (after clicking clear ato)

Code: Select all
    #include <SoftwareSerial.h>
    #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 <Humidity.h>
    #include <DCPump.h>
    #include <PAR.h>
    #include <ReefAngel.h>
    /*
    #define Heater      1
    #define Return      2
    #define HeaterTk2   3
    #define Skimmer     4
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7
    #define Sump Light  8
    */
    ////// Place global variable code below here
byte vtechmode, vtSpeed, vtDuration;
    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port2Bit;
        // ReefAngel.FeedingModePortsE[0] = 0;
        // Ports toggled in Water Change Mode
        // ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // ReefAngel.WaterChangePortsE[0] = 0;
        // Ports toggled when Lights On / Off menu entry selected
        // ReefAngel.LightsOnPorts = 0;
        // ReefAngel.LightsOnPortsE[0] = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
        // 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( 830 );
        ReefAngel.AddRANet();


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port3 );
        ReefAngel.Relay.On( Port4 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
        ReefAngel.Relay.On( Box1_Port1 );
        ReefAngel.Relay.On( Box1_Port2 );
        ReefAngel.Relay.On( Box1_Port3 );
        ReefAngel.Relay.On( Box1_Port4 );
        ReefAngel.Relay.On( Box1_Port5 );
        ReefAngel.Relay.On( Box1_Port6 );
        ReefAngel.Relay.On( Box1_Port7 );
        ReefAngel.Relay.On( Box1_Port8 );
     

        ////// Place additional initialization code below here
       
        // Hardcode calibrations
        ReefAngel.PHMin=576; // PH7.0
        ReefAngel.PHMax=842; // PH10.0
        ReefAngel.SalMax=3300; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
    vtechmode=InternalMemory.RFMode_read();
    vtSpeed=InternalMemory.RFSpeed_read();
    vtDuration=InternalMemory.RFDuration_read();

    static unsigned long feeding;
    ReefAngel.StandardHeater( Port1,778,782 );
        ReefAngel.WaterLevelATO( Port7,180,71,74 );
        ReefAngel.StandardLights( Port8,15,0,2,0 );
        ReefAngel.PWM.SetChannel( 0,PWMSlope(19,00,21,00,15,51,20,0) );  //MOON
        ReefAngel.PWM.SetChannel( 1,PWMSlope(12,30,20,00,15,50,30,0) );  //RB
        ReefAngel.PWM.SetChannel( 2,PWMSlope(12,20,20,00,15,95,30,0) ); //WHITE
        ReefAngel.PWM.SetChannel( 3,PWMSlope(12,15,20,00,15,70,30,0) );  //BLUE&CYAN
        ReefAngel.PWM.SetChannel( 4,PWMSlope(12,00,20,30,15,70,30,0) ); //UV
       
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
       
if (hour() >=13 && hour() < 20)
      {
        // if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
        ReefAngel.RF.UseMemory=true;
        // ReefAngel.RF.SetMode(ReefCrest,60,20);
            if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            {
             feeding=now();
             }
             if (now()-feeding<5400) {
            // if (now()-feeding > 1 && now()-feeding < 5400) { // 1 second after feeding mode until 60 minutes after feeding mode.
  ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Smart_NTM,75,10);
    }
           }
      else
      {
        ReefAngel.RF.UseMemory=false;
        ReefAngel.RF.SetMode(Constant,10,0);
       }
         if (vtechmode!=InternalMemory.RFMode_read())
          InternalMemory.RFMode_write(vtechmode);
         if (vtSpeed!=InternalMemory.RFSpeed_read())
          InternalMemory.RFSpeed_write(vtSpeed);
         if (vtDuration!=InternalMemory.RFDuration_read())
          InternalMemory.RFDuration_write(vtDuration);

        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
     void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

    ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if (vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");

  ReefAngel.LCD.DrawText(0,255,4,30,"RF Speed:");
  ReefAngel.LCD.Clear(255,59,29,128,39);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,71,31,vtSpeed);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,90,31,"/");
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,100,31,vtDuration);
 
  ReefAngel.LCD.DrawText(0,255,10,40,"Salt");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 50, text, Num8x8);
  pingSerial();

 /* ReefAngel.LCD.DrawText(0,255,50,40,"Fresh");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 50, 50, text, Num8x8);
  pingSerial();
*/
  ReefAngel.LCD.DrawText(0,255,100,40,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 50, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,13,58,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 13, 68, text, Num8x8);
  pingSerial();

  // water level
    ReefAngel.LCD.DrawText(0,255,68,58,"WL");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 68, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();

       // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 108, TempRelay );
        pingSerial();
         // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
       TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
       ReefAngel.LCD.DrawOutletBox( 12, 120, TempRelay );
        pingSerial();
     
    }
   
    void DrawCustomGraph()
    {
    }
    /* void Heater2(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    void Heater1(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T1_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T1_PROBE] <= LowTemp && ReefAngel.Params.Temp[T1_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T1_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    */


any advice?
clear ato works fine from the android app though
Image

Posts: 11975
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Jan 08, 2015 9:51 am
I was able to replicate the issue.
It's related to the RANet code indeed.
This will be fixed in the next update.
https://github.com/reefangel/Libraries/issues/202
Roberto.

Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm
PostPosted: Thu Jan 08, 2015 5:45 pm
rimai wrote:I was able to replicate the issue.
It's related to the RANet code indeed.
This will be fixed in the next update.
https://github.com/reefangel/Libraries/issues/202


there's also a bug when it exits feeding mode it changes the vortechs to 100% constant.
well, in my code after it exists the smart_ntm part of it after 5400 seconds it then changes the vortechs to 100% constant. and again, i need to reboot to fix it.
Image

Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm
PostPosted: Fri Jan 09, 2015 4:24 pm
bencollinz wrote:
rimai wrote:I was able to replicate the issue.
It's related to the RANet code indeed.
This will be fixed in the next update.
https://github.com/reefangel/Libraries/issues/202


there's also a bug when it exits feeding mode it changes the vortechs to 100% constant.
well, in my code after it exists the smart_ntm part of it after 5400 seconds it then changes the vortechs to 100% constant. and again, i need to reboot to fix it.


I confirmed this again after tonight's feeding.
Image
User avatar
Posts: 5337
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Jan 09, 2015 4:46 pm
I think that's your code doing that. Can you comment out your feeding routine section in full and verify that it exists as a bug.

Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm
PostPosted: Sat Jan 10, 2015 11:31 am
lnevo wrote:I think that's your code doing that. Can you comment out your feeding routine section in full and verify that it exists as a bug.


I commented this out
Code: Select all
 if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            {
             feeding=now();
             }
             if (now()-feeding<5400) {
            // if (now()-feeding > 1 && now()-feeding < 5400) { // 1 second after feeding mode until 60 minutes after feeding mode.
  ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Smart_NTM,75,10);
    }
           }
      else
      {


and it did reoccur.
Image
User avatar
Posts: 5337
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Jan 10, 2015 12:12 pm
There was more that needed commenting. It would make no sense for your ra to put it into any particular mode after the 5400 seconds. Can you post the full code and I'll revert with the correct change.

Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm
PostPosted: Sat Jan 10, 2015 12:34 pm
lnevo wrote:There was more that needed commenting. It would make no sense for your ra to put it into any particular mode after the 5400 seconds. Can you post the full code and I'll revert with the correct change.

Code: Select all
    #include <SoftwareSerial.h>
    #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 <Humidity.h>
    #include <DCPump.h>
    #include <PAR.h>
    #include <ReefAngel.h>
    /*
    #define Heater      1
    #define Return      2
    #define             3
    #define Skimmer     4
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7
    #define Sump Light  8
    */
    ////// Place global variable code below here
byte vtechmode, vtSpeed, vtDuration;
    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port2Bit;
        // ReefAngel.FeedingModePortsE[0] = 0;
        // Ports toggled in Water Change Mode
        // ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // ReefAngel.WaterChangePortsE[0] = 0;
        // Ports toggled when Lights On / Off menu entry selected
        // ReefAngel.LightsOnPorts = 0;
        // ReefAngel.LightsOnPortsE[0] = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
        // 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( 830 );
        ReefAngel.AddRANet();


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port3 );
        ReefAngel.Relay.On( Port4 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
        ReefAngel.Relay.On( Box1_Port1 );
        ReefAngel.Relay.On( Box1_Port2 );
        ReefAngel.Relay.On( Box1_Port3 );
        ReefAngel.Relay.On( Box1_Port4 );
        ReefAngel.Relay.On( Box1_Port5 );
        ReefAngel.Relay.On( Box1_Port6 );
        ReefAngel.Relay.On( Box1_Port7 );
        ReefAngel.Relay.On( Box1_Port8 );
     

        ////// Place additional initialization code below here
       
        // Hardcode calibrations
       // ReefAngel.PHMin=576; // PH7.0
       // ReefAngel.PHMax=842; // PH10.0
      //  ReefAngel.SalMax=3300; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
    vtechmode=InternalMemory.RFMode_read();
    vtSpeed=InternalMemory.RFSpeed_read();
    vtDuration=InternalMemory.RFDuration_read();

    static unsigned long feeding;
    ReefAngel.StandardHeater( Port1,778,782 );
        ReefAngel.WaterLevelATO( Port7,180,71,74 );
        ReefAngel.StandardLights( Port8,15,0,2,0 );
        ReefAngel.PWM.SetChannel( 0,PWMSlope(19,00,21,00,15,51,20,0) );  //MOON
        ReefAngel.PWM.SetChannel( 1,PWMSlope(12,30,20,00,15,50,30,0) );  //RB
        ReefAngel.PWM.SetChannel( 2,PWMSlope(12,20,20,00,15,95,30,0) ); //WHITE
        ReefAngel.PWM.SetChannel( 3,PWMSlope(12,15,20,00,15,70,30,0) );  //BLUE&CYAN
        ReefAngel.PWM.SetChannel( 4,PWMSlope(12,00,20,30,15,70,30,0) ); //UV
       
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
       
if (hour() >=13 && hour() < 20)
      {
        // if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
        ReefAngel.RF.UseMemory=true;
        // ReefAngel.RF.SetMode(ReefCrest,60,20);
       /*     if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            {
             feeding=now();
             }
             if (now()-feeding<5400) {
            // if (now()-feeding > 1 && now()-feeding < 5400) { // 1 second after feeding mode until 90 minutes after feeding mode.
  ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Smart_NTM,75,10);
    } */
           }
      else
      {
        ReefAngel.RF.UseMemory=false;
        ReefAngel.RF.SetMode(Constant,10,0);
       }
         if (vtechmode!=InternalMemory.RFMode_read())
          InternalMemory.RFMode_write(vtechmode);
         if (vtSpeed!=InternalMemory.RFSpeed_read())
          InternalMemory.RFSpeed_write(vtSpeed);
         if (vtDuration!=InternalMemory.RFDuration_read())
          InternalMemory.RFDuration_write(vtDuration);

        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
     void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

    ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if (vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");

  ReefAngel.LCD.DrawText(0,255,4,30,"RF Speed:");
  ReefAngel.LCD.Clear(255,59,29,128,39);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,71,31,vtSpeed);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,90,31,"/");
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,100,31,vtDuration);
 
  ReefAngel.LCD.DrawText(0,255,10,40,"Salt");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 50, text, Num8x8);
  pingSerial();

 /* ReefAngel.LCD.DrawText(0,255,50,40,"Fresh");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 50, 50, text, Num8x8);
  pingSerial();
*/
  ReefAngel.LCD.DrawText(0,255,100,40,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 50, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,13,58,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 13, 68, text, Num8x8);
  pingSerial();

  // water level
    ReefAngel.LCD.DrawText(0,255,68,58,"WL");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 68, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();

       // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 108, TempRelay );
        pingSerial();
         // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
       TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
       ReefAngel.LCD.DrawOutletBox( 12, 120, TempRelay );
        pingSerial();
     
    }
   
    void DrawCustomGraph()
    {
    }
    /* void Heater2(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    void Heater1(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T1_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T1_PROBE] <= LowTemp && ReefAngel.Params.Temp[T1_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T1_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    */


As well as, you can no longer calibrate pH from the menu on the controller. You click OK for 7 and it skips the 10 really quickly. I tried it 6 times. As well as from the app. No go.
Image

Posts: 11975
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sat Jan 10, 2015 4:04 pm
The calibration is related to the same issue.
The joystick button was not being debounced and was capturing two presses instead of one.
With the addition of the RANet, I had to disable the joystick button interrupt and make it software capture.
The new dev branch has this issue of the joystick button fixed.
If you download the latest dev branch, the joystick should work as intended.
Roberto.
User avatar
Posts: 5337
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Jan 23, 2015 8:16 am
Sorry for the late reply. Please try this code.

Code: Select all
    #include <SoftwareSerial.h>
    #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 <Humidity.h>
    #include <DCPump.h>
    #include <PAR.h>
    #include <ReefAngel.h>
    /*
    #define Heater      1
    #define Return      2
    #define             3
    #define Skimmer     4
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7
    #define Sump Light  8
    */
    ////// Place global variable code below here
byte vtechmode, vtSpeed, vtDuration;
    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port2Bit;
        // ReefAngel.FeedingModePortsE[0] = 0;
        // Ports toggled in Water Change Mode
        // ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // ReefAngel.WaterChangePortsE[0] = 0;
        // Ports toggled when Lights On / Off menu entry selected
        // ReefAngel.LightsOnPorts = 0;
        // ReefAngel.LightsOnPortsE[0] = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
        // 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( 830 );
        ReefAngel.AddRANet();


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port3 );
        ReefAngel.Relay.On( Port4 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
        ReefAngel.Relay.On( Box1_Port1 );
        ReefAngel.Relay.On( Box1_Port2 );
        ReefAngel.Relay.On( Box1_Port3 );
        ReefAngel.Relay.On( Box1_Port4 );
        ReefAngel.Relay.On( Box1_Port5 );
        ReefAngel.Relay.On( Box1_Port6 );
        ReefAngel.Relay.On( Box1_Port7 );
        ReefAngel.Relay.On( Box1_Port8 );
     

        ////// Place additional initialization code below here
       
        // Hardcode calibrations
       // ReefAngel.PHMin=576; // PH7.0
       // ReefAngel.PHMax=842; // PH10.0
      //  ReefAngel.SalMax=3300; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
    vtechmode=InternalMemory.RFMode_read();
    vtSpeed=InternalMemory.RFSpeed_read();
    vtDuration=InternalMemory.RFDuration_read();

    static unsigned long feeding;
    ReefAngel.StandardHeater( Port1,778,782 );
        ReefAngel.WaterLevelATO( Port7,180,71,74 );
        ReefAngel.StandardLights( Port8,15,0,2,0 );
        ReefAngel.PWM.SetChannel( 0,PWMSlope(19,00,21,00,15,51,20,0) );  //MOON
        ReefAngel.PWM.SetChannel( 1,PWMSlope(12,30,20,00,15,50,30,0) );  //RB
        ReefAngel.PWM.SetChannel( 2,PWMSlope(12,20,20,00,15,95,30,0) ); //WHITE
        ReefAngel.PWM.SetChannel( 3,PWMSlope(12,15,20,00,15,70,30,0) );  //BLUE&CYAN
        ReefAngel.PWM.SetChannel( 4,PWMSlope(12,00,20,30,15,70,30,0) ); //UV
       
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
ReefAngel.RF.UseMemory=true;
/*       
if (hour() >=13 && hour() < 20)
      {
        // if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
        ReefAngel.RF.UseMemory=true;
        // ReefAngel.RF.SetMode(ReefCrest,60,20);
            if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            {
             feeding=now();
             }
             if (now()-feeding<5400) {
            // if (now()-feeding > 1 && now()-feeding < 5400) { // 1 second after feeding mode until 90 minutes after feeding mode.
  ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Smart_NTM,75,10);
    }
           }
      else
      {
        ReefAngel.RF.UseMemory=false;
        ReefAngel.RF.SetMode(Constant,10,0);
       }
         if (vtechmode!=InternalMemory.RFMode_read())
          InternalMemory.RFMode_write(vtechmode);
         if (vtSpeed!=InternalMemory.RFSpeed_read())
          InternalMemory.RFSpeed_write(vtSpeed);
         if (vtDuration!=InternalMemory.RFDuration_read())
          InternalMemory.RFDuration_write(vtDuration);
*/
        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
     void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

    ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if (vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");

  ReefAngel.LCD.DrawText(0,255,4,30,"RF Speed:");
  ReefAngel.LCD.Clear(255,59,29,128,39);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,71,31,vtSpeed);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,90,31,"/");
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,100,31,vtDuration);
 
  ReefAngel.LCD.DrawText(0,255,10,40,"Salt");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 50, text, Num8x8);
  pingSerial();

 /* ReefAngel.LCD.DrawText(0,255,50,40,"Fresh");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 50, 50, text, Num8x8);
  pingSerial();
*/
  ReefAngel.LCD.DrawText(0,255,100,40,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 50, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,13,58,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 13, 68, text, Num8x8);
  pingSerial();

  // water level
    ReefAngel.LCD.DrawText(0,255,68,58,"WL");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 68, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();

       // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 108, TempRelay );
        pingSerial();
         // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
       TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
       ReefAngel.LCD.DrawOutletBox( 12, 120, TempRelay );
        pingSerial();
     
    }
   
    void DrawCustomGraph()
    {
    }
    /* void Heater2(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    void Heater1(byte HeaterRelay, int LowTemp, int HighTemp)
    {
    if (ReefAngel.Params.Temp[T1_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
    if (ReefAngel.Params.Temp[T1_PROBE] <= LowTemp && ReefAngel.Params.Temp[T1_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
    if (ReefAngel.Params.Temp[T1_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
    }
    */
PreviousNext

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest