If you aren't using them, then don't call the functions. If the functions are not referenced (or called) by your code, then they will be removed automatically for you.
Here's a sample PDE that includes the code I was talking about. This code assumes that you have the proper features enabled to display a custom menu entry.
Code: Select all
//
// This version designed for v0.8.5 Beta 17 and later
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Multi Dose";
PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label
};
void MenuEntry1()
{
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
}
// This entry handles displaying the MultiDose menu entry
// COPY THIS FUNCTION
void MenuEntry3()
{
int v = InternalMemory.DP1RepeatInterval_read();
int y = InternalMemory.DP2RepeatInterval_read();
if ( SetupOption(v, y, 1, 1440, 4, "m", "", "Repeat Interval", "DP1:", "DP2:") )
{
InternalMemory.DP1RepeatInterval_write(v);
InternalMemory.DP2RepeatInterval_write(y);
}
v = InternalMemory.DP1Timer_read();
y = InternalMemory.DP2Timer_read();
if ( SetupOption(v, y, 1, 255, 3, "s", "", "Run Time", "DP1:", "DP2:") )
{
InternalMemory.DP1Timer_write(v);
InternalMemory.DP2Timer_write(y);
}
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports that are always on
ReefAngel.Relay.On(Port8);
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
ReefAngel.SingleATOLow(Port6);
ReefAngel.Relay.DelayedOn(Port1, 1);
ReefAngel.StandardLights(Port2);
ReefAngel.MHLights(Port3);
ReefAngel.Wavemaker1(Port4);
ReefAngel.Wavemaker2(Port5);
ReefAngel.StandardHeater(Port7);
}
// Setup Menu Screen
// ADD THIS FUNCTION
bool SetupOption(int &v, int &y, int rangemin, int rangemax, byte maxdigits,
char* unit, char* subunit, char* title,
char* prefix1, char* prefix2)
{
// return true to save value stored in out in memory
enum choices {
OPT1,
OPT2,
OK,
CANCEL
};
byte sel = OPT1;
bool bSave = false;
bool bDone = false;
bool bRedraw = true;
bool bDrawButtons = true;
bool bSingle = (y < 0) ? true : false;
byte offset = 50;
ReefAngel.ClearScreen(DefaultBGColor);
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW, title);
// prefix for each option
if ( ! bSingle )
{
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW*4, prefix1);
ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW*6, prefix2);
}
do
{
#if defined WDT || defined WDT_FORCE
wdt_reset();
#endif // defined WDT || defined WDT_FORCE
if ( bRedraw )
{
switch ( sel )
{
case OPT1:
{
if ( ! bSingle )
ReefAngel.LCD.DrawOption(y, 0, MENU_START_COL+offset, MENU_START_ROW*6, unit, subunit, maxdigits);
ReefAngel.LCD.DrawOption(v, 1, MENU_START_COL+offset, MENU_START_ROW*4, unit, subunit, maxdigits);
if ( bDrawButtons )
{
ReefAngel.LCD.DrawOK(false);
ReefAngel.LCD.DrawCancel(false);
}
break;
}
case OPT2:
{
ReefAngel.LCD.DrawOption(v, 0, MENU_START_COL+offset, MENU_START_ROW*4, unit, subunit, maxdigits);
ReefAngel.LCD.DrawOption(y, 1, MENU_START_COL+offset, MENU_START_ROW*6, unit, subunit, maxdigits);
if ( bDrawButtons )
{
ReefAngel.LCD.DrawOK(false);
ReefAngel.LCD.DrawCancel(false);
}
break;
}
case OK:
{
if ( bDrawButtons )
{
ReefAngel.LCD.DrawOption(v, 0, MENU_START_COL+offset, MENU_START_ROW*4, unit, subunit, maxdigits);
if ( ! bSingle )
ReefAngel.LCD.DrawOption(y, 0, MENU_START_COL+offset, MENU_START_ROW*6, unit, subunit, maxdigits);
ReefAngel.LCD.DrawOK(true);
ReefAngel.LCD.DrawCancel(false);
}
break;
}
case CANCEL:
{
if ( bDrawButtons )
{
ReefAngel.LCD.DrawOption(v, 0, MENU_START_COL+offset, MENU_START_ROW*4, unit, subunit, maxdigits);
if ( ! bSingle )
ReefAngel.LCD.DrawOption(y, 0, MENU_START_COL+offset, MENU_START_ROW*6, unit, subunit, maxdigits);
ReefAngel.LCD.DrawOK(false);
ReefAngel.LCD.DrawCancel(true);
}
break;
}
}
bRedraw = false;
bDrawButtons = false;
} // if bRedraw
if ( ReefAngel.Joystick.IsUp() )
{
bRedraw = true;
if ( sel == OPT1 )
{
v++;
if ( v > rangemax )
{
v = rangemin;
}
}
else if ( sel == OPT2 )
{
y++;
if ( y > rangemax )
{
y = rangemin;
}
}
}
if ( ReefAngel.Joystick.IsDown() )
{
bRedraw = true;
if ( sel == OPT1 )
{
v--;
if ( v < rangemin )
{
v = rangemax;
}
}
else if ( sel == OPT2 )
{
y--;
if ( y < rangemin )
{
y = rangemax;
}
}
}
if ( ReefAngel.Joystick.IsRight() )
{
bRedraw = true;
bDrawButtons = true; // only redraw the buttons if we are moving right or left
// move right, if we are on cancel, wrap around to opt1
sel++;
if ( bSingle && sel == OPT2 ) sel++; // advance again if single
if ( sel > CANCEL )
{
sel = OPT1;
}
}
if ( ReefAngel.Joystick.IsLeft() )
{
bRedraw = true;
bDrawButtons = true;
// move left, if we are on opt1, wrap around to cancel
sel--;
if ( bSingle && sel == OPT2 ) sel--;
if ( sel > CANCEL )
{
sel = CANCEL;
}
}
if ( ReefAngel.Joystick.IsButtonPressed() )
{
// only break when button pressed on ok or cancel
if ( sel == OK )
{
bDone = true;
bSave = true;
}
else if ( sel == CANCEL )
{
bDone = true;
}
}
} while ( ! bDone );
// return true saves the value, false ignores the value
return bSave;
}
If you add in the sections that are mentioned above (MenuEntry3() and SetupOption()), you should be good to go. Hopefully that code is a good example for you to follow.