Regarding scheduler, if we go the non-interrupt way, I'm thinking of having a check every second that will go through a list of events. If the time is right, flip the relay else, move on. Something as basic as this should be very easy to implement. Ideally we want an interrupt driven scheduler, but that will probably require some more coding, and to be honest I don't know if I want my lights to interrupt the ATO Off or something more important.
Just a general idea in my head.[\QUOTE]
See that's exactly what I was going for and I feel thatswhat my code does. It checks every loop weather the alarm time has passed or not. and I'm not quiet sure I"m following on w hat you mean by an "interrupt driven scheduler." maybe i'm missing a concept here.
MA70Snowman, what you have can be simplified a bit by combining the HR and MIN into a minute_since_midnight counter and just check if it is the right minute to turn on/off a given relay. Other than that, you probably want some struct Event/Alarm that holds time on, time off and relay, and then a list of all the alarms. Otherwise it will be one big *** if/else statement
I THINK i see where you're going with this line of thought, however even if you do a minute-since-midnight counter, thats an additional variable/s as well as another check statement that would replace the current check statement. Currently I total there's 8 check statements, 4 if ON time is later (closer to midnight) then the OFF time, and 4 for the opposite.
In some cases like the ATO it may be simpler to think of it as a start time and a length to run. If you have a power failure when it is suppose to come on no big deal. It will cycle the next time (ok maybe the next day). This would work great if we had an interrupt handler.
Light on the other hand should have an on and off time and get reset in the event of a power failure.
Can you break the list down and just check lights (and a few others) and turn them on if between on and off time.
see that's a concept I hadn't thought of. ON time, and then a RUN time. that ideally could be much simpler to implement.
and talking about power failures. that's the reason I have the large check in the SETUP function. if there is a power failure. when Power is restored, it performs an indepth check of what the time/alarm status is, and this will restore all functions to where they should be.
One more thought. ATO is what exactly? it's 5 am and still asleep.