How about reading the value at 95 before writing, and if it is the same as Lights then do not do the write.
Perhaps another suggestion convert your time to all minutes (word) then you only need one test instead of 2.
How about reading the value at 95 before writing, and if it is the same as Lights then do not do the write.
Perhaps another suggestion convert your time to all minutes (word) then you only need one test instead of 2.
Code:Lights var PortB.1 LightStatus VAR BYTE SYMBOL WStatus = LightStatus.0 ChkLights var bit WStatus = 0 ChkLights = lights ' Take status. IF RTCHour = SetlightOnHour THEN IF RTCMin = SetlightOnMin THEN Lights = 1 WStatus = 1 ' set flag for write. ENDIF ENDIF IF RTCHour = SetlightOffHour THEN IF RTCMin = SetlightOffMin THEN Lights = 0 WStatus = 1 ' set flag for write. ENDIF ENDIF if WStatus = 1 then ' Flag is set if chklights <> lights then ' and lights pin changed its status; so write. WRITE 95, Lights ' This way, writing to eeprom for entire 1 minute duration is avoided. WStatus = 0 ' clear flag. endif endif
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Thanks aerostar and sayzer!!
I totally overlooked the fact that it would write for the entire minute. That tip is better than condensing the code!!
And it only added 1 byte to the program for 4 lights. Now if I could only get the routines for setting the actual time and the time for each light on/off a lot smaller, right now its like 2000 bytes, but thats for me to work out... or go to a bigger pic.![]()
If you are not using LightStatus.1 anywhere in your program, then
remove "ChkLights var bit" and have this one instead (will save you one byte) : ChkLights var LightStatus.1
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks