Custom Menu Generator

Community contributed apps
User avatar
Posts: 5349
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Jun 14, 2013 1:23 pm
Can you post the full code?
User avatar
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL
PostPosted: Fri Jun 14, 2013 1:37 pm
Here you go.

Code: Select all
a#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 <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

////// Place global variable code below here
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Feeding";
prog_char menu1_label[] PROGMEM = "Water Change";
prog_char menu2_label[] PROGMEM = "Accilmate";
prog_char menu3_label[] PROGMEM = "Lights On";
prog_char menu4_label[] PROGMEM = "Lights Off";
prog_char menu5_label[] PROGMEM = "Calibrate PH";
prog_char menu6_label[] PROGMEM = "Calibrate Water Level";
prog_char menu7_label[] PROGMEM = "Clear ATO ";
prog_char menu8_label[] PROGMEM = "Clear Overheat";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_label, menu8_label  };

void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");ReefAngel.FeedingModeStart();

}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");ReefAngel.WaterChangeModeStart();

}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");ReefAngel.Relay.Override(Port6, ~bitRead(ReefAngel.Relay.RelayMaskOff, Port6Bit)*2);
ReefAngel.DisplayedMenu = RETURN_MAIN_MODE;
}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");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 MenuEntry5()
{
ReefAngel.DisplayMenuEntry("Item 5");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 MenuEntry6()
{
ReefAngel.DisplayMenuEntry("Item 6");ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;

}
void MenuEntry7()
{
ReefAngel.DisplayMenuEntry("Item 7");{
  ReefAngel.SetupCalibrateWaterLevel();
  ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
}
void MenuEntry8()
{
ReefAngel.DisplayMenuEntry("Item 8");ReefAngel.ATOClear();

}
void MenuEntry9()
{
ReefAngel.DisplayMenuEntry("Item 9");ReefAngel.OverheatClear();

}

unsigned long ATOUpdate=0;
////// Place global variable code above here


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Initialize the menu
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 825 );



// Ports that are always on
ReefAngel.Relay.On( Port4 );

////// Place additional initialization code below here


////// Place additional initialization code above here
}

void loop()
{
ReefAngel.StandardLights( Port1,12,0,22,0 );
ReefAngel.StandardLights( Port2,13,0,21,0 );
ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port1 ) );
ReefAngel.StandardLights( Port7,13,0,21,0 );
ReefAngel.Relay.Set(Port5,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
ReefAngel.Relay.Set(Port8,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
ReefAngel.WaterLevelATO(Port6,720,30,30); // Enable ATO the ATO
if (ReefAngel.Relay.Status(Port5)) // Check to see if port 5 is on and update time is empty
{
ATOUpdate = now(); // If so, set the update time to now
}

if (now() - ATOUpdate < 120) // If it hasnt been 120 seconds turn off the port
{
ReefAngel.WaterLevelATO(Port6,720,0,1);
}
ReefAngel.PWM.SetActinic(MyCustomWave(50));
if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(0);
if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);
if (hour()<12 || hour()>=22) ReefAngel.PWM.SetActinic(30);
////// Place your custom code below here


////// Place your custom code above here

// This should always be the last line
ReefAngel.Portal( "Sacohen","Seth0310" );
ReefAngel.ShowInterface();
}

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,66, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel() );
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
byte MyCustomWave(byte maxspeed)
{
static byte randomspeed=0;
if (now()%11<5)
{
return randomspeed;
}
else if (now()%11>=5 && now()%11<10)
{
return maxspeed;
}
else
{
randomspeed=random(35,maxspeed);
return 0;
}
}

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Jun 14, 2013 1:41 pm
Try this:
Code: Select all
void MenuEntry4()
{
  ReefAngel.LightsOn();
}
void MenuEntry5()
{
  ReefAngel.LightsOff();
}
Roberto.
User avatar
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL
PostPosted: Fri Jun 14, 2013 4:21 pm
Tried that Roberto and same thing. Nothing happened. :(

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Jun 14, 2013 4:26 pm
It's showing your ports are on. Nothing is going to happen when ports are on. LightsOn() would override on and LightsOff() just cancels the override. It doesn't actually override it off.
So, if your lights are already on, overriding it on would do nothing.
Roberto.
User avatar
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL
PostPosted: Fri Jun 14, 2013 5:42 pm
Ok. Sorry. I thought it would over ride then to turn off if they were on too.
They are working properly.
The other code I had probably worked too.
Previous

Return to Apps

Who is online

Users browsing this forum: No registered users and 1 guest

cron