XRinger
Member
Here is some code that I'm trying out to control a fresh air fan in my basment (using X10)..
At the bottom of the main body, it calls the subroutine CALLER, with the next command being END..
CALLER starts off testing the hour of the day, to see if it's after 8AM. (don't want fan noise too early).
If it's after 8AM, it skips the next command, (END #2) and starts checking humidity etc..
After the last call in CALLER is done, it ends with RET, returns to the main body and hits the 'real' main body END..
But if it's before 8AM, it hits END (#2) and re-starts at START.. This end/restart keeps anything below it from executing.
Anyways, this seems to be working. So the question is, will it cause some error later many loops later?
Thanks,
Rich
START
DELAY 10
SET VAR6 0
SET VAR1 T1
SET VAR2 T2
SET VAR3 T3
SET VAR4 H1
SET RAM7 0
SET VAR7 0
MUL CH 60 RAM8
ADD RAM8 CM VAR8
CALLSUB CALLER
END
CALLER:
TSTLE CH 7
END
TSTGT H1[200] 79
CALLSUB FAN_OFF
TSTLE H1[200] 76
CALLSUB FAN_ON
RET
FAN_ON:
X10 2 7 ON
SET OP1 1
SET RAM7 900
CALLSUB TIME10
SET RAM7 0
RET
FAN_OFF:
INC VAR6
X10 2 7 OFF
SET OP1 0
SET RAM7 900
CALLSUB TIME10
SET RAM7 0
RET
TIME10:
SET VAR7 0
MIDEE:
DELAY 1000
TSTEQ VAR7 RAM7
RET
INC VAR7
GOTO MIDEE
At the bottom of the main body, it calls the subroutine CALLER, with the next command being END..
CALLER starts off testing the hour of the day, to see if it's after 8AM. (don't want fan noise too early).
If it's after 8AM, it skips the next command, (END #2) and starts checking humidity etc..
After the last call in CALLER is done, it ends with RET, returns to the main body and hits the 'real' main body END..
But if it's before 8AM, it hits END (#2) and re-starts at START.. This end/restart keeps anything below it from executing.
Anyways, this seems to be working. So the question is, will it cause some error later many loops later?
Thanks,
Rich
START
DELAY 10
SET VAR6 0
SET VAR1 T1
SET VAR2 T2
SET VAR3 T3
SET VAR4 H1
SET RAM7 0
SET VAR7 0
MUL CH 60 RAM8
ADD RAM8 CM VAR8
CALLSUB CALLER
END
CALLER:
TSTLE CH 7
END
TSTGT H1[200] 79
CALLSUB FAN_OFF
TSTLE H1[200] 76
CALLSUB FAN_ON
RET
FAN_ON:
X10 2 7 ON
SET OP1 1
SET RAM7 900
CALLSUB TIME10
SET RAM7 0
RET
FAN_OFF:
INC VAR6
X10 2 7 OFF
SET OP1 0
SET RAM7 900
CALLSUB TIME10
SET RAM7 0
RET
TIME10:
SET VAR7 0
MIDEE:
DELAY 1000
TSTEQ VAR7 RAM7
RET
INC VAR7
GOTO MIDEE