Sunlocation?

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
madweazl
Posts: 44
Joined: Tue Dec 03, 2013 3:08 am
Location: Fredericksburg, VA

Re: Sunlocation?

Post by madweazl »

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.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Sunlocation?

Post by lnevo »

When you run the Init function you set the coordinates. If you don't specify it will use GBR coordinates by default
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Sunlocation?

Post by lnevo »

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:

Code: Select all

SunLocation *sl = new SunLocation();
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:

Code: Select all

SunLocation sl;
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.
User avatar
madweazl
Posts: 44
Joined: Tue Dec 03, 2013 3:08 am
Location: Fredericksburg, VA

Re: Sunlocation?

Post by madweazl »

lnevo wrote:When you run the Init function you set the coordinates. If you don't specify it will use GBR coordinates by default
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.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Sunlocation?

Post by lnevo »

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.
User avatar
madweazl
Posts: 44
Joined: Tue Dec 03, 2013 3:08 am
Location: Fredericksburg, VA

Re: Sunlocation?

Post by madweazl »

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.ino

Code: 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;
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?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Sunlocation?

Post by lnevo »

Yes, what I do is if my dim % is >= the percent they go off, the. i turn the relay on. Otherwise they are off.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Sunlocation?

Post by lnevo »

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.
Post Reply