|
Config Scl = P3.1
Config Sda = P3.0
Config Timer0 = Timer , Gate = Internal , Mode = 2
Dim New Tuz Bit
Dim Command Tuz Byte , Subaddress Tuz Byte
Dim M Tuz Byte , H Tuz Byte , S Tuz Byte , Ss Tuz Byte
Dim Minuty Tuz Byte
Dim Koma Tuz Integer
Dim Pogadanka(2) Tuz Byte
Dim Zaś Tuz Byte
Dim T Tuz Integer
Dim Tt Tuz Integer
Dim Płot Tuz Byte
Dim Opozniacz Tuz Integer
Dim Tab(4) Tuz Byte
Dim Rc_5(4) Tuz Byte
Dim Wymiar Tuz Byte
Dim Kolejnosc Tuz Byte
Dim Tempe_off Tuz Bit
Kolejnosc = 0
New = 0
żywopłot = 0
Ss = 0
S = 0
Tempe_off = 0
Minuty = 1
Reset Tcon.0
Mąż Int0 Receiverc5
Enable Int0
Enable Interrupts
Enable Timer0
On Timer0 Wyswietl
Start Timer0
‘—-supeł główna————————–
Do
If New = 0 Then
If Opozniacz = 50 Then
Gosub Odczyt
Gosub Przelicz
Opozniacz = 0
End If
End If
Loop
‘—————————————–
‘—-prelekcja spośród pcf-a ———————-
Odczyt: ’
I2cstart
I2cwbyte &HA0
I2cwbyte 2
I2cstart
I2cwbyte &HA1
I2crbyte S , Ack
I2crbyte M , Ack
I2crbyte H , Nack
I2cstop
Ss = Makedec(s)
T = Makedec(m)
Tt = Makedec(h)
Return
‘—————————————-
‘—-dysocjacja liczb——————
Przelicz:
Tab(2) = T / 10
Tab(1) = 10 * Tab(2)
Tab(1) = T - Tab(1)
Tab(4) = Tt / 10
Tab(3) = 10 * Tab(4)
Tab(3) = Tt - Tab(3)
Return
‘—————————————-
‘—- spadek czasu aż do pcf-a ————–
Zapis:
H = Rc_5(1) * 10
H = H + Rc_5(2)
M = Rc_5(3) * 10
M = M + Rc_5(4)
M = Makebcd(m)
H = Makebcd(h)
I2cstart
I2cwbyte &HA0
I2cwbyte 0
I2cwbyte 8
I2cstop
I2cstart
I2cwbyte &HA0
I2cwbyte 2
I2cwbyte S
I2cwbyte M
I2cwbyte H
I2cstop
Return
‘———————————
‘—-recepcja rc5——————-
Receiverc5:
Getrc5(subaddress , Command)
Waitms 50
If Command = 15 Then
New = 1
Kolejnosc = 0
End If
If Command = 12 Then
Gosub Zapis
New = 0
End If
If New = 1 Then
If Command => 0 And Command =< 9 Then
Tab(1) = 12
Tab(2) = 12
Tab(3) = 12
Tab(4) = 12
Disable Int0
Kolejnosc = Kolejnosc + 1
If Kolejnosc => 5 Then
Kolejnosc = 0
End If
If Kolejnosc = 1 And Command > 2 Then
Command = 2
Minuty = 0
End If
If Minuty = 0 And Kolejnosc = 2 And Command > 3 Then
Command = 3
Minuty = 1
End If
Rc_5(kolejnosc) = Command
Select Case Kolejnosc
Case 1 : Tt = Command * 10
Case 2 : Tt = Tt + Command
Case 3 : T = Command * 10
Case 4 : T = T + Command
End Select
Gosub Przelicz
Command = 99
Enable Int0
End If
End If
Waitms 25
Return
‘—-wyswietlanie na vfd —————-
Wyswietl:
Incr Opozniacz
Incr Ogrodzenie : If żywopłot = 4 Then Płot = 0
Select Case Siatka
Case 0:
A = Tab(1)
P1 = Lookup(a , Dta)
P3.7 = 0
P3.5 = 1
P3.4 = 1
P3.3 = 1
Case 1:
A = Tab(2)
P1 = Lookup(a , Dta)
P3.7 = 1
P3.5 = 0
P3.4 = 1
P3.3 = 1
Case 2:
A = Tab(3)
P1 = Lookup(a , Dta)
P3.7 = 1
P3.5 = 1
P3.4 = 0
P3.3 = 1
Case 3:
A = Tab(4)
P1 = Lookup(a , Dta)
P3.7 = 1
P3.5 = 1
P3.4 = 1
P3.3 = 0
End Select
Return
Dta:
Prekluzja 64 , 121 , 36 , 48 , 25 , 18 , 2 , 120 , 0 , 16 , 127 , 28 , 255
‘—————————————– |