Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "m32def.dat"
- $crystal = 4000000
- Config Lcd = 16 * 2
- Config Lcdpin = Pin , Rs = Porta.5 , E = Porta.4 , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0
- Cursor OFF : CLS
- Config Sda = Portc.1 'konfiguracja szyny I2C
- Config Scl = Portc.0
- Config Int1 = Falling
- 'Config Pinc.7 = Input : Config Pinc.6 = Input : Config Pinc.5 = Input : Config Pinc.4 = Input
- Portc.7 = 1 : Portc.6 = 1 : Portc.5 = 1 : Portc.4 = 1
- Enable Interrupts 'uruchomienie przerwań
- Enable Int1
- ON Int1 Co_1_sek
- DIM Odswiez_godz AS Bit : DIM Dwukropek AS Bit
- DIM Sekundy AS Byte : DIM Minuty AS Byte : DIM Godziny AS Byte
- DIM Sekundy_bcd AS Byte : DIM Minuty_bcd AS Byte : DIM Godziny_bcd AS Byte
- DIM Dzien AS Byte : DIM Miesiac AS Byte
- DIM Dzien_bcd AS Byte : DIM Miesiac_bcd AS Byte
- DIM Rok AS Byte : DIM Dzien_tygodnia AS Byte
- DIM Menu AS Byte : DIM Poziom_menu AS Byte
- DIM Przypisz AS Bit : DIM Rok_bcd AS Byte
- DIM Zostaw_godz AS Bit : DIM Zostaw_date AS Bit
- DIM Rok_start AS Byte : DIM Pierwszy_rok AS Bit
- DIM Ustaw_sekundy AS Byte : DIM Ustaw_minuty AS Byte : DIM Ustaw_godziny AS Byte
- DIM Ustaw_dzien AS Byte : DIM Ustaw_miesiac AS Byte : DIM Ustaw_rok AS Byte
- Odswiez_godz = 1 : Dwukropek = 1 : Rok_start = 11 : Pierwszy_Rok = 1
- Menu = 0 : Poziom_menu = 1 : Zostaw_godz = 0 : Zostaw_date = 1
- DIM Rok_eeprom AS Eram Word
- DO
- IF Menu = 0 THEN
- IF Pinc.7 = 0 THEN : Menu = 1 : Przypisz = 1 : Disable Int1 : CLS : Waitms 150 : END IF
- I2cstart
- I2cwbyte 162
- I2cwbyte 2
- I2cstart
- I2cwbyte 163
- I2crbyte Sekundy_bcd , Ack
- I2crbyte Minuty_bcd , Ack
- I2crbyte Godziny_bcd , Ack
- I2crbyte Dzien_bcd , Ack
- I2crbyte Miesiac_bcd , Nack
- I2cstop
- Sekundy = Makedec(sekundy_bcd)
- Minuty = Makedec(minuty_bcd)
- Godziny = Makedec(godziny_bcd)
- Rok = Dzien
- Shift Rok , Right , 6
- Rok = Makedec(rok)
- Dzien.7 = 0 : Dzien.6 = 0
- Dzien = Makedec(dzien_bcd)
- Dzien_tygodnia = Miesiac
- Shift Dzien_tygodnia , Right , 5
- Dzien_tygodnia = Makedec(dzien_tygodnia)
- Miesiac.7 = 0 : Miesiac.6 = 0 : Miesiac.5 = 0
- Miesiac = Makedec(miesiac_bcd)
- IF Odswiez_godz = 1 THEN
- LOCATE 1 , 12 : Lcd Bcd(godziny_bcd)
- LOCATE 1 , 14 : IF Dwukropek = 1 THEN : Lcd ":" : ELSE : Lcd " " : END IF
- LOCATE 1 , 15 : Lcd Bcd(minuty_bcd)
- LOCATE 2 , 12 : Lcd Bcd(dzien) : Lcd "/" : Lcd Bcd(miesiac)
- Toggle Odswiez_godz
- END IF
- END IF
- IF Menu = 1 THEN 'Menu ustawień
- Disable Int1
- IF Przypisz = 1 THEN
- Ustaw_godziny = Godziny_bcd : Ustaw_minuty = Minuty_bcd : Ustaw_sekundy = Sekundy_bcd
- Ustaw_dzien = Dzien_bcd : Ustaw_miesiac = Miesiac_bcd : Ustaw_rok = Rok_bcd
- Przypisz = 0
- END IF
- IF Pinc.7 = 0 THEN
- Incr Poziom_menu : Waitms 200
- END IF
- IF Poziom_menu > 6 THEN : Poziom_menu = 1 : Zostaw_date = 1 : END IF
- IF Zostaw_date = 1 THEN
- IF Pierwszy_rok = 1 THEN : Ustaw_rok = Makebcd(rok_start) : Pierwszy_rok = 0 : END IF
- LOCATE 2 , 1 : Lcd " "
- Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok) : Lcd " "
- Zostaw_date = 0
- END IF
- '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>USTAWIANIE GODZINY<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- IF Poziom_menu = 1 THEN : Zostaw_godz = 1 : LOCATE 1 , 4 'USTAWIANIE GODZINY
- Lcd "[" : Lcd Bcd(ustaw_godziny) : Lcd "]" : Lcd ":" : Lcd Bcd(ustaw_minuty) : Lcd ":" : Lcd Bcd(ustaw_sekundy)
- END IF
- IF Poziom_menu = 1 AND Pinc.4 = 0 THEN
- Ustaw_godziny = Makedec(ustaw_godziny) : Incr Ustaw_godziny
- IF Ustaw_godziny > 24 THEN : Ustaw_godziny = 1 : END IF
- Ustaw_godziny = Makebcd(ustaw_godziny) : Waitms 150
- END IF
- IF Poziom_menu = 1 AND Pinc.5 = 0 THEN
- Ustaw_godziny = Makedec(ustaw_godziny) : Decr Ustaw_godziny
- IF Ustaw_godziny < 1 THEN : Ustaw_godziny = 24 : END IF
- Ustaw_godziny = Makebcd(ustaw_godziny) : Waitms 150
- END IF
- IF Poziom_menu = 2 THEN : LOCATE 1 , 4 'USTAWIANIE MINUT
- Lcd Bcd(ustaw_godziny) : Lcd ":" : Lcd "[" : Lcd Bcd(ustaw_minuty) : Lcd "]" : Lcd ":" : Lcd Bcd(ustaw_sekundy)
- END IF
- IF Poziom_menu = 2 AND Pinc.4 = 0 THEN
- Ustaw_minuty = Makedec(ustaw_minuty) : Incr Ustaw_minuty
- IF Ustaw_minuty > 59 THEN : Ustaw_minuty = 0 : END IF
- Ustaw_minuty = Makebcd(ustaw_minuty) : Waitms 150
- END IF
- IF Poziom_menu = 2 AND Pinc.5 = 0 THEN
- Ustaw_minuty = Makedec(ustaw_minuty) : Decr Ustaw_minuty
- IF Ustaw_minuty > 200 AND Ustaw_minuty <= 255 THEN : Ustaw_minuty = 59 : END IF
- Ustaw_minuty = Makebcd(ustaw_minuty) : Waitms 150
- END IF
- IF Poziom_menu = 3 THEN : LOCATE 1 , 4 'USTAWIANIE SEKUND
- Lcd Bcd(ustaw_godziny) : Lcd ":" : Lcd Bcd(ustaw_minuty) : Lcd ":" : Lcd "[" : Lcd Bcd(ustaw_sekundy) : Lcd "]"
- END IF
- IF Poziom_menu = 3 AND Pinc.4 = 0 THEN
- Ustaw_sekundy = Makedec(ustaw_sekundy) : Incr Ustaw_sekundy
- IF Ustaw_sekundy > 59 THEN : Ustaw_sekundy = 0 : END IF
- Ustaw_sekundy = Makebcd(ustaw_sekundy) : Waitms 150
- END IF
- IF Poziom_menu = 3 AND Pinc.5 = 0 THEN
- Ustaw_sekundy = Makedec(ustaw_sekundy) : Decr Ustaw_sekundy
- IF Ustaw_sekundy > 200 AND Ustaw_sekundy <= 255 THEN : Ustaw_sekundy = 59 : END IF
- Ustaw_sekundy = Makebcd(ustaw_sekundy) : Waitms 150
- END IF
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>USTAWIANIE DATY<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- IF Poziom_menu = 4 THEN 'USTAWIANIE DNIA
- IF Zostaw_godz = 1 THEN : LOCATE 1 , 4 : Lcd " " : Lcd Bcd(ustaw_godziny) : Lcd ":" : Lcd Bcd(ustaw_minuty) : Lcd ":" : Lcd Bcd(ustaw_sekundy) : Lcd " " : Zostaw_godz = 0 : END IF
- LOCATE 2 , 3
- Lcd "[" : Lcd Bcd(ustaw_dzien) : Lcd "]" : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok)
- END IF
- IF Poziom_menu = 4 AND Pinc.4 = 0 THEN
- Ustaw_dzien = Makedec(ustaw_dzien) : Incr Ustaw_dzien
- IF Ustaw_dzien > 31 THEN : Ustaw_dzien = 1 : END IF
- Ustaw_dzien = Makebcd(ustaw_dzien) : Waitms 150
- END IF
- IF Poziom_menu = 4 AND Pinc.5 = 0 THEN
- Ustaw_dzien = Makedec(ustaw_dzien) : Decr Ustaw_dzien
- IF Ustaw_dzien < 1 THEN : Ustaw_dzien = 31 : END IF
- Ustaw_dzien = Makebcd(ustaw_dzien) : Waitms 150
- END IF
- IF Poziom_menu = 5 THEN 'USTAWIANIE MIESIACA
- LOCATE 2 , 3
- Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd "[" : Lcd Bcd(ustaw_miesiac) : Lcd "]" : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok)
- END IF
- IF Poziom_menu = 5 AND Pinc.4 = 0 THEN
- Ustaw_miesiac = Makedec(ustaw_miesiac) : Incr Ustaw_miesiac
- IF Ustaw_miesiac > 12 THEN : Ustaw_miesiac = 1 : END IF
- Ustaw_miesiac = Makebcd(ustaw_miesiac) : Waitms 150
- END IF
- IF Poziom_menu = 5 AND Pinc.5 = 0 THEN
- Ustaw_miesiac = Makedec(ustaw_miesiac) : Decr Ustaw_miesiac
- IF Ustaw_miesiac < 1 THEN : Ustaw_miesiac = 12 : END IF
- Ustaw_miesiac = Makebcd(ustaw_miesiac) : Waitms 150
- END IF
- IF Poziom_menu = 6 THEN 'USTAWIANIE ROKU
- LOCATE 2 , 3
- Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "[" : Lcd "20" : Lcd Bcd(ustaw_rok) : Lcd "]"
- END IF
- IF Poziom_menu = 6 AND Pinc.4 = 0 THEN
- Ustaw_rok = Makedec(ustaw_rok) : Incr Ustaw_rok
- IF Ustaw_rok > 99 THEN : Ustaw_rok = 11 : END IF
- Ustaw_rok = Makebcd(ustaw_rok) : Waitms 150
- END IF
- IF Poziom_menu = 6 AND Pinc.5 = 0 THEN
- Ustaw_rok = Makedec(ustaw_rok) : Decr Ustaw_rok
- IF Ustaw_rok < 11 THEN : Ustaw_rok = 99 : END IF
- Ustaw_rok = Makebcd(ustaw_rok) : Waitms 150
- END IF
- END IF
- LOOP : END
- Co_1_sek:
- Toggle Odswiez_godz
- Toggle Dwukropek
- RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement