Please help me to add and edit my codes please

Do you have a question on how to do something.
Ask in here.
Post Reply
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Please help me to add and edit my codes please

Post by Marcos »

Hi to all! I'm the new guy :)
Could any one Please help me to add and edit my codes please. I got these code from a friend and made it almost work the way I wanted and it's just two things I can't make it work. I just wanted to add On and Off on the port 1 when it is closed, let's say for example when I came home late at night and I wanted to see my tank and if I could make it also opposite of port 1 for sump light or just create another port for sump light. We could just delete the line for "Version" to make a room or any suggestion. Thanks in advance!

Here's my full code bellow and I would like to share it too...


/* The following features are enabled for this File:
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DisplayLEDPWM
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define PWMEXPANSION
#define CUSTOM_MAIN
#define COLORS_PDE
#define FONT_8x16
*/


#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <ReefAngel.h>

#define Light Actinic 1
#define Light Full sp 2
#define Jebao 3
#define Jecod 4
#define Skimmer 5
#define Return 6
#define Heater 7
#define Fan 8

#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Date / Time";
prog_char menu7_label[] PROGMEM = "Version";
prog_char menu8_label[] PROGMEM = "Turn ON Skimmer";
prog_char menu9_label[] PROGMEM = "Turn Off Skimmer";
// 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, menu9_label
};

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.SetupDateTime();
}
void MenuEntry7()
{
ReefAngel.DisplayVersion();
}
void MenuEntry8()
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

//custom dysplay temp+on and off relay
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 6, 2, "Marco's ReefAngel");
ReefAngel.LCD.DrawDate(6, 118);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 17, 132, 17);
pingSerial();
x = 12;
y += MENU_START_ROW+1;
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Display PH");
char text[7];
ConvertNumToString(text, ReefAngel.Params.P, 100);
ReefAngel.LCD.Clear(DefaultBGColor, x+16, y+65, x+65, y+16);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text);
pingSerial();

ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
pingSerial();
ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
pingSerial();
x += (16*4) + 8;
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,8,y+25,"ROOM:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor,
9, y+35, 10);
ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x+8,y+25,"SUMP:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], T3TempColor,
x+9, y+35, 10);


byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);

}

void DrawCustomGraph()
{
}


void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.LightsOnPorts = 0;
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(Port4);
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
}

void loop()
{
// Specific functions
// ReefAngel.StandardATO(Port1);
ReefAngel.StandardLights( Port1,8,0,20,0 );
ReefAngel.StandardLights( Port2,10,0,18,0 );
ReefAngel.StandardHeater( Port7,765,780 );
ReefAngel.StandardFan( Port8,771,781 );


ReefAngel.ShowInterface();
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Please help me to add and edit my codes please

Post by rimai »

Do you have the wifi attachment?
It's super easy to turn lights on with the smartphone app.
Roberto.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

No, I don't have Wifi attachment.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Please help me to add and edit my codes please

Post by rimai »

You can only use 9 max menu items.
If you take version, you can turn on, but you will never be able to turn off.
Is there anything you want to remove?
What port do you have the sump light connected to?
Roberto.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Hi, we could remove Date / Time and the Version and if possible for the sump light will be the opposite of the port1 when it Off.
Thanks!
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Any one could help me please?
Thank you!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Please help me to add and edit my codes please

Post by rimai »

Try this:

Code: Select all

/* The following features are enabled for this File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DisplayLEDPWM
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 9
#define PWMEXPANSION
#define CUSTOM_MAIN
#define COLORS_PDE
#define FONT_8x16
*/


#include <ReefAngel_Features.h>
#include <RA_Colors.h>
#include <RA_CustomColors.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 <ReefAngel.h>

#define Light Actinic 1
#define Light Full sp 2
#define Jebao 3
#define Jecod 4
#define Skimmer 5
#define Return 6
#define Heater 7
#define Fan 8

#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "ATO Clear";
prog_char menu4_label[] PROGMEM = "Overheat Clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "Lights On";
prog_char menu7_label[] PROGMEM = "Lights Off";
prog_char menu8_label[] PROGMEM = "Turn ON Skimmer";
prog_char menu9_label[] PROGMEM = "Turn Off Skimmer";
// 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, menu9_label
};

void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.ATOClear();
ReefAngel.DisplayMenuEntry("Clear ATO Timeout");
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.LightsOn();
}
void MenuEntry7()
{
ReefAngel.LightsOff();
}
void MenuEntry8()
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

//custom dysplay temp+on and off relay 
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 6, 2, "Marco's ReefAngel");
ReefAngel.LCD.DrawDate(6, 118);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 17, 132, 17);
pingSerial();
x = 12;
y += MENU_START_ROW+1;
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Display PH");
char text[7];
ConvertNumToString(text, ReefAngel.Params.P, 100); 
ReefAngel.LCD.Clear(DefaultBGColor, x+16, y+65, x+65, y+16);
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text);
pingSerial();

ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.Clear(DefaultBGColor,x,y,x+(16*4),y+16);
pingSerial();
ReefAngel.LCD.DrawHugeNumbers(T1TempColor, DefaultBGColor, x, y, text);
pingSerial(); 
x += (16*4) + 8;
ReefAngel.LCD.DrawText(T2TempColor,DefaultBGColor,8,y+25,"ROOM:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 
9, y+35, 10);
ReefAngel.LCD.DrawText(T3TempColor,DefaultBGColor,x+8,y+25,"SUMP:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], T3TempColor, 
x+9, y+35, 10);


byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);

}

void DrawCustomGraph()
{
}


void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));

ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
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(Port4);
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
}

void loop()
{
// Specific functions
// ReefAngel.StandardATO(Port1);
ReefAngel.StandardLights( Port1,8,0,20,0 );
ReefAngel.StandardLights( Port2,10,0,18,0 );
ReefAngel.StandardHeater( Port7,765,780 );
ReefAngel.StandardFan( Port8,771,781 );


ReefAngel.ShowInterface();
Roberto.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Thank you very much Roberto! I will try it when I get home and I will let you know the result.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Hi Roberto, Ya the menu are there now but Lights On and Lights Off still didn't work and it's only white blank screen and the relay didn't even make any sounds. I think I already tried edited that line before but it didn't work as well.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Please help me to add and edit my codes please

Post by rimai »

Did you change this line too:

Code: Select all

ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
Roberto.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Yes Roberto I did
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Roberto, I saw now why no response, we should only put Port1bit; because it's conflict on the port 2 while its ON on the timer configuration... Now its working. Now I wanted the Port 1 to be opposite with the sump light. For example when its Off during night time the sump light will turn ON.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

Roberto I think I have no port available for the opposite light.... any suggestion or just put on a separate plug and just use a regular timer?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Please help me to add and edit my codes please

Post by rimai »

Get the relay expansion box.
Roberto.
Marcos
Posts: 10
Joined: Wed Nov 16, 2016 4:36 am

Re: Please help me to add and edit my codes please

Post by Marcos »

ok thanks! I will buy also soon the wifi attachment and if I will have trouble I will contact you again. Thank you very much and thank you also for you time! Have a great weekend!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Please help me to add and edit my codes please

Post by lnevo »

You could make the menu item a toggle. Thats what I did for my refugium/stand light
Post Reply