
$prog &HFF , &HE2 , &HDF , &HFF                             ' generated. Take care that the chip supports all fuse bytes.


$regfile = "attiny45.dat"
$crystal = 8000000
$hwstack = 36
$swstack = 8
$framesize = 24



Config Portb.2 = Output
Config Portb.1 = Output
Config Portb.0 = Output

Config Spi = Soft , Dout = Portb.2 , Ss = Portb.1 , Clock = Portb.0

Config 1wire = Portb.3

Dim W(2) As Byte                                            'Adat alsó és felső byte
Dim T As Byte

Dim Digit(8) As Word


Dim A As Byte
Dim Aa As Word
Dim B As Byte
Dim C As Word
Dim N1 As Bit

Dim D As Byte
Dim Dd As Word
Dim E As Byte
Dim F As Word
Dim N2 As Bit



Dim Dsid1(8) As Byte
Dim Dsid2(8) As Byte

Dsid1(1) = 1wsearchfirst()
Dsid2(1) = 1wsearchnext()





Spiinit

W(1) = 12                                                   'Shutdown On
W(2) = 0
Spiout W(1) , 2
W(1) = 9                                                    'digitek B kóddal vagy szegmensenként
W(2) = 255
Spiout W(1) , 2
W(1) = 10                                                   'Fényerő max
W(2) = 15
Spiout W(1) , 2
W(1) = 11                                                   '# Digits 8
W(2) = 7
Spiout W(1) , 2
W(1) = 15                                                   'Test Off
W(2) = 0
Spiout W(1) , 2
W(1) = 12                                                   ' Shutdown Off
W(2) = 1
Spiout W(1) , 2


For T = 1 To 8                                              ' minden digit sötétítés
W(1) = T
W(2) = 15
Spiout W(1) , 2
Next T




Do
N1 = 0
N2 = 0

1wreset

'Indítja az AD convertálást'
1wwrite &HCC
1wwrite &H44
Waitms 750

'kiolvassa a ds1 hőfok alsó és felső byte-it és kiszámolja a hőfok 10szeresét '
1wreset
1wreset
1wverify Dsid1(1)
1wwrite &HBE



A = 1wread()
B = 1wread()


Aa = B * 256
Aa = Aa + A

If Aa = 0 Then
C = Aa
End If



If Aa <= 4095 And Aa <> 0 Then
C = Aa * 10
C = C / 16
End If

If Aa > 4095 Then
Aa = 65536 - Aa
C = Aa * 10
C = C / 16
N1 = 1
End If



'kiolvassa a ds2 hőfok alsó és felső byte-it és kiszámolja a hőfok 10szeresét '

1wreset
1wreset
1wverify Dsid2(1)
1wwrite &HBE



D = 1wread()
E = 1wread()


Dd = E * 256
Dd = Dd + D

If Dd = 0 Then
F = Dd
End If



If Dd <= 4095 And Dd <> 0 Then
F = Dd * 10
F = F / 16
End If

If Dd > 4095 Then
Dd = 65536 - Dd
F = Dd * 10
F = F / 16
N2 = 1
End If





Digit(8) = 15
If N1 = 1 Then
Digit(8) = 10
End If
If C >= 1000 Then
Digit(8) = 1
End If

Digit(7) = C Mod 1000
Digit(7) = Digit(7) / 100

If C < 1000 And Digit(7) = 0 Then
Digit(7) = 15
End If
Digit(6) = C Mod 100
Digit(5) = C Mod 10

Digit(4) = 15
If N2 = 1 Then
Digit(4) = 10
End If
If F >= 1000 Then
Digit(4) = 1
End If

Digit(3) = F Mod 1000
Digit(3) = Digit(3) / 100

If F < 1000 And Digit(3) = 0 Then
Digit(3) = 15
End If
Digit(2) = F Mod 100
Digit(1) = F Mod 10

Digit(6) = Digit(6) / 10
Digit(2) = Digit(2) / 10

Digit(6) = Digit(6) + 128
Digit(2) = Digit(2) + 128



For T = 8 To 1 Step -1
W(1) = T
W(2) = Digit(t)
Spiout W(1) , 2
Next




Loop

End