Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 8.32 KB | None | 0 0
  1. $regfile = "m32def.dat"
  2. $crystal = 4000000
  3.  
  4.  
  5. Config Lcd = 16 * 2
  6. Config Lcdpin = Pin , Rs = Porta.5 , E = Porta.4 , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0
  7. Cursor OFF : CLS
  8.  
  9. Config Sda = Portc.1                                        'konfiguracja szyny I2C
  10. Config Scl = Portc.0
  11.  
  12. Config Int1 = Falling
  13.  
  14.  
  15.  
  16. 'Config Pinc.7 = Input : Config Pinc.6 = Input : Config Pinc.5 = Input : Config Pinc.4 = Input
  17.  
  18.  
  19. Portc.7 = 1 : Portc.6 = 1 : Portc.5 = 1 : Portc.4 = 1
  20.  
  21. Enable Interrupts                                           'uruchomienie przerwań
  22. Enable Int1
  23.  
  24. ON Int1 Co_1_sek
  25.  
  26. DIM Odswiez_godz AS Bit : DIM Dwukropek AS Bit
  27.  
  28. DIM Sekundy AS Byte : DIM Minuty AS Byte : DIM Godziny AS Byte
  29. DIM Sekundy_bcd AS Byte : DIM Minuty_bcd AS Byte : DIM Godziny_bcd AS Byte
  30. DIM Dzien AS Byte : DIM Miesiac AS Byte
  31. DIM Dzien_bcd AS Byte : DIM Miesiac_bcd AS Byte
  32. DIM Rok AS Byte : DIM Dzien_tygodnia AS Byte
  33. DIM Menu AS Byte : DIM Poziom_menu AS Byte
  34. DIM Przypisz AS Bit : DIM Rok_bcd AS Byte
  35. DIM Zostaw_godz AS Bit : DIM Zostaw_date AS Bit
  36. DIM Rok_start AS Byte : DIM Pierwszy_rok AS Bit
  37.  
  38.  
  39. DIM Ustaw_sekundy AS Byte : DIM Ustaw_minuty AS Byte : DIM Ustaw_godziny AS Byte
  40. DIM Ustaw_dzien AS Byte : DIM Ustaw_miesiac AS Byte : DIM Ustaw_rok AS Byte
  41.  
  42.  
  43. Odswiez_godz = 1 : Dwukropek = 1 : Rok_start = 11 : Pierwszy_Rok = 1
  44. Menu = 0 : Poziom_menu = 1 : Zostaw_godz = 0 : Zostaw_date = 1
  45.  
  46. DIM Rok_eeprom AS Eram Word
  47.  
  48.  
  49.  
  50.  
  51. DO
  52.  
  53. IF Menu = 0 THEN
  54.  
  55. IF Pinc.7 = 0 THEN : Menu = 1 : Przypisz = 1 : Disable Int1 : CLS : Waitms 150 : END IF
  56.  
  57.  
  58.  
  59.  
  60.  
  61. I2cstart
  62.   I2cwbyte 162
  63.   I2cwbyte 2
  64.   I2cstart
  65.   I2cwbyte 163
  66.   I2crbyte Sekundy_bcd , Ack
  67.   I2crbyte Minuty_bcd , Ack
  68.   I2crbyte Godziny_bcd , Ack
  69.   I2crbyte Dzien_bcd , Ack
  70.   I2crbyte Miesiac_bcd , Nack
  71.   I2cstop
  72.  
  73. Sekundy = Makedec(sekundy_bcd)
  74. Minuty = Makedec(minuty_bcd)
  75. Godziny = Makedec(godziny_bcd)
  76.  
  77.  
  78. Rok = Dzien
  79. Shift Rok , Right , 6
  80. Rok = Makedec(rok)
  81. Dzien.7 = 0 : Dzien.6 = 0
  82. Dzien = Makedec(dzien_bcd)
  83. Dzien_tygodnia = Miesiac
  84. Shift Dzien_tygodnia , Right , 5
  85. Dzien_tygodnia = Makedec(dzien_tygodnia)
  86. Miesiac.7 = 0 : Miesiac.6 = 0 : Miesiac.5 = 0
  87. Miesiac = Makedec(miesiac_bcd)
  88.  
  89. IF Odswiez_godz = 1 THEN
  90. LOCATE 1 , 12 : Lcd Bcd(godziny_bcd)
  91. LOCATE 1 , 14 : IF Dwukropek = 1 THEN : Lcd ":" : ELSE : Lcd " " : END IF
  92. LOCATE 1 , 15 : Lcd Bcd(minuty_bcd)
  93.  
  94. LOCATE 2 , 12 : Lcd Bcd(dzien) : Lcd "/" : Lcd Bcd(miesiac)
  95. Toggle Odswiez_godz
  96. END IF
  97.  
  98. END IF
  99.  
  100.  
  101. IF Menu = 1 THEN                                            'Menu ustawień
  102.  
  103.    Disable Int1
  104.  
  105.       IF Przypisz = 1 THEN
  106.          Ustaw_godziny = Godziny_bcd : Ustaw_minuty = Minuty_bcd : Ustaw_sekundy = Sekundy_bcd
  107.          Ustaw_dzien = Dzien_bcd : Ustaw_miesiac = Miesiac_bcd : Ustaw_rok = Rok_bcd
  108.          Przypisz = 0
  109.       END IF
  110.  
  111.       IF Pinc.7 = 0 THEN
  112.          Incr Poziom_menu : Waitms 200
  113.       END IF
  114.  
  115.  
  116.      IF Poziom_menu > 6 THEN : Poziom_menu = 1 : Zostaw_date = 1 : END IF
  117.  
  118.  
  119.       IF Zostaw_date = 1 THEN
  120.          IF Pierwszy_rok = 1 THEN : Ustaw_rok = Makebcd(rok_start) : Pierwszy_rok = 0 : END IF
  121.          LOCATE 2 , 1 : Lcd "   "
  122.          Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok) : Lcd "  "
  123.          Zostaw_date = 0
  124.       END IF
  125.  
  126.  
  127. '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>USTAWIANIE GODZINY<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  128.  
  129.       IF Poziom_menu = 1 THEN : Zostaw_godz = 1 : LOCATE 1 , 4       'USTAWIANIE GODZINY
  130.          Lcd "[" : Lcd Bcd(ustaw_godziny) : Lcd "]" : Lcd ":" : Lcd Bcd(ustaw_minuty) : Lcd ":" : Lcd Bcd(ustaw_sekundy)
  131.       END IF
  132.       IF Poziom_menu = 1 AND Pinc.4 = 0 THEN
  133.          Ustaw_godziny = Makedec(ustaw_godziny) : Incr Ustaw_godziny
  134.             IF Ustaw_godziny > 24 THEN : Ustaw_godziny = 1 : END IF
  135.          Ustaw_godziny = Makebcd(ustaw_godziny) : Waitms 150
  136.       END IF
  137.  
  138.       IF Poziom_menu = 1 AND Pinc.5 = 0 THEN
  139.          Ustaw_godziny = Makedec(ustaw_godziny) : Decr Ustaw_godziny
  140.             IF Ustaw_godziny < 1 THEN : Ustaw_godziny = 24 : END IF
  141.          Ustaw_godziny = Makebcd(ustaw_godziny) : Waitms 150
  142.       END IF
  143.  
  144.  
  145.       IF Poziom_menu = 2 THEN : LOCATE 1 , 4                'USTAWIANIE MINUT
  146.          Lcd Bcd(ustaw_godziny) : Lcd ":" : Lcd "[" : Lcd Bcd(ustaw_minuty) : Lcd "]" : Lcd ":" : Lcd Bcd(ustaw_sekundy)
  147.       END IF
  148.       IF Poziom_menu = 2 AND Pinc.4 = 0 THEN
  149.          Ustaw_minuty = Makedec(ustaw_minuty) : Incr Ustaw_minuty
  150.             IF Ustaw_minuty > 59 THEN : Ustaw_minuty = 0 : END IF
  151.             Ustaw_minuty = Makebcd(ustaw_minuty) : Waitms 150
  152.       END IF
  153.  
  154.       IF Poziom_menu = 2 AND Pinc.5 = 0 THEN
  155.          Ustaw_minuty = Makedec(ustaw_minuty) : Decr Ustaw_minuty
  156.             IF Ustaw_minuty > 200 AND Ustaw_minuty <= 255 THEN : Ustaw_minuty = 59 : END IF
  157.          Ustaw_minuty = Makebcd(ustaw_minuty) : Waitms 150
  158.       END IF
  159.  
  160.  
  161.       IF Poziom_menu = 3 THEN : LOCATE 1 , 4                'USTAWIANIE SEKUND
  162.          Lcd Bcd(ustaw_godziny) : Lcd ":" : Lcd Bcd(ustaw_minuty) : Lcd ":" : Lcd "[" : Lcd Bcd(ustaw_sekundy) : Lcd "]"
  163.       END IF
  164.       IF Poziom_menu = 3 AND Pinc.4 = 0 THEN
  165.          Ustaw_sekundy = Makedec(ustaw_sekundy) : Incr Ustaw_sekundy
  166.             IF Ustaw_sekundy > 59 THEN : Ustaw_sekundy = 0 : END IF
  167.             Ustaw_sekundy = Makebcd(ustaw_sekundy) : Waitms 150
  168.       END IF
  169.  
  170.       IF Poziom_menu = 3 AND Pinc.5 = 0 THEN
  171.          Ustaw_sekundy = Makedec(ustaw_sekundy) : Decr Ustaw_sekundy
  172.             IF Ustaw_sekundy > 200 AND Ustaw_sekundy <= 255 THEN : Ustaw_sekundy = 59 : END IF
  173.          Ustaw_sekundy = Makebcd(ustaw_sekundy) : Waitms 150
  174.       END IF
  175.  
  176. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  177.  
  178. '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>USTAWIANIE DATY<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  179.  
  180.  
  181.       IF Poziom_menu = 4 THEN                               'USTAWIANIE DNIA
  182.          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
  183.          LOCATE 2 , 3
  184.          Lcd "[" : Lcd Bcd(ustaw_dzien) : Lcd "]" : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok)
  185.       END IF
  186.       IF Poziom_menu = 4 AND Pinc.4 = 0 THEN
  187.          Ustaw_dzien = Makedec(ustaw_dzien) : Incr Ustaw_dzien
  188.             IF Ustaw_dzien > 31 THEN : Ustaw_dzien = 1 : END IF
  189.             Ustaw_dzien = Makebcd(ustaw_dzien) : Waitms 150
  190.       END IF
  191.  
  192.       IF Poziom_menu = 4 AND Pinc.5 = 0 THEN
  193.          Ustaw_dzien = Makedec(ustaw_dzien) : Decr Ustaw_dzien
  194.             IF Ustaw_dzien < 1 THEN : Ustaw_dzien = 31 : END IF
  195.          Ustaw_dzien = Makebcd(ustaw_dzien) : Waitms 150
  196.       END IF
  197.  
  198.  
  199.       IF Poziom_menu = 5 THEN                               'USTAWIANIE MIESIACA
  200.          LOCATE 2 , 3
  201.          Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd "[" : Lcd Bcd(ustaw_miesiac) : Lcd "]" : Lcd "/" : Lcd "20" : Lcd Bcd(ustaw_rok)
  202.       END IF
  203.       IF Poziom_menu = 5 AND Pinc.4 = 0 THEN
  204.          Ustaw_miesiac = Makedec(ustaw_miesiac) : Incr Ustaw_miesiac
  205.             IF Ustaw_miesiac > 12 THEN : Ustaw_miesiac = 1 : END IF
  206.             Ustaw_miesiac = Makebcd(ustaw_miesiac) : Waitms 150
  207.       END IF
  208.  
  209.       IF Poziom_menu = 5 AND Pinc.5 = 0 THEN
  210.          Ustaw_miesiac = Makedec(ustaw_miesiac) : Decr Ustaw_miesiac
  211.             IF Ustaw_miesiac < 1 THEN : Ustaw_miesiac = 12 : END IF
  212.          Ustaw_miesiac = Makebcd(ustaw_miesiac) : Waitms 150
  213.       END IF
  214.  
  215.  
  216.       IF Poziom_menu = 6 THEN                               'USTAWIANIE ROKU
  217.          LOCATE 2 , 3
  218.          Lcd Bcd(ustaw_dzien) : Lcd "/" : Lcd Bcd(ustaw_miesiac) : Lcd "/" : Lcd "[" : Lcd "20" : Lcd Bcd(ustaw_rok) : Lcd "]"
  219.       END IF
  220.       IF Poziom_menu = 6 AND Pinc.4 = 0 THEN
  221.          Ustaw_rok = Makedec(ustaw_rok) : Incr Ustaw_rok
  222.             IF Ustaw_rok > 99 THEN : Ustaw_rok = 11 : END IF
  223.             Ustaw_rok = Makebcd(ustaw_rok) : Waitms 150
  224.       END IF
  225.  
  226.       IF Poziom_menu = 6 AND Pinc.5 = 0 THEN
  227.          Ustaw_rok = Makedec(ustaw_rok) : Decr Ustaw_rok
  228.             IF Ustaw_rok < 11 THEN : Ustaw_rok = 99 : END IF
  229.          Ustaw_rok = Makebcd(ustaw_rok) : Waitms 150
  230.       END IF
  231.  
  232.  
  233. END IF
  234.  
  235. LOOP : END
  236.  
  237.  
  238. Co_1_sek:
  239. Toggle Odswiez_godz
  240. Toggle Dwukropek
  241. RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement