MoonPhase

New members questions
Post Reply
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

MoonPhase

Post by dtzreef »

Hi everyone, Just to clarify a few things, I just set up my wifi and I have a slow blinking green light and I can see my params on the Portal, am I good? I thought I read somewhere that I should get a solid green light. Also I have two moon lights attached to the PWM channels with "moonphase" set in my code, do the moon lights follow some sort of pattern (phase)? When I pull up the portal i get different pwm % almost everytime. Is this correct?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: MoonPhase

Post by rimai »

slow blinking is good.
Can you post the code?
Roberto.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: MoonPhase

Post by dtzreef »

I will when I get home tonight. At work today. Yes, I am on Reef Angel at work ;) What can ya do?
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: MoonPhase

Post by dtzreef »

Hey Roberto, here is the code I am running. Now I am having another problem, It seems as though my wifi is timing out or something. When I log into Portal it shows "unreachable Address". I thought I finally did something right without your help but, here I am again, at your mercy. So, as you are dissecting my code, would you find what I did wrong with the moonphase and wifi. Thank you so much!!!

Dave

#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_Colors.h>
#include <RA_CustomColors.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>

byte wmport=Port5;
boolean wmdelay=false;


#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 = "Lights On";
prog_char menu7_label[] PROGMEM = "Lights Off";

PROGMEM const char *menu_items[] = {
menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label, menu7_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.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE = ReefAngel.LightsOnPortsE;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}

void MenuEntry7()
{
ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}

void DrawCustomMain()
{

ReefAngel.LCD.DrawDate(6, 120);
ReefAngel.LCD.DrawLargeText(COLOR_DARKTURQUOISE, COLOR_WHITE, 4, 4 , "DTZ REEF ANGEL");
ReefAngel.LCD.Clear(COLOR_MAROON, 1, 13, 132, 13);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 75, 119, 75);
ReefAngel.LCD.Clear(COLOR_MAROON, 10, 118, 119, 118);
pingSerial();


ReefAngel.LCD.DrawText(COLOR_GOLDENROD, COLOR_WHITE, 8, 15, "Main Tank:");
char text[7];
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
pingSerial();
ReefAngel.LCD.DrawText(COLOR_GOLDENROD, DefaultBGColor, 88, 15, text);
pingSerial();

ReefAngel.LCD.DrawText(COLOR_MEDIUMSEAGREEN, COLOR_WHITE, 50, 46, "pH:");
ConvertNumToString(text, ReefAngel.Params.PH, 100);

ReefAngel.LCD.DrawText(PHColor, DefaultBGColor, 88, 46, text);
pingSerial();

ReefAngel.LCD.DrawText(COLOR_RED, COLOR_WHITE,8,25,"Room Temp:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_RED, 88, 25, 10);

ReefAngel.LCD.DrawText(COLOR_DARKORCHID, COLOR_WHITE,8,36,"Refugium:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], T2TempColor, 88, 36, 10);

pingSerial();
// Display arrows for Wavemaker
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor, 38, 57,"WAVE FLOW:");
if (bitRead(ReefAngel.Relay.RelayData,Port5-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67,"----->"); //port 5 on
else if (bitRead(ReefAngel.Relay.RelayData,Port6-1)==1) ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67,"<-----"); //port 6 on
else ReefAngel.LCD.DrawText(APColor,DefaultBGColor, 49, 67," 00000 "); //port5 and port 6 off, wavemaker delay
//show the timer for wavemaker
int t=ReefAngel.Timer[1].Trigger-now();
if (t>=0)
ReefAngel.LCD.Clear(255,105,64,135,74);
ReefAngel.LCD.DrawText(APColor, COLOR_KHAKI,105,64,t);
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 = Port2Bit | Port5Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port7Bit;
ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
randomSeed(analogRead(0));
ReefAngel.Timer[1].SetInterval(random(30,45));
ReefAngel.Timer[1].Start();
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
InternalMemory.OverheatTemp_write( 805 );
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port2);
ReefAngel.Relay.On(Port8);
}

void loop()
{
// Specific functions
ReefAngel.StandardATO( Port1,600 );
ReefAngel.Relay.DelayedOn( Port2,5 );
ReefAngel.StandardLights( Port3,9,0,21,0 );
ReefAngel.StandardLights( Port4,10,0,20,0 );
ReefAngel.StandardHeater( Port7,770,790 );
ReefAngel.PWM.SetDaylight( MoonPhase() );
ReefAngel.PWM.SetActinic( MoonPhase() );
//wavemaker timers and slow down at night
if ( ReefAngel.Timer[1].IsTriggered() )
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
ReefAngel.Timer[1].SetInterval(60); // wm night delay
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
ReefAngel.Timer[1].SetInterval(20); // short wave
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
//8a-9p normal wave settings
ReefAngel.Timer[1].SetInterval(random(35,50));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Toggle(Port5);
if bitRead(ReefAngel.Relay.RelayData,Port5-1) ReefAngel.Relay.Off(Port6);
else ReefAngel.Relay.On(Port6);
}
}
ReefAngel.Portal("dtzreef");
ReefAngel.ShowInterface();
ReefAngel.LCD.BacklightOn();
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: MoonPhase

Post by rimai »

You code looks good. Why do you think there is something wrong?
The moonphase for today is 31%. Isn't it what it is showing on screen for you?
It changes daily to follow the moon cycle.
Did you try removing the wifi and replugging it?
Roberto.
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: MoonPhase

Post by dtzreef »

Great!!! So the moonphase does change daily. Cool. I will try the wifi thing. Thanks again!
dtzreef
Posts: 50
Joined: Sat Jul 14, 2012 8:58 pm

Re: MoonPhase

Post by dtzreef »

Well, wifi is up and running. Thank you again! (I'm sure not the last time). Have a great night.
Post Reply