Advertisement
hejmus

Untitled

Dec 30th, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2. $regfile = "m32def.dat"
  3. $crystal = 8000000
  4. $baud = 19200
  5. $hwstack = 64                                               ' default use 32 for the hardware stack
  6. $swstack = 20                                               ' default use 10 for the SW stack
  7. $framesize = 80
  8. $lib "mcsbyte.lbx"
  9.  
  10. 'deklaracje
  11. Declare Function Readline(byval M As Byte) As String
  12. Declare Function Readkey() As Byte
  13. Declare Sub Wyslij()
  14. Declare Sub Dodaj()
  15. Declare Sub Usun()
  16. Declare Sub Edytuj()
  17. Declare Function Chooseitem(byval Pos As Byte) As Byte
  18.  
  19. 'definiowanie hardware'u
  20. Config Portc = Output
  21. Config Portc.1 = Output : Config Portc.0 = Output
  22. Config Portd = Input
  23. Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
  24. Config Keyboard = Pinc.0 , Data = Pinc.1 , Keydata = Keydata
  25. Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.6 , Rs = Portc.7
  26. Config Lcd = 20 * 4
  27. Config Rc5 = Pind.2
  28. Enable Interrupts
  29.  
  30. 'eeprom data
  31. Dim Names(30) As Eram String * 16
  32. Dim Addrs(30) As Eram Byte
  33. Dim Cmds(30) As Eram Byte
  34.  
  35. 'klawisze strzalek
  36. Const Kl = 4 + 48
  37. Const Kr = 6 + 48
  38. Const Ku = 8 + 48
  39. Const Kd = 2 + 48
  40.  
  41. 'menu data 1234567890123456
  42. Dim Menu(4) As String * 16
  43. Menu(1) = "wyslij          "
  44. Menu(2) = "dodaj           "
  45. Menu(3) = "usun            "
  46. Menu(4) = "edytuj          "
  47. Dim Curmenu As Byte
  48. Dim K As Byte
  49.  
  50. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  51. '///////////////////////////////////////////////////////////////////////////
  52.  
  53. 'eeprom test data
  54. 'Dim Ss As String * 16
  55. 'Dim Ia As Byte
  56. 'Ss = Space(16)
  57. 'Names(1) = "pozycja 1"
  58. 'Names(2) = "blahblah"
  59. 'Addrs(1) = &HAB
  60. 'Addrs(2) = &HCD
  61. 'Cmds(1) = &H12
  62. 'Cmds(2) = &H34
  63. 'For Ia = 3 To 30
  64. 'Names(ia) = Ss
  65. 'Addrs(ia) = &HFF
  66. 'Cmds(ia) = &HFF
  67. 'Next
  68.  
  69. Cls
  70. Lcd "     pilot v0.2     "
  71. Print "--init complete--"
  72.  
  73. Curmenu = 1
  74. Do
  75.     Lowerline
  76.     If Curmenu > 1 Then Lcd "< " Else Lcd "  "
  77.     Locate 2 , 3 : Lcd Menu(curmenu)
  78.     If Curmenu < 4 Then Lcd " >" Else Lcd "  "
  79.     Locate 2 , 3
  80.  
  81.     K = Readkey()
  82.  
  83.     If K = Kl Then
  84.         Decr Curmenu
  85.         If Curmenu = 0 Then Curmenu = 1
  86.     Elseif K = Kr Then
  87.         Incr Curmenu
  88.         If Curmenu = 5 Then Curmenu = 4
  89.     Elseif K = 13 Then
  90.         Select Case Curmenu
  91.             Case 1 : Wyslij
  92.             Case 2 : Dodaj
  93.             Case 3 : Usun
  94.             Case 4 : Edytuj
  95.         End Select
  96.         Cls
  97.         Lcd "     pilot v0.2     "
  98.     End If
  99. Loop
  100.  
  101. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  102. End                                                         '|||||||||||||||
  103. '///////////////////////////////////////////////////////////////////////////
  104.  
  105. Sub Wyslij()
  106. Local I As Byte
  107. Local E1b As Byte , E2b As Byte
  108. I = 1
  109. Do
  110.     I = Chooseitem(i)
  111.     If I = 255 Then Exit Sub
  112.  
  113.     E1b = Addrs(i)
  114.     E2b = Cmds(i)
  115.     If E1b <> 255 Then
  116.         Thirdline
  117.         Lcd "     wysylanie      "
  118.  
  119.         Rc5send 32 , E1b , E2b
  120.         Waitms 100
  121.         Rc5send 0 , E1b , E2b
  122.         Waitms 100
  123.  
  124.         Home T
  125.         Lcd Spc(40)
  126.     End If
  127. Loop
  128.  
  129. End Sub
  130.  
  131. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  132. '///////////////////////////////////////////////////////////////////////////
  133.  
  134. Sub Dodaj()
  135. Local I As Byte
  136. Local Es As String * 16
  137. Local E1 As Byte , E2 As Byte
  138. Local Raw As Byte
  139. I = 1
  140. Do
  141.     I = Chooseitem(i)
  142.     'Print "dodaj - i=" ; I
  143.    If I = 255 Then Exit Sub
  144.  
  145.     E1 = Addrs(i)
  146.     If E1 = 255 Then
  147.         Lowerline
  148.         Lcd Spc(40)
  149.         Home L
  150.         Lcd " podaj nazwe dla: "
  151.         Lcd I
  152.  
  153.         Es = Readline(16)
  154.  
  155.         Home T : Lcd Spc(40)
  156.         Lowerline
  157.         Lcd " przeslij kod ..."
  158.         Print "przeslij kod ..."
  159.  
  160.         Do
  161.             Print "dodaj do start"
  162.             Getrc5(e1 , E2)
  163.             Print "getrc5=" ; E1 ; " " ; E2
  164.             Raw = Getatkbdraw()
  165.             Print "raw=" ; Raw
  166.             If E1 <> 255 Or Raw = 27 Then
  167.                 E1 = E1 And &B01111111
  168.                 Print "dodaj do end"
  169.                 Exit Do
  170.             End If
  171.         Loop
  172.         Addrs(i) = E1
  173.         Cmds(i) = E2
  174.  
  175.         Home T : Lcd Spc(40)
  176.     End If
  177. Loop
  178. End Sub
  179.  
  180. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  181. '///////////////////////////////////////////////////////////////////////////
  182.  
  183. Sub Usun()
  184. Local I As Byte
  185. Local Es As String * 16
  186. Local E1a As Byte , E2a As Byte
  187. Local Tk As Byte
  188. I = 1
  189. Do
  190.     I = Chooseitem(i)
  191.     If I = 255 Then Exit Sub
  192.  
  193.     E1a = Addrs(i)
  194.     If E1a <> 255 Then
  195.         Lowerline
  196.         Lcd Spc(40)
  197.         Home L
  198.         Lcd " usunac "
  199.         Lcd I
  200.         Lcd "? [T]"
  201.  
  202.         Do
  203.             Tk = Getatkbd()
  204.         Loop Until Tk <> 0
  205.  
  206.         If Tk = 116 Then
  207.             Thirdline
  208.             Lcd " usuwanie ..."
  209.  
  210.             Es = Space(16)
  211.             Names(i) = Es
  212.             Addrs(i) = 255
  213.             Cmds(i) = 255
  214.             Waitms 100
  215.  
  216.             Home T : Lcd Spc(40)
  217.         End If
  218.     End If
  219. Loop
  220. End Sub
  221.  
  222. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  223. '///////////////////////////////////////////////////////////////////////////
  224.  
  225. Sub Edytuj()
  226.  
  227. End Sub
  228.  
  229. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  230. '///////////////////////////////////////////////////////////////////////////
  231.  
  232. Function Chooseitem(byval Pos As Byte) As Byte
  233. Dim Cur As Byte
  234. Dim Tkc As Byte
  235. Cur = 1
  236. Cur = Pos
  237. Dim Tmps As String * 16
  238. Dim Tmpb As Byte
  239. Tkc = 0
  240. Tmps = Space(16)
  241. Tmpb = 255
  242. 'Print "chooseitem enter"
  243. Do
  244.     Lowerline
  245.     Lcd Spc(40)
  246.     Home L
  247.     If Cur > 1 Then Lcd "< " Else Lcd "  "
  248.     Locate 2 , 3 : Tmps = Names(cur) : Lcd Tmps
  249.     Locate 2 , 19
  250.     If Cur < 30 Then Lcd " >" Else Lcd "  "
  251.  
  252.     Tmpb = Addrs(cur)
  253.     Fourthline
  254.     If Tmpb = 255 Then
  255.     Lcd "   WOLNY"
  256.     Else
  257.     Lcd "   ZAJETY: "
  258.     Lcd Hex(tmpb)
  259.     Lcd ":"
  260.     Tmpb = Cmds(cur) : Lcd Hex(tmpb)
  261.     End If
  262.  
  263.     Locate 1 , 17
  264.     Lcd "[  ]"
  265.     Locate 1 , 18
  266.     Lcd Cur
  267.  
  268.     Locate 2 , 3
  269.  
  270.     Tmpb = Addrs(cur)
  271.     'Print Cur ; "=> " ; Tmpb ; " ";
  272.    Tmpb = Cmds(cur)
  273.     Print Tmpb
  274.     Do
  275.         Tkc = Getatkbd()
  276.     Loop Until Tkc <> 0
  277.     'Print "key=" ; Tkc
  278.    If Tkc = Kl Then
  279.         Decr Cur
  280.         If Cur = 0 Then Cur = 1
  281.     Elseif Tkc = Kr Then
  282.         Incr Cur
  283.         If Cur = 31 Then Cur = 30
  284.     Elseif Tkc = 13 Then
  285.         Chooseitem = Cur
  286.         Locate 1 , 17
  287.         Lcd "    "
  288.         'Print "chooseitem=" ; Chooseitem
  289.        'Print "chooseitem normal exit"
  290.        Exit Function
  291.     Elseif Tkc = 27 Then
  292.         Chooseitem = 255
  293.         Locate 1 , 17
  294.         Lcd "    "
  295.         'Print "chooseitem=" ; Chooseitem
  296.        'Print "chooseitem esc exit"
  297.        Exit Function
  298.     End If
  299. Loop
  300. End Function
  301.  
  302. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  303. '///////////////////////////////////////////////////////////////////////////
  304.  
  305. Function Readkey() As Byte
  306. Local Key As Byte
  307. Do
  308.     Key = Getatkbd()
  309.     If Key <> 0 Then Readkey = Key
  310. Loop Until Key <> 0
  311. End Function
  312.  
  313. Function Readline(byval M As Byte) As String
  314. Local Key As Byte
  315. Local Txt As String * 20
  316. Local Txt1 As String * 20
  317. Local Tmp As Byte
  318. Local Pos As Byte
  319. Txt = ""
  320. Txt1 = ""
  321. Pos = 0
  322.  
  323. Thirdline
  324.  
  325. Do
  326.     Do
  327.     Key = Getatkbd()
  328.     Loop Until Key <> 0
  329.     If Key > 32 Then
  330.         If Pos < M Then
  331.             Txt = Txt + Chr(key)
  332.             Incr Pos
  333.             Lcd Chr(key)
  334.         End If
  335.     Elseif Key = 8 Then
  336.         If Pos > 0 Then
  337.             Tmp = Len(txt) - 1
  338.             Txt1 = Left(txt , Tmp)
  339.             Txt = Txt1
  340.             Locate 3 , Pos
  341.             Lcd " "
  342.             Locate 3 , Pos
  343.             Decr Pos
  344.             If Pos = 0 Then
  345.                 Pos = 0
  346.                 Txt = ""
  347.                 Home T
  348.             End If
  349.         End If
  350.     End If
  351. Loop Until Key = 13
  352.  
  353. Readline = Txt
  354. End Function
  355.  
  356. '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  357. '///////////////////////////////////////////////////////////////////////////
  358.  
  359. Keydata:
  360. 'lower
  361. Data 0 , 0 , 0 , 204 , 202 , 200 , 201 , 0 , 0 , 0 , 0 , 205 , 203 , 0 , &H5E , 0
  362. Data 0 , 0 , 0 , 0 , 0 , 113 , 49 , 0 , 0 , 0 , 122 , 115 , 97 , 119 , 50 , 0
  363. Data 0 , 99 , 120 , 100 , 101 , 52 , 51 , 0 , 0 , 32 , 118 , 102 , 116 , 114 , 53 , 0
  364. Data 0 , 110 , 98 , 104 , 103 , 121 , 54 , 7 , 8 , 44 , 109 , 106 , 117 , 55 , 56 , 0
  365. Data 0 , 44 , 107 , 105 , 111 , 48 , 57 , 0 , 0 , 46 , 45 , 108 , 48 , 112 , 43 , 0
  366. Data 0 , 0 , 0 , 0 , 0 , 92 , 0 , 0 , 0 , 0 , 13 , 0 , 0 , 92 , 0 , 0
  367. Data 0 , 60 , 0 , 0 , 0 , 0 , 8 , 0 , 0 , 49 , 0 , 52 , 55 , 0 , 0 , 0
  368. Data 48 , 44 , 50 , 53 , 54 , 56 , 27 , 0 , 0 , 43 , 51 , 45 , 42 , 57 , 0 , 0
  369.  
  370. 'upper
  371. Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
  372. Data 0 , 0 , 0 , 0 , 0 , 81 , 33 , 0 , 0 , 0 , 90 , 83 , 65 , 87 , 34 , 0
  373. Data 0 , 67 , 88 , 68 , 69 , 0 , 35 , 0 , 0 , 32 , 86 , 70 , 84 , 82 , 37 , 0
  374. Data 0 , 78 , 66 , 72 , 71 , 89 , 38 , 0 , 0 , 76 , 77 , 74 , 85 , 47 , 40 , 0
  375. Data 0 , 59 , 75 , 73 , 79 , 61 , 41 , 0 , 0 , 58 , 95 , 76 , 48 , 80 , 63 , 0
  376. Data 0 , 0 , 0 , 0 , 0 , 96 , 0 , 0 , 0 , 0 , 13 , 94 , 0 , 42 , 0 , 0
  377. Data 0 , 62 , 0 , 0 , 0 , 8 , 0 , 0 , 49 , 0 , 52 , 55 , 0 , 0 , 0 , 0
  378. Data 48 , 44 , 50 , 53 , 54 , 56 , 0 , 0 , 0 , 43 , 51 , 45 , 42 , 57 , 0 , 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement