Custom menu question
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Custom menu question
I am going to try my hand at building a custom menu. One of the entries that I would like to have is the ability to manually turn on one set of lights. Could you advise me on how to do this?
Thanks!
Thanks!
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
Re: Custom menu question
I use this:
My lights are on Port 3 and 4.
You can move the 1s to whatever port you have your lights.
Code: Select all
void MenuEntry4()
{
ReefAngel.Relay.RelayMaskOn|=B00001100; //Override Lights On;
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
You can move the 1s to whatever port you have your lights.
Roberto.
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
Thanks Roberto. I put in the code and when I tried to compile it, it gave me an error message that the sketch was too big. I can make it work if I take out the 4th menu entry - set time and date. I don't really don't need it but what if I want to add another menu entry? Like a nother wavmaker mode? Will it be too big again? Why is my code so big?
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
This was my running pde file - all I added were the custom menu lines. Here is the code:
Code: Select all
/* The following features are enabled for this PDE File:
#define DateTimeSetup
#define DisplayLEDPWM
#define RelayExp
#define wifi
#define VersionMenu
#define PWMEXPANSION
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 4
#define CUSTOM_MAIN
#define NUMBERS_8x16
#define COLORS_PDE
*/
#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Wifi.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>
#include <ReefAngel_Salinity.h>
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding Time";
prog_char menu1_label[] PROGMEM = "Water Change";
prog_char menu2_label[] PROGMEM = "Lights On";
prog_char menu3_label[] PROGMEM = "Set time and date";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label};
void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Feeding Time");
ReefAngel.FeedingModeStart();
}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Water Change");
ReefAngel.WaterChangeModeStart();
}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Lights On");
ReefAngel.Relay.RelayMaskOn|=B00000001; //Override Lights On;
ReefAngel.DisplayedMenu=RETURN_MAIN_MODE;
}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Set time and date");
ReefAngel.SetupDateTime();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
byte PWMChannel[]={
0,0,0,0,0,0};
void DrawCustomMain()
{
//Top Banner
ReefAngel.LCD.DrawText(COLOR_BLACK, COLOR_SKYBLUE, 9, 2, " Harry's 120H Reef ");
ReefAngel.LCD.DrawDate(6, 123);
pingSerial();
// Display Temp Text
ReefAngel.LCD.DrawText(0,255,8,12,"Temp");
// Display the T1 temp value
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp1, 10);
ReefAngel.LCD.Clear(255, 4, 22, 37, 38);
ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 4, 22, text, Num8x16);
pingSerial();
// Display Salt Text
ReefAngel.LCD.DrawText(0,255,54,12,"Salt");
// Display Salt Value
ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
ReefAngel.LCD.Clear(255, 52, 22, 75, 38);
ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 52, 22, text, Num8x16);
pingSerial();
// Display pH Text
ReefAngel.LCD.DrawText(0,255,112,12,"pH");
// Display pH Value
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.Clear(255, 94, 22, 106, 38);
ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE, 255, 94, 22, text, Num8x16);
pingSerial();
// Display Actinic Percentage Text
ReefAngel.LCD.DrawText(0,255,8,40,"Blue LED %");
// Display Actinic Percentage Value
ConvertNumToString(text, PWMChannel[1], 1);
strcat(text," ");
ReefAngel.LCD.DrawText(0, 255, 80, 40, text);
pingSerial();
// Display Daylight Percentage Text
ReefAngel.LCD.DrawText(0,255,8,50,"White LED %");
// Display Daylight Percentage Value
ConvertNumToString(text, PWMChannel[0], 1);
strcat(text," ");
ReefAngel.LCD.DrawText(0, 255, 80, 50, text);
pingSerial();
// Display Moonlight Phase Text
ReefAngel.LCD.DrawText(0,255,8,60,"Moonlight ");
// Display Moonlight Phase Value
ConvertNumToString(text, PWMChannel[2], 1);
strcat(text," ");
ReefAngel.LCD.DrawText(0, 255, 80, 60, text);
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(13, 97, TempRelay);
pingSerial();
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(13, 109, TempRelay);
pingSerial();
}
void DrawCustomGraph()
{
}
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = B00110000;
ReefAngel.FeedingModePortsE[0] = B00110000;
ReefAngel.WaterChangePorts = B00111100;
ReefAngel.WaterChangePortsE[0] = B00110011;
ReefAngel.OverheatShutoffPorts = B00000011;
ReefAngel.LightsOnPorts = B00011110;
// Ports that are always on
ReefAngel.Relay.On(Port3);
ReefAngel.Relay.On(Port4);
ReefAngel.Relay.On(Box1_Port1);
ReefAngel.Relay.On(Box1_Port2);
// Wavemaker timer
ReefAngel.Timer[1].SetInterval(random(15,90));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port6);
}
void loop()
{
ReefAngel.ShowInterface();
// Specific functions
// T5 White
ReefAngel.StandardLights(Port1,10,30,20,0);
//T5 Blue
ReefAngel.StandardLights(Port2,9,30,20,45);
//LED Blue
ReefAngel.StandardLights(Port7,9,0,21,15);
//LED White
ReefAngel.StandardLights(Port8,10,0,20,30);
//Heater
ReefAngel.StandardHeater(Box1_Port3,773,783);
//Refugium
ReefAngel.StandardLights(Box1_Port4,21,0,7,0);
//Fan
ReefAngel.StandardLights(Box1_Port7,8,30,21,0);
//LED Moonlight
ReefAngel.StandardLights(Box1_Port8,20,45,7,30);
// Channel 0 = White
PWMChannel[0]=PWMSlope(10,0,20,30,0,100,30,PWMChannel[0]); // calculate slope %
// Channel 1 = Blue
PWMChannel[1]=PWMSlope(9,0,21,15,0,100,30,PWMChannel[1]); // calculate slope %
// Channel 2= Moonlights
PWMChannel[2]=MoonPhase(); // calculate moon phase %
// this section sends the data to the PWM expansion module
for (int a=0;a<4;a++)
ReefAngel.PWM.Expansion(a,int(2.55*PWMChannel[a]));
// Wavemaker
if ( ReefAngel.Timer[1].IsTriggered() )
{
ReefAngel.Timer[1].SetInterval(random(15,90));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Toggle(Port5);
ReefAngel.Relay.Toggle(Port6);
ReefAngel.Relay.Toggle(Box1_Port5);
ReefAngel.Relay.Toggle(Box1_Port6);
}
}
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
And my features file as well:
Code: Select all
// AutoGenerated file by RAGen (v1.1.0.124), (10/22/2011 19:43)
/*
* Copyright 2010-11 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 SIMPLE_MENU
#define DateTimeSetup
#define DisplayLEDPWM
#define wifi
#define RelayExp
#define InstalledRelayExpansionModules 1
#define PWMEXPANSION
#define WDT
#define SALINITYEXPANSION
#define CUSTOM_MENU
#define CUSTOM_MENU_ENTRIES 4
#define CUSTOM_MAIN
#define NUMBERS_8x16
#define COLORS_PDE
#endif // __REEFANGEL_FEATURES_H__
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
Yes, I do. I do not have it running yet but it's next on the to do list... 
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
Re: Custom menu question
Ok, so you can remove the date/time setup. It takes quite a bit of memory.
You can use the wifi very easily to update the time.
Make sure to also remove this line in the features file:
You can use the wifi very easily to update the time.
Make sure to also remove this line in the features file:
Code: Select all
#define DateTimeSetup
Roberto.
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
I did try that and the pde will compile. The time/date is big - That's what I thought. But, if I want to add another menu entry of any kind, will the code be too big again or will it be okay(being that the t/d function is huge)?
-
rimai
- Posts: 12857
- Joined: Fri Mar 18, 2011 6:47 pm
-
binder
- Posts: 2865
- Joined: Fri Mar 18, 2011 6:20 pm
- Location: Illinois
- Contact:
Re: Custom menu question
Adding menu entries does not increase code size by a whole lot. The more complex the function is, the larger the code size increase will be. I cannot give you an example, just a general guideline.
-
maxxdog21
- Posts: 34
- Joined: Thu Dec 08, 2011 3:19 pm
Re: Custom menu question
I figured as much. The time/date code segment must be big, even if it seems to be a simple function.
-
binder
- Posts: 2865
- Joined: Fri Mar 18, 2011 6:20 pm
- Location: Illinois
- Contact:
Re: Custom menu question
yes it is big. there is a lot that has to be done with updating the screen on the changes. so it does require some space.
