'**************************** 'Konfiguracja '**************************** '$regfile = "attiny2313.dat" $regfile = "m8def.dat" $crystal = 12000000 'Config Portb = &B11111111 : Portb = &B11111111 'Config Portd = &B11111111 : Portd = &B11111111 Config Portb = &B11111111 : Portb = &B11111111 Config Portc = &B11111111 : Portc = &B11111111 Config Portd = &B11111111 : Portd = &B11111111 Config 1wire = Pinc.5 Config Timer0 = Timer , Prescale = 64 Enable Timer0 : On Timer0 Przerwanie0 Enable Interrupts '**************************** 'Zmienne '**************************** Dim Lsb As Byte Dim Msb As Byte Dim Co4ms As Byte , Co100ms As Byte , Co1s As Byte Dim Wysw As Word , Wysw1 As Byte , Wysw10 As Byte , Wysw100 As Byte Dim Wysw_pomoc As Word Dim Tempa As Word Dim Mux As Byte Dim Zezw_wysw As Bit Dim Pomiar_odczyt As Bit Dim Minus As Bit Dim Ur As Bit '**************************** 'Wartosci Poczatkowe '**************************** Reset Pomiar_odczyt Reset Ur Wysw1 = 191 Wysw10 = 191 Wysw100 = 191 '**************************** 'Petla glowna '**************************** Do If Zezw_wysw = 1 Then Reset Zezw_wysw 'co 4ms Wysw = Tempa If Ur = 1 Then Gosub Przelicz Gosub Wyswietl End If Loop End '**************************** 'Przerwanie timer0 '**************************** Przerwanie0: Timer0 = 5 Incr Co4ms If Co4ms = 3 Then Co4ms = 0 '*************************************** co 4ms Set Zezw_wysw Incr Co100ms If Co100ms = 25 Then Co100ms = 0 '*************************************** co 100 ms 'ew flaga obslugi przyciskow Incr Co1s If Co1s = 7 Then Co1s = 0 '*************************************** co 1s Pomiar_odczyt = Not Pomiar_odczyt Disable Interrupts 1wreset If Pomiar_odczyt = 1 Then 1wwrite &HCC 1wwrite &H44 Else If Err = 0 Then 1wwrite &HCC 1wwrite &HBE Lsb = 1wread(): Msb = 1wread(): Minus = Msb.7 Tempa = Msb * 256 Tempa = Tempa + Lsb If Minus = 1 Then Tempa = Not Tempa Tempa = Tempa + 1 End If Tempa = Tempa * 10 'temperatura *10 Tempa = Tempa / 16 If Ur = 0 Then Ur = 1 Else Tempa = 10000 'Er wyswietli wyswietlacz potem End If End If Enable Interrupts '*************************************** End If '*************************************** End If '*************************************** End If Return '**************************** 'Inne Etykiety '**************************** Przelicz: If Wysw < 1000 Then Wysw_pomoc = Wysw Mod 10 Wysw1 = Wysw_pomoc Wysw = Wysw / 10 Wysw_pomoc = Wysw Mod 10 Wysw10 = Wysw_pomoc Wysw = Wysw / 10 Wysw_pomoc = Wysw Mod 10 Wysw100 = Wysw_pomoc If Wysw100 = 0 Then Wysw100 = 10 'wygaszenie zera wiodącego Wysw1 = Lookup(wysw1 , Tabela) Wysw10 = Lookup(wysw10 , Tabela2) Wysw100 = Lookup(wysw100 , Tabela) Else Wysw1 = 175 'r Wysw10 = 175 'r Wysw100 = 134 'E End If Return Wyswietl: Incr Mux If Mux = 3 Then Mux = 0 Portc.3 = Not Minus Select Case Mux Case 0: Set Portc.0 Portd = Wysw100 Reset Portc.2 Case 1: Set Portc.2 Portd = Wysw10 Reset Portc.1 Case 2: Set Portc.1 Portd = Wysw1 Reset Portc.0 End Select Return '**************************** '**************************** '******************************************************************************* 'Tabele do wyswietlania na wyswietlaczu '******************************************************************************* Tabela: Data 192 , 249 , 164 , 176 , 153 , 146 , 130 , 248 , 128 , 144 , 255 'znak: 0 1 2 3 4 5 6 7 8 9 pusty Tabela2: Data 64 , 121 , 36 , 48 , 25 , 18 , 2 , 120 , 0 , 16 , 255 'znak: 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. pusty '******************************************************************************* '*******************************************************************************