Ive been writing this code to add some custom menus to my android app to access the reef angel.
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 <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 <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
#include <avr/pgmspace.h>
prog_char menu1_label[] PROGMEM = "Feeding";
prog_char menu2_label[] PROGMEM = "Water Change";
prog_char menu3_label[] PROGMEM = "Wavemaker";
prog_char menu4_label[] PROGMEM = "Overheat clear";
prog_char menu5_label[] PROGMEM = "PH Calibration";
prog_char menu6_label[] PROGMEM = "White Lights";
prog_char menu7_label[] PROGMEM = "Blue Lights";
prog_char menu8_label[] PROGMEM = "Lunar Lights";
prog_char menu9_label[] PROGMEM = "date/Time";
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();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry2()
{
ReefAngel.WaterChangeModeStart();
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry3()
{
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
void MenuEntry4()
{
ReefAngel.OverheatClear();
ReefAngel.DisplayMenuEntry("Clear Overheat");
}
void MenuEntry5()
{
ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry6()
{
ReefAngel.Relay.On (Port3);
}
void MenuEntry7()
{
ReefAngel.Relay.On (Port4);
}
void MenuEntry8()
{
ReefAngel.Relay.Toggle(255 ,231);
ReefAngel.DisplayMenuEntry("Moon cycle ");
}
void MenuEntry9()
{
ReefAngel.SetupDateTime();
7eefAngel.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( Port1 );
ReefAngel.Relay.On( Port7 );
void setup()
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.MoonLights( Port2 );
ReefAngel.DayLights( Port3 );
ReefAngel.ActinicLights( Port4 );
ReefAngel.WavemakerRandom1( Port5,10,60 );
ReefAngel.WavemakerRandom2( Port6,5,10 );
ReefAngel.StandardHeater( Port8 );
ReefAngel.PWM.Channel0PWMSlope();
ReefAngel.PWM.Channel1PWMSlope();
ReefAngel.PWM.Channel2PWMSlope();
ReefAngel.PWM.Channel3PWMSlope();
ReefAngel.PWM.Channel4PWMSlope();
////// Place your custom code below here
pinMode(lowATOPin,OUTPUT);
if (InternalMemory.LEDPWMActinic_read()<=100)
analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
else
analogWrite(lowATOPin,MoonPhase()*2.55);
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "Dctrojan" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 39, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// pH Expansion
ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,76, "PHE:" );
ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,76, 100 );
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
}/code]
I was wondering if someone could help me with menu item #8? I would like to be able to toggle the lunar hub to follow the moonphase on and off.
It would also be great if I could also control the lunar hub dimmer through this function as well.
By no means is this a finished code, just really a starting point. im having trouble entering the toggle function, im not sure how to enter in the location and Bit.
I ultimately would like to also lengthen the feeding time as well if anyone knows how to do this.
also eventually i would like to be able to control the circulation pumps timers.
thanks for all the help and advice.