This idea might be worth a try..
http://www.picbasic.co.uk/forum/show...1881#post91881
This idea might be worth a try..
http://www.picbasic.co.uk/forum/show...1881#post91881
Dave
Always wear safety glasses while programming.
Malcolm,
I missed this part in your conversion last time.It should be testing the Stop time instead of the Current time.Code:; if the Start and Stop times are the same, then Always OFF if (lightsetHR[fn]=timeH) AND _ (lightsetMN[fn]=timeM) then AlwaysOFF
Here's the updated code.
I've run it in the simulator and it works perfectly.Code:CheckTimes: TimeCmpFlags = 0 ; clear flags first ; if the Start and Stop times are the same, then Always OFF if (lightsetHR[fn]=lightoffHR[fn]) AND _ (lightsetMN[fn]=lightoffMN[fn]) then AlwaysOFF ; is it past the Start time? if (timeH>lightsetHR[fn]) OR _ (timeH=lightsetHR[fn] AND timeM >= lightsetMN[fn])then PastStart=1 ; is it past the Stop time? if (timeH>lightoffHR[fn]) OR _ (timeH=lightoffHR[fn] AND timeM >= lightoffMN[fn])then PastStop=1 ; does the period end the following day? if (lightoffHR[fn]< lightsetHR[fn]) OR _ (lightoffHR[fn]=lightsetHR[fn] AND lightoffMN[fn] < lightsetMN[fn]) then NextDay=1 if !NextDay then ; same day, use AND if PastStart AND !PastStop then ProgON = 1 else ; next day, use OR IF PastStart OR !PastStop then ProgON = 1 endif AlwaysOFF: return
![]()
DT
Thanks guys,
Darrel, I'll give that a whirl later this morning.... and will report back if I have any issues
Love the look of that simulator.... nice layout
Thanks for the support
Edit - Just tried it by setting the current time to 8:15 and then setting the lighting to come on at 8:09 and off at 8:20 and when run it works fine - have also tried it with the clock set to 23:58 and a lighting period of 23:59 to 00:01 and that works too - Thanks DT
However.....
I can't get the display to show when the lights are on...
The value for Lights1 or Lights2 changes from 0 to 1 as the corresponding LED on the development board lights up or turns off according to the value, but the IF Lights1 = 1 LCDOut $FE, $94+9,"Light 1 ON" or IF Lights1 = 1 THEN LCDOut $FE, $94+9,"Light 1 ON" seems to be ignoredCode:fn = 0 ; select the first Lights GOSUB CheckTimes ; compare the programed period IF ProgON THEN ; If in the program period IF Lights1 = 0 THEN Lights1 = 1 IF Lights1 = 1 LCDOut $FE, $94+9,"Light 1 ON" ELSE IF Lights1 = 1 THEN Lights1 = 0 IF Lights1 = 0 LCDOut $FE, $94+9," " ENDIF fn = 1 ; select the second Lights GOSUB CheckTimes ; compare the programed period IF ProgON THEN IF Lights2 = 0 THEN Lights2 = 1 LCDOut $FE, $94+9,"Light 2 ON" ELSE IF Lights2 = 1 THEN Lights2 = 0 LCDOut $FE, $94+9," " ENDIF if Lights1 = 1 and Lights2 = 1 then LCDOut $FE, $94+9,"Lights ON" ELSE LCDOut $FE, $94+9," " Endif
Last edited by malc-c; - 28th July 2010 at 10:17. Reason: update - feedback on performance
Bookmarks