Config 1wire = Portb.0 'deklaracja portu na którym będą podpięte DS18b20
Dim I1 As Integer , Ss As String * 6
Dim I2 As Integer , Tt As String * 2
Config Pind.1 = Input
Portd.1 = 1
Config Pind.4 = Input
Portd.4 = 1
Config Pind.3 = Input
Portd.3 = 1
Config Pind.0 = Output
Portd.0 = 0
Dim Dsid1(8) As Byte
Dim Dsid2(8) As Byte
Menu Alias Pind.3
Plus Alias Pind.4
Minus Alias Pind.1
Wyj Alias Portd.0
Dim B As Byte
Dim W As Byte
Dim S As Byte
Dim E As Byte
Dim F As Byte
Dim I As Byte
Dim D As Byte
Dim H As Byte
Deflcdchar 2 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Deflcdchar 3 , 4 , 14 , 31 , 14 , 14 , 14 , 14 , 14
Deflcdchar 4 , 14 , 17 , 17 , 14 , 32 , 32 , 32 , 32
Cursor Off 'Wyłącza kursor
Cls 'Funkcja CLS czyści ekran
Lcd "Termometr Marcina" ; 'ekran startowy (pojawia się tylko podczas włączania urządzenia)
Lowerline
Lcd " 2007 rok "
Wait 1
Cls
W = 1wirecount()
Lcd "Ilosc czujnikow:" 'Informuje ile czujników jest podpiętych do układu (pojawia się tylko podczas włączania urządzenia)
Waitms 400
Lcd W
Wait 1
Cls 'Znajdź pierwszy czujnik podpięty do portu
Dsid1(1) = 1wsearchfirst() 'Znajdź kolejny czujnik podpięty do portu
Dsid2(1) = 1wsearchnext() 'Znajdź kolejny czujnik podpięty do portu
'*******************Odczyt numerów ID czujników temperatury*********************
If Dsid1(8) = Crc8(dsid1(1) , 7) Then 'ta opcja pojawia się tylko przy włączaniu urządzenia
Locate 1 , 1
Lcd "CRC OK Czujnik 1 ID"
Waitms 600
Locate 1 , 1
For B = 1 To 8
Lcd Hex(dsid1(b))
Next
End If
If Dsid2(8) = Crc8(dsid2(1) , 7) Then
Locate 2 , 1
Lcd "CRC OK Czujnik 2 ID"
Waitms 600
Locate 2 , 1
For B = 1 To 8
Lcd Hex(dsid2(b))
Next
End If
Cls
Ppp:
Do
Readeeprom S , 1
Readeeprom H , 2
1wreset
1wwrite &H55
1wverify Dsid1(1)
1wwrite &HBE
I2 = 1wread(2)
' -------------------------------
1wreset
1wwrite &H55
1wverify Dsid2(1)
1wwrite &HBE
I1 = 1wread(2)
'--------konwersja temp dla wszystkich dsow
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 750
If Menu = 0 Then Gosub Ttt
I1 = I1 * 10
I1 = I1 / 16
'If I1 > 0 Then Cls
Ss = Str(i1)
Ss = Format(ss , " 0.0")
D = S * 10
E = D - H
Locate 2 , 1
Lcd "W DOMU " ; Ss ; Chr(4) ; "C "
Locate 3 , 10
If I1 =< E Then Lcd ; Chr(3)
If I1 =< E Then Wyj = 1
If I1 >= D Then Wyj = 0
Locate 3 , 10
If I1 >= D Then Lcd " "
Locate 4 , 1
Lcd "USTAWIONA " ; S ; Chr(4) ; "C"
I2 = I2 * 10
I2 = I2 / 16
Ss = Str(i2)
Ss = Format(ss , " 0.0")
Locate 1 , 1
Lcd "NA POLU " ; Ss ; Chr(4) ; "C"
If I2 >= 0 Then Locate 1 , 19
Lcd " "
If Menu = 0 Then Gosub Ttt
Loop
Ttt:
Cls
Do
Locate 1 , 1
Lcd " USTAW TEMPERATURE "
Locate 3 , 10
Lcd S ; Chr(4) ; "C"
Locate 3 , 14
If S < 100 Then Lcd " "
Locate 3 , 13
If S < 10 Then Lcd " "
Waitms 500
If S < 50 Then
If Plus = 0 Then Waitms 150
If Plus = 0 Then S = S + 1
End If
If S > 0 Then
If Minus = 0 Then Waitms 150
If Minus = 0 Then S = S -1
End If
Debounce , Menu , 0 , Kkk
Loop
Kkk:
Cls
Do
If H < 50 Then
If Plus = 0 Then Waitms 150
If Plus = 0 Then H = H + 5
Waitms 200
End If
If H > 0 Then
If Minus = 0 Then Waitms 150
If Minus = 0 Then H = H - 5
Waitms 200
End If
Tt = Str(h)
Tt = Format(tt , " 0.0" )
Waitms 150
Locate 1 , 1
Lcd " USTAW HISTEREZE "
Locate 3 , 10
Lcd Tt ; Chr(4) ; "C"
Debounce , Menu , 0 , Xxx
Loop
Xxx:
Do
Cls
Locate 2 , 1
Lcd " ZAPIS USTAWIEN"
Waitms 400
Writeeeprom S , 1
Writeeeprom H , 2
Waitms 400
Cls
Goto Ppp
Loop