My code - now with RAnet
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
Thank you both. Will try it out.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
I would like my mp10s to go into feeding mode when I choose feeding mode from the menu...how would I go about doing that?
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
oh. cool. didn't know that. I'm on 1.03, haven't updated for awhile...it will still do that?rimai wrote:it does it automatically.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
yes it does, just tried it out. very cool!bencollinz wrote:oh. cool. didn't know that. I'm on 1.03, haven't updated for awhile...it will still do that?rimai wrote:it does it automatically.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
ok, so feeding mode isn't strong enough flow. How do I tell it to go to short pulse 53% @ 25 duration when I go into feeding mode?
Re: My code
You can change the feeding mode speed on the Ecotech driver without having to do any code change. I believe it keeps the mode that you are in.
You can adjust the speed and duration for this mode using the EcoSmart Configuration mode. See Section 4.5: Configuration Mode for instructions on how to do this. The default speed is set to 50% slower than the lowest speed of the pump for a duration of 10 minutes.
You can adjust the speed and duration for this mode using the EcoSmart Configuration mode. See Section 4.5: Configuration Mode for instructions on how to do this. The default speed is set to 50% slower than the lowest speed of the pump for a duration of 10 minutes.
Re: My code
Setting 1: Barely Spinning
Setting 2: 50% lower than lowest speed of pump
Setting 3: lowest speed of pump
Setting 4: 25% speed of pump
Setting 5: 50% speed of pump
Setting 2: 50% lower than lowest speed of pump
Setting 3: lowest speed of pump
Setting 4: 25% speed of pump
Setting 5: 50% speed of pump
Re: My code
The only reason I suggest this route is that I like to see my drivers blinking in feeding mode You could certainly set it in code, but then you lose the nice light show
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
ok, I'll look into that possibility. thank you.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
wow, your code is insane! I tried to pick through it to figure out NTM mode after exiting feeding mode for a set amount of time and just got entirely lost. is there an easier way?lnevo wrote:The only reason I suggest this route is that I like to see my drivers blinking in feeding mode You could certainly set it in code, but then you lose the nice light show
Re: My code
It's actually pretty straight forward, but my code does a lot...
So during feeding mode, I update a variable with the current time. When feeding mode stops that variable stops getting updated and I know when feeding mode ends.
Then during each pass of loop() you can check that varaible and run NTM for whatever amount of time you want:
I left the ... in place of whatever you want to do. Keep in mind if you have other scheduling overrides and modes happening, you'll need to make that if part of that loop or do it after... this is where my stuff gets more complex and will probably similar in your code.
So during feeding mode, I update a variable with the current time. When feeding mode stops that variable stops getting updated and I know when feeding mode ends.
Code: Select all
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
feeding=now();
}
Code: Select all
if (now()-feeding > 1 && now()-feeding < 3600) { // 1 second after feeding mode until 60 minutes after feeding mode.
... // Run your smart_ntm here.
}
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
like this?
Code: Select all
void_loop(){
if (hour() >=8 && hour() < 22)
{
if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
ReefAngel.RF.UseMemory=true;
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
feeding=now();
}
if (now()-feeding > 1 && now()-feeding < 3600) { // 1 second after feeding mode until 60 minutes after feeding mode.
ReefAngel.RF.SetMode(vtMode,vtSpeed,vtDuration);
}
ReefAngel.Relay.Off(Port8);
}
else
{
ReefAngel.RF.UseMemory=false;
ReefAngel.RF.SetMode(Night,15,0);
ReefAngel.Relay.On(Port8);
}
// This should always be the last line
ReefAngel.Portal( "bencollinz" );
ReefAngel.ShowInterface();
}
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
sorry. i have no programming skills whatsover.
Re: My code
I see that No worries. I'll see what I can do on the trainride home for you.
Re: My code
Actually it looks like you got it. The only thing you need to add is to set UseMemory false if you are doing SetMode like that. Otherwise it looks good.
Don't forget to declare the feeding variable...the static unsigned long feeding; statement. It can be inside the loop function, as long as its before the test.
Good work!
Don't forget to declare the feeding variable...the static unsigned long feeding; statement. It can be inside the loop function, as long as its before the test.
Good work!
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
ok, but I want it to function as follows...lnevo wrote:Actually it looks like you got it. The only thing you need to add is to set UseMemory false if you are doing SetMode like that. Otherwise it looks good.
Don't forget to declare the feeding variable...the static unsigned long feeding; statement. It can be inside the loop function, as long as its before the test.
Good work!
between 8am and 10pm I want it to use whatever setting from memory (ie. portal)
if between 8am and 10pm I go into feeding mode then for 1 hour afterwards it does NTM mode
otherwise it's nite mode ie. ReefAngel.RF.UseMemory=false; ReefAngel.RF.SetMode(Night,15,0);
is that making sense? or am I misunderstanding how this works?
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
or like this?
Code: Select all
void_loop(){
if (hour() >=8 && hour() < 22)
{
if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
ReefAngel.RF.UseMemory=true;
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
feeding=now();
}
if (now()-feeding > 1 && now()-feeding < 3600) { // 1 second after feeding mode until 60 minutes after feeding mode.
ReefAngel.RF.UseMemory=false;
ReefAngel.RF.SetMode(vtMode,vtSpeed,vtDuration);
}
ReefAngel.Relay.Off(Port8);
}
else
{
ReefAngel.RF.UseMemory=false;
ReefAngel.RF.SetMode(Night,15,0);
ReefAngel.Relay.On(Port8);
}
// This should always be the last line
ReefAngel.Portal( "bencollinz" );
ReefAngel.ShowInterface();
}
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
testing it now. thank you so so so so much for helping me!lnevo wrote:Yeah exactly.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code
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)
any advice?
clear ato works fine from the android app though
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
}
*/
clear ato works fine from the android app though
Re: My code - now with RAnet
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
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
Re: My code - now with RAnet
there's also a bug when it exits feeding mode it changes the vortechs to 100% constant.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
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.
-
- Posts: 151
- Joined: Wed Mar 13, 2013 5:36 pm
Re: My code - now with RAnet
I confirmed this again after tonight's feeding.bencollinz wrote:there's also a bug when it exits feeding mode it changes the vortechs to 100% constant.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
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.
Re: My code - now with RAnet
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
Re: My code - now with RAnet
I commented this outlnevo 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.
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
{
Re: My code - now with RAnet
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
Re: My code - now with RAnet
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
}
*/
Re: My code - now with RAnet
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.
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.
Re: My code - now with RAnet
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
}
*/