How do I trigger a condition based on the moon phase labels? Or are the labels based on a number I can query? I have a series of images that look like the moon phases and I want to load the correct picture based on the phase of the moon. For instance, is it like this....
if (MoonPhaseLabel()=="New Moon") New(5,50);
The "New(5,50)" is a function that draws the picture. It compiles but doesn't work. The picture functions work fine. I'm guessing the labels have a spacing to them I need to get just right. I tried to find them in the libraries, but couldn't locate it.
Thanks for your help,
Jon
Moon labels
Re: Moon labels
I think in your case you better off just copy the function and do what you want instead of comparing.
char array comparisons are tricky and are based on the size of the array.
The function is in Globals.cpp
Here is the code for the function:
Just make it a void function instead of char* and replace the return "...." with your own function.
char array comparisons are tricky and are based on the size of the array.
The function is in Globals.cpp
Here is the code for the function:
Code: Select all
char* MoonPhaseLabel()
{
int m,d,y;
int yy,mm;
long K1,K2,K3,J;
double V;
byte PWMvalue;
m = month();
d = day();
y = year();
yy = y-((12-m)/10);
mm = m+9;
if (mm>=12) mm -= 12;
K1 = 365.25*(yy+4712);
K2 = 30.6*mm+.5;
K3 = int(int((yy/100)+49)*.75)-38;
J = K1+K2+d+59-K3;
V = (J-2451550.1)/29.530588853;
V -= floor(V);
if (V<0) V++;
if (V<0.0625) return "New Moon";
else if (V<0.1875) return "Waxing Crescent";
else if (V<0.3125) return "First Quarter";
else if (V<0.4375) return "Waxing Gibbous";
else if (V<0.5625) return "Full Moon";
else if (V<0.6875) return "Waning Gibbous";
else if (V<0.8125) return "Last Quarter";
else if (V<0.9375) return "Waning Crescent";
else return "New Moon";
}
Roberto.