I've created a program that runs a clock module and an iButton 1-wire reader. I want to be able to display what time the iButton was detected and keep that in some sort of record so when I put it in again it displays the same time. I was originally planning on using B1 etc. variables to swap with the variables of the clock module at the time but turns out the B1 variables only go up to B28. Is there another way I can do this? Here's my current program;
wait 2
serout b.3,n2400,(254,128)
pause 50
SYMBOL character1 = B15
SYMBOL character2 = B16
SYMBOL character3 = B17
SYMBOL character4 = B18
SYMBOL character5 = B19
SYMBOL character6 = B20
SYMBOL hours = B21
SYMBOL mins = B22
SYMBOL secs = B23
SYMBOL day = B24
SYMBOL date = B25
SYMBOL month = B26
SYMBOL year = B27
SYMBOL PM_AM = B0
serout b.3,n2400,(254,1)
pause 50
Program:
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte ' set to 100kbps
HI2Cout $0, ( $00,$00 ,$19 ,day,date,month,year) ' write time to DS1307 example (11.58.00 PM)
'prog time (secs,mins,hours,day,date,month,year) ' enter hours in 24 hour format ($0 to $23)
Main:
swap b2,b15
swap b3,b16
swap b4,b17
swap b5,b18
swap b6,b19
swap b7,b20
swap b8,b21
swap b9,b22
swap b10,b23
swap b11,b24
swap b12,b25
swap b13,b26
swap b14,b27
swap b15,b0
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte
HI2Cin $0, (secs,mins,hours,day,date,month,year)
ClockDisplay:
PM_AM ="P" : IF hours < $12 then M_AM = "A" : ENDIF 'indicate PM or AM
IF hours = $20 OR hours = $21 THEN : LET hours = hours - $6 : ENDIF
IF hours > $12 THEN : LET hours = hours - $12 : ENDIF '24 to 12 hour format
IF hours = $0 THEN : hours = $12 : ENDIF
BcdTOASCII hours,character1,character2 : IF character1 = "0" THEN : character1 = " " : ENDIF' zero blanking character1
BcdTOASCII mins ,character3,character4
BcdTOASCII secs ,character5,character6
Start:
let b6 = 0
let b7 = 0
let b8 = 0
let b9 = 0
let b10 = 0
let b11 = 0
let b12 = 0
let b13 = 0
Loop1:
readowsn b.2
if b6 =33 and b7 =38 and b8 =119 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =163 then iButton1
if b6 =33 and b7 =216 and b8 =96 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =239 then iButton2
Gosub Clock
Goto main
iButton1:
gosub ScreenClear
do while b6 =33 and b7 =38 and b8 =119 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =163
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,("iButton One")
pause 50
gosub ValueRewrite
loop
goto main
iButton2:
gosub ScreenClear
do while b6 =33 and b7 =216 and b8 =96 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =239
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,("iButton Two")
pause 50
gosub ValueRewrite
loop
goto main
Clock:
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,(CR, LF,character1,character2,".",character3,character4,".",character5,character6," ",PM_AM,"M", CR, LF)
pause 50
debug
return
ValueRewrite:
let b6 = 0
let b7 = 0
let b8 = 0
let b9 = 0
let b10 = 0
let b11 = 0
let b12 = 0
let b13 = 0
readowsn b.2
return
ScreenClear:
serout b.3,n2400,(254,1)
return
wait 2
serout b.3,n2400,(254,128)
pause 50
SYMBOL character1 = B15
SYMBOL character2 = B16
SYMBOL character3 = B17
SYMBOL character4 = B18
SYMBOL character5 = B19
SYMBOL character6 = B20
SYMBOL hours = B21
SYMBOL mins = B22
SYMBOL secs = B23
SYMBOL day = B24
SYMBOL date = B25
SYMBOL month = B26
SYMBOL year = B27
SYMBOL PM_AM = B0
serout b.3,n2400,(254,1)
pause 50
Program:
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte ' set to 100kbps
HI2Cout $0, ( $00,$00 ,$19 ,day,date,month,year) ' write time to DS1307 example (11.58.00 PM)
'prog time (secs,mins,hours,day,date,month,year) ' enter hours in 24 hour format ($0 to $23)
Main:
swap b2,b15
swap b3,b16
swap b4,b17
swap b5,b18
swap b6,b19
swap b7,b20
swap b8,b21
swap b9,b22
swap b10,b23
swap b11,b24
swap b12,b25
swap b13,b26
swap b14,b27
swap b15,b0
HI2Csetup I2Cmaster, %11010000, I2Cslow, I2Cbyte
HI2Cin $0, (secs,mins,hours,day,date,month,year)
ClockDisplay:
PM_AM ="P" : IF hours < $12 then M_AM = "A" : ENDIF 'indicate PM or AM
IF hours = $20 OR hours = $21 THEN : LET hours = hours - $6 : ENDIF
IF hours > $12 THEN : LET hours = hours - $12 : ENDIF '24 to 12 hour format
IF hours = $0 THEN : hours = $12 : ENDIF
BcdTOASCII hours,character1,character2 : IF character1 = "0" THEN : character1 = " " : ENDIF' zero blanking character1
BcdTOASCII mins ,character3,character4
BcdTOASCII secs ,character5,character6
Start:
let b6 = 0
let b7 = 0
let b8 = 0
let b9 = 0
let b10 = 0
let b11 = 0
let b12 = 0
let b13 = 0
Loop1:
readowsn b.2
if b6 =33 and b7 =38 and b8 =119 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =163 then iButton1
if b6 =33 and b7 =216 and b8 =96 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =239 then iButton2
Gosub Clock
Goto main
iButton1:
gosub ScreenClear
do while b6 =33 and b7 =38 and b8 =119 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =163
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,("iButton One")
pause 50
gosub ValueRewrite
loop
goto main
iButton2:
gosub ScreenClear
do while b6 =33 and b7 =216 and b8 =96 and b9 =1 and b10 =0 and b11 =32 and b12 =79 and b13 =239
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,("iButton Two")
pause 50
gosub ValueRewrite
loop
goto main
Clock:
serout b.3,n2400,(254,128)
pause 50
serout b.3,n2400,(CR, LF,character1,character2,".",character3,character4,".",character5,character6," ",PM_AM,"M", CR, LF)
pause 50
debug
return
ValueRewrite:
let b6 = 0
let b7 = 0
let b8 = 0
let b9 = 0
let b10 = 0
let b11 = 0
let b12 = 0
let b13 = 0
readowsn b.2
return
ScreenClear:
serout b.3,n2400,(254,1)
return