I'm not sure how best to calculate offsets against the minutes, however, as the internal memory stores the hours and minutes separately, and an offset that would take the minutes higher than 60 or lower than 0 would probably cause a problem.
If I were using a PWM code to calculate the light level for a given time, how could I modify this to calculate the correct hour and minute values if I want to offset it by 30 minutes, and don't know whether that will take me past an hour threshhold?
Code: Select all
PWMSmoothRampHighRes(InternalMemory.StdLightsOnHour_read(), InternalMemory.StdLightsOnMinute_read(), InternalMemory.StdLightsOffHour_read(), InternalMemory.StdLightsOffMinute_read(), 0, 100, 120, 0);
Is there a function somewhere that can accommodate this, or can someone help me with some custom code to take the existing hour and minute variables and calculate a new variable based on the offset?
something like
Code: Select all
if (InternalMemory.StdLightsOnMinute_read()+Offset>60)
{
byte newMinutes=InternalMemory.StdLightsOnMinute_read()-60;
byte newHour=InternalMemory.StdLightsOnHour_read()+1
for (int a=0;a<5;a++) {
if newMinutes > 60 (newMinutes=newMinutes-60; newHour=newHour+1;)
};
};
This doesn't seem terribly efficient, and would require another function to accommodate offsets going the other way, and potentially another to handle offsets that push the hour past midnight.