need help with custom menu.

Do you have a question on how to do something.
Ask in here.
Post Reply
kevin36
Posts: 7
Joined: Sun Mar 04, 2012 7:42 am

need help with custom menu.

Post by kevin36 »

When I go to menu and press on "PH Calibration" it bring me right back to the main menu, only feeding work but the rest just bring back to the main menu.I did load the Internal Mem prior to this. here' my code:

Code: Select all

// This version designed for v0.9.0 or later

/* The following features are enabled for this File: 
#define DisplayImages
#define DateTimeSetup
#define VersionMenu
#define DisplayLEDPWM
#define RemoveAllLights
#define SIMPLE_MENU
#define CUSTOM_MENU
#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 AutoTopOff        1
    #define Daylight          2
    #define Actinic           3
    #define StandardLight     4
    #define Moonlight         5
    #define Heater            6
    #define Skimmer           7
    #define Return            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();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayVersion();
}
void MenuEntry8()
{
ReefAngel.Relay.On(Port7);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Port7);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 112);
    pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
    ReefAngel.LCD.DrawGraph(5, 5);
}


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
    
    ReefAngel.FeedingModePorts = Port8Bit;
    ReefAngel.WaterChangePorts = Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;

    // Ports that are always on
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardATO(Port1,5);
    ReefAngel.StandardLights(Port2,13,30,22,0);
    ReefAngel.StandardLights(Port3,13,30,22,0);
    ReefAngel.StandardLights(Port4,15,0,21,30);
    ReefAngel.StandardLights(Port5,21,30,9,0);
    ReefAngel.StandardHeater(Port6,885,840);

    ReefAngel.PWM.SetActinic(PWMSlope(13,30,22,0,30,60,60,20));
    ReefAngel.PWM.SetDaylight(PWMSlope(13,30,22,0,20,50,60,20));


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

Re: need help with custom menu.

Post by rimai »

I'm getting the same thing :(
Let me see if I can find out anything.
Roberto.
kevin36
Posts: 7
Joined: Sun Mar 04, 2012 7:42 am

Re: need help with custom menu.

Post by kevin36 »

Thanks
Can you help me build my pde .I just want to add couple menu to my pde
, on/off skimmer and on/off lighting (port 2,3,4).
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: need help with custom menu.

Post by rimai »

I think I'm gonna need Curt's help on this one :(
None of the menus work.
Roberto.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: need help with custom menu.

Post by binder »

There were several errors with the INO file when I tried to compile it (using the Features that were listed in the comments). I fixed it up and everything is working now. The reason why you were having issues was you did not specify how many menu entries there were. If that is left off, the libraries assume that there is only 1 menu entry and will only process 1 entry. You will still display all the entries but only 1 is active.
I also had to remove the "RemoveAllLights" define because that will not work with PWM stuff enabled and I removed the "SIMPLE_MENU" define because it was not needed since CUSTOM_MENU overrides it.

With that being said, you just need to update your ReefAngel_Features.h file and replace it with this:

Code: Select all

// AutoGenerated file by RAGen (v1.2.2.162), (02/19/2012 17:34)

/*
 * Copyright 2010-12 Curt Binder
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__

#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


#endif  // __REEFANGEL_FEATURES_H__
And for completeness, here is the INO file:

Code: Select all

// This version designed for v0.9.0 or later

/* 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 AutoTopOff        1
    #define Daylight          2
    #define Actinic           3
    #define StandardLight     4
    #define Moonlight         5
    #define Heater            6
    #define Skimmer           7
    #define Return            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();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayVersion();
}
void MenuEntry8()
{
ReefAngel.Relay.On(Port7);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry9()
{
ReefAngel.Relay.Off(Port7);
ReefAngel.Relay.Write();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}

void DrawCustomMain()
{
    // the graph is drawn/updated when we exit the main menu &
    // when the parameters are saved
    ReefAngel.LCD.DrawDate(6, 112);
    pingSerial();
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue());
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor(15, 60, ReefAngel.Params);
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

void DrawCustomGraph()
{
    ReefAngel.LCD.DrawGraph(5, 5);
}


void setup()
{
    ReefAngel.Init();  //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
    
    ReefAngel.FeedingModePorts = Port8Bit;
    ReefAngel.WaterChangePorts = Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;

    // Ports that are always on
    ReefAngel.Relay.On(Port7);
    ReefAngel.Relay.On(Port8);
}

void loop()
{
    // Specific functions
    ReefAngel.StandardATO(Port1,5);
    ReefAngel.StandardLights(Port2,13,30,22,0);
    ReefAngel.StandardLights(Port3,13,30,22,0);
    ReefAngel.StandardLights(Port4,15,0,21,30);
    ReefAngel.StandardLights(Port5,21,30,9,0);
    ReefAngel.StandardHeater(Port6,885,840);

    ReefAngel.PWM.SetActinic(PWMSlope(13,30,22,0,30,60,60,20));
    ReefAngel.PWM.SetDaylight(PWMSlope(13,30,22,0,20,50,60,20));


    ReefAngel.ShowInterface();
}

Now it works great for me.
kevin36
Posts: 7
Joined: Sun Mar 04, 2012 7:42 am

Re: need help with custom menu.

Post by kevin36 »

Many thanks to binder and rimai ,I'll try tomorrow.
Post Reply