Page 1 of 1

MoonPhase Display

Posted: Thu Apr 05, 2012 3:32 pm
by JNieuwenhuizen
Hi.

I am having a bit of a issues with displaying the MoonPhase.

The code I am using does not refer to it specifically, and I have no idea how to get it to look at the values.

Code: Select all

  //Start Moon Phase Display
  x += (16*4) + 8;
  y += MENU_START_ROW+3;
  if (ReefAngel.PWM.GetChannelValue(4) ==0) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"Off");
  else if(ReefAngel.PWM.GetChannelValue(4) >=1 && ReefAngel.PWM.GetChannelValue(4) < 5) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"New");
  else if(ReefAngel.PWM.GetChannelValue(4) >=5 && ReefAngel.PWM.GetChannelValue(4) < 10) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"Cresent");
  else if(ReefAngel.PWM.GetChannelValue(4) >=10 && ReefAngel.PWM.GetChannelValue(4) < 20) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"Half");
  else if(ReefAngel.PWM.GetChannelValue(4) >=20 && ReefAngel.PWM.GetChannelValue(4) < 30) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"Gibbous");
  else if(ReefAngel.PWM.GetChannelValue(4) >=30 && ReefAngel.PWM.GetChannelValue(4) < 45) ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,81,75,"Full");
  //End Display Moon Phase Display
This does refer to PWM Channel 4, that will be Moonlights. But I cannot define a PWM slope for Moonlights as it goes past 12h00 at night , so using this code to do the MoonPhase

Code: Select all

 MoonPWMValue=MoonPhase();
  if (hour()==22 || hour()==6)
    MoonPWMValue=PWMSlope(22,00,6,00,0,MoonPhase(),45,0);
  if (ChannelValue[LEDWhiteBlue]==1) MoonPWMValue=0;
  ReefAngel.PWM.SetChannel(4,MoonPWMValue);
  
    ChannelValue[LEDWhiteBlue]=PWMSlope(8,0,22,0,0,90,300,ChannelValue[LEDWhiteBlue]);
    ChannelValue[LEDWhiteBlue1]=PWMSlope(8,30,21,30,0,90,270,ChannelValue[LEDWhiteBlue1]);
    ChannelValue[LEDWhiteBlue2]=PWMSlope(9,0,21,0,0,90,240,ChannelValue[LEDWhiteBlue2]);
    ChannelValue[MixedLED]=PWMSlope(12,0,18,0,0,90,60,ChannelValue[MixedLED]);
  //ChannelValue[LEDMoonlights]=PWMSlope(22,0,11,59,0,10,0,ChannelValue[LEDMoonlights]);
  //ChannelValue[LEDMoonlights]=PWMSlope(00,0,7,0,10,45,240,ChannelValue[LEDMoonlights]);
I cannot "GetMoonPWMValue" , as it is not defined on RA_PWMClass

Any help would be appreciated

Re: MoonPhase Display

Posted: Thu Apr 05, 2012 3:44 pm
by rimai
Just use MoonPhase()
It should give you the correct value to display on screen.

Re: MoonPhase Display

Posted: Thu Apr 05, 2012 4:02 pm
by JNieuwenhuizen
Thank You

Now it gives a comiling error : 'class RA_PWM has no member named MoonPhase

Re: MoonPhase Display

Posted: Fri Apr 06, 2012 8:53 am
by rimai
Just use MoonPhase() and nothing else.

Re: MoonPhase Display

Posted: Sat Apr 07, 2012 7:55 am
by JNieuwenhuizen
Thank You, Its working now.

One question though, with the pwm functions, what is the diffenece between pwmslope and pwmparabola?

Re: MoonPhase Display

Posted: Sat Apr 07, 2012 11:49 am
by Sebyte
PWMslope gives a linear rise in the Led %. And PWMparabola gives a bell curve which is more realistic like the way the sun passes through the day.

Re: MoonPhase Display

Posted: Sat Apr 07, 2012 11:52 am
by JNieuwenhuizen
Thank You Sebyte, Will use Parabola rather