Sunlocation?
Re: Sunlocation?
Where are the sunrise/sunset times coming from? I see GPS mentioned but don't understand where the information is being pulled from in the code.
Re: Sunlocation?
When you run the Init function you set the coordinates. If you don't specify it will use GBR coordinates by default
Re: Sunlocation?
I think you have to set the GPS through the Init function.
There is a "Constructor" function for the SunLocation class, but I think the way we use it, it's never called.
Typically in C++ you use pointers and a constructor to do the following:
Notice the * that means we're pointing to a location in memory and the new function returns the memory address of a newly created SunLocation class. Since we're a bit more basic, we never actually run a constructor when you do this:
So with that you'd have to run the Init in order to set the coordinates. I may modify the class to have an Init() with no args so you can use the defaults.
For the record the code is in Libraries/SunLocation and you can see in SunLocation.cpp the first two functions, the first being the constructor I mentioned and the second being the Init function.
There is a "Constructor" function for the SunLocation class, but I think the way we use it, it's never called.
Typically in C++ you use pointers and a constructor to do the following:
Code: Select all
SunLocation *sl = new SunLocation();
Code: Select all
SunLocation sl;
For the record the code is in Libraries/SunLocation and you can see in SunLocation.cpp the first two functions, the first being the constructor I mentioned and the second being the Init function.
Re: Sunlocation?
I see reference to Great Barrier Reef in there but nothing else; is that just a reference? I dont have any issues using that lat/long, I was just curious. I'm not even going to try and make sense out of the moon library yet; that one left me googly eyed.lnevo wrote:When you run the Init function you set the coordinates. If you don't specify it will use GBR coordinates by default
Re: Sunlocation?
Yeah I'd say for now it only works as a reference but yes feel free to use those with the Init function with those values.
Re: Sunlocation?
I'd like to get this going but my lights dont dim to 0 (SBReef basic black boxes) so I use relays 5 and 6 for on/off functionality. Is there a way to tie that in so the relay and rise/set functions work together?lnevo wrote:Here is the excerpt from my code that references SunLocation. I think it's pretty self explanatory. One thing to keep in mind is that if sun.UseMemory==true, which is the default, then it will write the Daylight on/off times each day.
$ egrep -i 'SunLocation|sun\.' Wizard65.inoCode: Select all
#include <SunLocation.h> SunLocation sun; sun.Init(InternalMemory.read_int(Mem_I_Latitude), InternalMemory.read_int(Mem_I_Longitude)); sun.SetOffset(riseOffset,(acclDay*acclRiseOffset),setOffset,(-acclDay*acclSetOffset)); // Bahamas sun.CheckAndUpdate(); // Calculate today's Sunrise / Sunset tide.SetSpeed(PWMSlope(sun.GetRiseHour()-1,sun.GetRiseMinute(), sun.GetSetHour(),sun.GetSetMinute(),nightSpeed+tideMin,vtSpeed,120,nightSpeed+tideMin)); } else if (!sun.IsDaytime() && nightRF) { if (sun.IsDaytime() && (now()+offset)%repeat==0) { sprintf(buf, "%02d:%02d", sun.GetRiseHour(), sun.GetRiseMinute()); sprintf(buf, "%02d:%02d", sun.GetSetHour(), sun.GetSetMinute()); x+=36;
Re: Sunlocation?
Yes, what I do is if my dim % is >= the percent they go off, the. i turn the relay on. Otherwise they are off.
Re: Sunlocation?
The other thing you can do is set the start and end percentage to be when your lights go off. This way you get the full photoperiod.