'---------------------------------------------------
Sub2: 'request current data for display
kbdin=0
hserflag = 0
gosub setlcd
serout 7,T9600_8,(254,128,"Waiting for data")
'then Hserout request for data code
hserout 0,(68,1) 'the "0" means NO BREAK sent
'interrupt Main here - put portc pin 5 low after +-50mS to prevent re-interrupt
dir3=0
do until dir3>0 'repeat until return interrupt received.
high portc 4
pause 50
low portc 4
loop
goto menu1
'return
'---------------------------------------------------------
SubSub1: 'get parameters etc., then send to master
temb2=0
memval=0 'use its bytes b20/b21
temb1=0
temw1=0
do until temb1 =10 'until # pressed=enter
do until temw1>490
gosub readkey
loop
gosub idkey
temw1=0
temb1=255
select case kbdin
case 42 'bspace * pressed
temb1 = 1
case 0 to 9 '1 to 9 pressed
temb1=2
case 35 '#(enter) pressed
temb1=10
end select
if temb1 =1 then
if charpos>charcnt then
dec charpos
serout 7,T9600_8,(254,charpos," ") 'print space
end if
serout 7,T9600_8,(254,charpos) 'return to charpos
temb1=0
temb2=temb2-1 min 0
serout 7,T9600_8,(254,13) 're-enter so flash cursor again
end if
if temb2<4 then 'allow 3char for batV: 122
if temb1=2 then
serout 7,T9600_8,(254,charpos,#kbdin) 'print character
inc charpos 'now incr charpos
temb1=0
inc temb2
if temb2=1 then:b18=kbdin:end if
if temb2=2 then:b19 = kbdin:end if
if temb2=3 then:b20=kbdin:end if
end if
end if
loop 'until temb1=10
serout 7,T9600_8,(254,13) 'flash cursor again
if temb2=1 then
temb1=b18
end if
if temb2=2 then
temb1=b18*10
temb1=temb1+b19
end if
if temb2=3 then
temb1=b18*100
b18=b19*10
temb1=temb1+b18+b20
end if
dir2=temb1 'for resend in Interrupt Confirm Data
dir3=0 'if dir3=1 then data received
' sertxd("Value entered = ",#temb1,13,10)
'now Hserout to Main
if charcnt=199 then 'deg C setpoint
temb2=12
dir1=12
end if
if charcnt=208 then 'RH% setpoint
temb2=14
dir1=14
end if
if charcnt=154 then 'Period setpoint
temb2=20
dir1=20
end if
if charcnt=164 then 'BatV setpoint
temb2=24
dir1=24
end if
if charcnt=215 then 'Alarm Cancel
temb2=88
dir1=88
end if
hserout 0,(temb2,temb1) 'send new settings,and interrupt if not Alarm Cancel
do while dir3=0
high portc 4 'a return interrupt will confirm
'when data received OK
pause 50 'pause 25mS(8mhz)
low portc 4
sertxd("sending - ",#temb2," / ",#temb1)
loop
'-----------------
'ON 40X1 MAIN
'int-out output pin 1
'int-in input pin 6
'hserin portC 7
'hserout portC 6
'-----------------
return
'-------------------------------------------------
Sub3:
'Not used yet
return
'---------------------------------------------------
'At BOTTOM of Program
'---------------------------------------------------
Interrupt: 'get latest data from Main
kbdin=0
charpos=0
pause 55 'wait 1/4 sec(8mhz) for pin to go low
'receive data into scratchpad address @ hserptr=100
'Below= what is sent.
'hserout 0,(Tsouth,Tnorth,Tout,Tset,RH,RHset,Period,BatV) 'current data received
' do until hserptr=108 'wait untill 8 bytes received
' pause 200
' charpos=hserptr-100
' loop
choice=100 'hserptr starting register
sertxd("ptr= ",#hserptr,"choice= ",#choice)
get choice,fornext 'code of what was sent, 1=view data/2=confirm data and/or resend..
inc choice 'increase to next ptr for actual data
select case fornext
case 1 'view current data request
get choice,dir1 'Tsouth
inc choice
get choice,dir2 'Tnorth
inc choice
get choice,dir3 'Tout
inc choice
get choice,b18 'Tset
inc choice
get choice,b19 'Rh
inc choice
get choice,b20 'RHset
inc choice
get choice,b21 'Period - b24 from w12
inc choice
get choice,b22 'BatvSet
gosub setlcd
serout 7,T9600_8,(254,13) 'flash cursor ?
gosub setlcd
pause 1000
serout 7,T9600_8,(254,128,"S: ",#dir1," N: ",#dir2," Out:",#dir3)
' --- -- ---- -- ----- -- 18chars
pause 30
serout 7,T9600_8,(254,192,"Tst:",#b18," RH: ",#b19)
' ---- -- ----- -- 13chars
pause 30
serout 7,T9600_8,(254,148,"RhSet: ",#b20," Per: ",#b21)
' ------- -- ------ -- 17chars
pause 30
serout 7,T9600_8,(254,212,"Bat V:",#b22," #= Menu")
' ------ -- --------- 17chars
pause 30
pause 1000
temw1=0
dir3=1
do until temw1>0 and temw1<510 'check for "#" pressed
gosub readkey
gosub idkey
pause 20
loop
case 2 'confirm and/or resend new setpoints
get choice,b18
inc choice
get choice,b19
sertxd("rec: ",#b18," ",#b19)
if b18=dir1 and b19=dir2 then
dir3=1
else
dir3=0
end if
if b18=88 then
setint %00100000 , %00100000 'interupt on input pin 5 high
hserinflag = 0 'reset flag,shows data was read
hserptr=100
temw1=0 'set again for display purposes
pause 20
goto menu1
end if
case 13 'temp alarm
gosub setlcd
get choice,dir1
serout 7,T9600_8,(254,128,"Temperature ALARM")
serout 7,T9600_8,(254,192,#dir1," Deg.C !")
serout 7,T9600_8,(254,212,"88 to CANCEL ")
setint %00100000 , %00100000 'interupt on input pin 5 high
hserinflag = 0 'reset flag,shows data was read
hserptr=100
temw1=0 'set again for display purposes
serout 7,T9600_8,(254,215)
pause 20
charpos=215
charcnt=charpos
serout 7,T9600_8,(254,215) 'goto entry position
gosub subsub1
case 15 'RH alarm
gosub setlcd
get choice,dir1
serout 7,T9600_8,(254,128,"Rel.Hum% ALARM")
serout 7,T9600_8,(254,192,"RH%: ",#dir1)
serout 7,T9600_8,(254,212,"88 to CANCEL ")
setint %00100000 , %00100000 'interupt on input pin 5 high
hserinflag = 0 'reset flag,shows data was read
hserptr=100
temw1=0 'set again for display purposes
serout 7,T9600_8,(254,215)
pause 20
charpos=215
charcnt=charpos
serout 7,T9600_8,(254,215) 'goto entry position
gosub subsub1
case 25 'batv alarm
gosub setlcd
get choice,dir1
serout 7,T9600_8,(254,128,"Bat Low ALARM")
serout 7,T9600_8,(254,192,"Bat V: ",#dir1)
serout 7,T9600_8,(254,212,"88 to CANCEL ")
setint %00100000 , %00100000 'interupt on input pin 5 high
hserinflag = 0 'reset flag,shows data was read
hserptr=100
temw1=0 'set again for display purposes
serout 7,T9600_8,(254,215)
pause 20
charpos=215
charcnt=charpos
serout 7,T9600_8,(254,215) 'goto entry position
gosub subsub1
end select
'if kbdin=35 then
setint %00100000 , %00100000 'interupt on input pin 5 high
hserinflag = 0 'reset flag,shows data was read
hserptr=100
temw1=0 'set again for display purposes
'end if
return