First note, you will want to get the value before you set the PWM.
Code: Select all
ActinicPWMValue=PWMSlope(22,00,7,00,0,MoonPhase(),60,ActinicPWMValue);
ReefAngel.PWM.SetActinic(ActinicPWMSlope);
DaylightPWMValue=PWMSlope(22,00,7,00,0,MoonPhase(),60,DaylightPWMValue);
ReefAngel.PWM.SetDaylight(DaylightPWMValue);
I'm not sure how well PWMSlope works crossing over midnight. It may have to be broken into 2 groups with an IF statement:
Code: Select all
if ( hour() >= 22 && hour() <= 23 )
{
// from 22:00 to 23:59
ActinicPWMValue=PWMSlope(22,0,23,59,0,MoonPhase(),0,ActinicPWMValue);
ReefAngel.PWM.SetActinic(ActinicPWMSlope);
DaylightPWMValue=PWMSlope(22,0,23,59,0,MoonPhase(),0,DaylightPWMValue);
ReefAngel.PWM.SetDaylight(DaylightPWMValue);
} else if ( hour() >= 0 && hour() < 7 )
{
// from 00:00 to 6:59
ActinicPWMValue=PWMSlope(0,0,7,0,0,MoonPhase(),0,ActinicPWMValue);
ReefAngel.PWM.SetActinic(ActinicPWMSlope);
DaylightPWMValue=PWMSlope(0,0,7,0,0,MoonPhase(),0,DaylightPWMValue);
ReefAngel.PWM.SetDaylight(DaylightPWMValue);
}
I took out the duration because I'm not quite sure how well it would work in those regards.
This is only a framework / start to solving the problem. More thought will need to be put into it. Bottom line, you will need to do the slope in 2 pieces....1 up to midnight and the other from midnight to your end time. The tricky part is to get the slope working. Maybe this will spark some ideas for you or others.