New Menu Item

Do you have a question on how to do something.
Ask in here.
Post Reply
grafspee1217
Posts: 84
Joined: Sun Mar 11, 2012 10:38 am

New Menu Item

Post 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
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: New Menu Item

Post 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.
Post Reply