Page 1 of 1
New Menu Item
Posted: Sun Aug 26, 2012 6:23 am
by grafspee1217
Hi Roberto,
How could I add a new function to the menu? For example, my current menu has water change, feeding etc. I wanted to add a lights on function. Many times I need to look at something in the tank and it's after the lights have gone out. Unplugging something from the relay box and plugging it into the wall is my only way of doing it now. I would specify which sockets to turn on in lights on mode. Can that be done?
Thanks
Re: New Menu Item
Posted: Sun Aug 26, 2012 7:31 am
by binder
Can you post your current code?
What you would need to do is use the LightsOn functionality.
Here is an example code:
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 <ReefAngel.h>
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding";
prog_char menu1_label[] PROGMEM = "Water Change";
prog_char menu2_label[] PROGMEM = "Lights On";
prog_char menu3_label[] PROGMEM = "Lights Off";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label };
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = ReefAngel.LightsOnPortsE[i];
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry4()
{
ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Initialize the custom menu
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit | Port5Bit;
}
void loop()
{
ReefAngel.ShowInterface();
}
The MenuEntry functions control what the functions do. The menu_label variables control what functions are displayed.
Using the LightsOnPorts allows you to make use of the built-in functionality for turning the lights ON/OFF.
This should be able to get you started.