'************* Konfiguracja uC ***************** '*********************************************** $regfile = "m8def.dat" $crystal = 16000000 Config Portb = &B11111111 : Portb = &B11111111 Config Portc = &B11111111 : Portc = &B11111111 Config Portd = &B00000011 : Portd = &B11111111 Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 Config Lcd = 16 * 2 Deflcdchar 0 , 32 , 32 , 32 , 32 , 32 , 31 , 14 , 4 Cls Cursor Off Noblink Sw_port Alias Pind Triak Alias Portb.2 Triak2 Alias Portb.1 Buzzer Alias Portd.1 Config Timer0 = Timer , Prescale = 256 Enable Timer0 : On Timer0 Prztimer0 Enable Interrupts '********** Konfiguracja uC Koniec ************ '****************** Zmienne ******************* '*********************************************** Dim Tryb As Byte , Wyswietl As Byte Dim Odliczanie As Bit , Poz_ust As Byte Dim Licz_1s As Word , Licz_1s_u As Word , Dzielnik As Byte Dim Help As Word Dim Flaga_4ms As Bit Dim Sw As Byte , Stan_sw As Byte , Licznik_sw As Byte Dim Autosave As Byte '************* Zmienne Koniec **************** '************ Warunki Poczatkowe *************** '*********************************************** Readeeprom Licz_1s_u , 1 If Licz_1s_u < 1 Or Licz_1s_u > 43200 Then Licz_1s_u = 60 Licz_1s = Licz_1s_u Wyswietl = 1 Poz_ust = 2 'ktora sie ustawia pozycja '******* Warunki Poczatkowe Koniec *********** Lcd " Wersja 1.22 " Lowerline Lcd " Autor: Mirley" Wait 2 Reset Buzzer Waitms 200 Set Buzzer '************** Petla glowna ****************** '*********************************************** Do If Flaga_4ms = 1 Then Flaga_4ms = 0 Gosub Wyswietlanie Gosub Przyciski If Autosave < 250 Then Incr Autosave If Autosave = 250 Then Writeeeprom Licz_1s_u , 1 End If End If End If Loop End '************ Petla glowna Koniec ************** '************ Przerwanie timer 0 *************** '*********************************************** Prztimer0: 'co 4ms Timer0 = 5 Flaga_4ms = 1 If Odliczanie = 1 Then Incr Dzielnik If Dzielnik = 250 Then Dzielnik = 0 If Licz_1s = 0 Then Gosub Zatrzymaj_liczenie Reset Buzzer Waitms 200 Set Buzzer Waitms 200 Reset Buzzer Waitms 200 Set Buzzer Waitms 200 Reset Buzzer Waitms 200 Set Buzzer Else Decr Licz_1s Wyswietl = 2 End If End If Else Dzielnik = 0 End If Return '******** Przerwanie timer 0 Koniec ************ '************** Wyswietlannie *********** Wyswietlanie: If Wyswietl <> 0 Then Select Case Wyswietl Case 1: Cls Lcd " Stop" Locate 1 , Poz_ust Lcd Chr(0) Case 2: If Tryb <> 2 Then Cls Lcd " Odliczanie ..." End If Case 3: Cls Lcd " Podglad" End Select Locate 2 , 2 Help = Licz_1s / 3600 'godziny If Help < 10 Then Lcd "0" Lcd Help;":" Help = Licz_1s / 60 Help = Help Mod 60 'minuty If Help < 10 Then Lcd "0" Lcd Help;":" Help = Licz_1s Mod 60 If Help < 10 Then Lcd "0" Lcd Help;" hhmmss" Tryb = Wyswietl Wyswietl = 0 End If Return '************** Wyswietlannie Koniec *********** '************** Przyciski *********** Przyciski: Sw = Sw_port And &B11111100 If Sw <> &B11111100 And Stan_sw = Sw Then Incr Licznik_sw If Licznik_sw = 100 Then Licznik_sw = 0 Select Case Stan_sw '********************* Case &B01111100: 'up If Tryb = 1 Then Select Case Poz_ust Case 2: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 36000 Case 3: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 3600 Case 5: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 600 Case 6: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 60 Case 8: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 10 Case 9: If Licz_1s_u < 43200 Then Licz_1s_u = Licz_1s_u + 1 End Select Licz_1s = Licz_1s_u Wyswietl = 1 Autosave = 0 Else Gosub Zatrzymaj_liczenie End If '********************* Case &B10111100: 'right If Tryb = 1 Then Incr Poz_ust If Poz_ust = 10 Then Poz_ust = 2 If Poz_ust = 4 Then Poz_ust = 5 If Poz_ust = 7 Then Poz_ust = 8 Wyswietl = 1 Autosave = 0 Else Gosub Zatrzymaj_liczenie End If '********************* Case &B11101100: 'down If Tryb = 1 Then Select Case Poz_ust Case 2: If Licz_1s_u > 36000 Then Licz_1s_u = Licz_1s_u - 36000 Case 3: If Licz_1s_u > 3600 Then Licz_1s_u = Licz_1s_u - 3600 Case 5: If Licz_1s_u > 600 Then Licz_1s_u = Licz_1s_u - 600 Case 6: If Licz_1s_u > 60 Then Licz_1s_u = Licz_1s_u - 60 Case 8: If Licz_1s_u > 10 Then Licz_1s_u = Licz_1s_u - 10 Case 8: If Licz_1s_u > 1 Then Licz_1s_u = Licz_1s_u - 1 End Select Licz_1s = Licz_1s_u Wyswietl = 1 Autosave = 0 Else Gosub Zatrzymaj_liczenie End If '********************* Case &B11011100: 'left If Tryb = 1 Then Decr Poz_ust If Poz_ust = 1 Then Poz_ust = 9 If Poz_ust = 4 Then Poz_ust = 3 If Poz_ust = 7 Then Poz_ust = 6 Wyswietl = 1 Autosave = 0 Else Gosub Zatrzymaj_liczenie End If '********************* Case &B11111000: 'start stop If Odliczanie = 0 Then Reset Triak Set Triak2 Licz_1s = Licz_1s_u Odliczanie = 1 Wyswietl = 2 Else Gosub Zatrzymaj_liczenie End If '********************* Case &B11110100: 'podglad If Tryb = 1 Then Reset Triak Set Triak2 Wyswietl = 3 Else Gosub Zatrzymaj_liczenie End If End Select End If Else Stan_sw = Sw Licznik_sw = 70 End If Return '************** Przyciski Koniec *********** '************** Stop *********** Zatrzymaj_liczenie: Set Triak Reset Triak2 Licz_01s = Licz_1s_u Odliczanie = 0 Wyswietl = 1 Return '************** stop Koniec ***********