Resources used:
UROM1 = user set sample time in seconds, should be divisible into 60, recommend 5,6,10,12, or 15
UROM2 = deadband, +/- value change (in counts) for transmission update, recommend 3
UROM3 = scaling factor to correct humidity sensor probe input as temperature, set 174
UROM4 = forced transmission update period in minutes, must be divisible into 60, recommend set 15
RAM1B1-RAM1B6 = 1 bit flags to avoid repeating Tx during each time slice
RAM1B7 = 1 bit flag signifies to force value Tx regardless of no change
RAM2-RAM3 = scratchpad for speed scaling and averaging calcs.
---------------------------------
START
SET RAM2 20
FLASH:
SETLED 0 # flash LED to indicate a reboot to local watcher
DELAY 50
SETLED 1
DELAY 50
DEC RAM2
BNZ FLASH
SETLED 0
DELAY 1000
WEBSET URL1 -1 # tells my ISY it rebooted.
DELAY 1000
MAINRESET:
SET COUNTER 0
MAINLOOP:
GOTO SEND_ALL # only allows two labels to exist right after another
SEND_ALL: # label used for description only
MOD CM UROM4 RAM2 # check for every UROM4 minutes
BNZ RAM2 SEND_DUN # nope = bypass this
TSTGE CS UROM1 # in the first UROM1 seconds?
GOTO SEND_DUN # nope = bypass this
SET RAM1B7 1 # set the force sends flag
GOTO SEC0
SEND_DUN:
SET RAM1B7 0 # clear the force sends flag
SEC0:
MOD CS UROM1 RAM2 # RAM2 carries the remainder of Current Second / 15 seconds
TSTNE RAM2 0 # is timeslice 0 ?
GOTO SEC0_DUN # nope = bypass
BNZ RAM1B1 SEC1 # not the first time here this slice = bypass
CALLSUB CLOCK1
SET RAM1B1 1 # mark it done
GOTO MAINLOOP
SEC0_DUN:
SET RAM1B1 0 # mark it not done for next time slice comes
SEC1: # timeslice 1
TSTNE RAM2 1
GOTO SEC1_DUN
BNZ RAM1B2 SEC2
CALLSUB GUST8
SET RAM1B2 1
GOTO MAINLOOP # always start again as RAM2 may be ruined in subroutine
SEC1_DUN:
SET RAM1B2 0
SEC2:
TSTNE RAM2 2
GOTO SEC2_DUN
BNZ RAM1B3 SEC3
CALLSUB OUTEMP2
SET RAM1B3 1
GOTO MAINLOOP
SEC2_DUN:
SET RAM1B3 0
SEC3:
TSTNE RAM2 3
GOTO SEC3_DUN
BNZ RAM1B4 SEC4
CALLSUB HUMID5
CALLSUB INTEMP6
SET RAM1B4 1
GOTO MAINLOOP
SEC3_DUN:
SET RAM1B4 0
SEC4:
TSTNE RAM2 4
GOTO SEC4_DUN
BNZ RAM1B5 RESET_TIM
CALLSUB WIND7
SET RAM1B5 1
GOTO MAINLOOP
SEC4_DUN:
SET RAM1B5 0
RESET_TIM:
BNZ CH RESET_DUN # is hour 0?
BNZ CM RESET_DUN # is miunute 0?
BNZ CS RESET_DUN # is second 0?
BNZ RAM1B8 RESET_X # have we been here before = bypass
SET RAM1B8 1 # flag subroutines to force send
GOTO MAINRESET
RESET_DUN:
SET RAM1B8 0 # clear flag = not (hr = min = sec = 0)
RESET_X:
GOTO MAINLOOP # repeat until CPU burns out