Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regfile = "m32def.dat"
- $crystal = 8000000
- $baud = 19200
- $hwstack = 64 ' default use 32 for the hardware stack
- $swstack = 20 ' default use 10 for the SW stack
- $framesize = 80
- $lib "mcsbyte.lbx"
- 'deklaracje
- Declare Function Readline(byval M As Byte) As String
- Declare Function Readkey() As Byte
- Declare Sub Wyslij()
- Declare Sub Dodaj()
- Declare Sub Usun()
- Declare Sub Edytuj()
- Declare Function Chooseitem(byval Pos As Byte) As Byte
- 'definiowanie hardware'u
- Config Portc = Output
- Config Portc.1 = Output : Config Portc.0 = Output
- Config Portd = Input
- Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
- Config Keyboard = Pinc.0 , Data = Pinc.1 , Keydata = Keydata
- Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.6 , Rs = Portc.7
- Config Lcd = 20 * 4
- Config Rc5 = Pind.2
- Enable Interrupts
- 'eeprom data
- Dim Names(30) As Eram String * 16
- Dim Addrs(30) As Eram Byte
- Dim Cmds(30) As Eram Byte
- 'klawisze strzalek
- Const Kl = 4 + 48
- Const Kr = 6 + 48
- Const Ku = 8 + 48
- Const Kd = 2 + 48
- 'menu data 1234567890123456
- Dim Menu(4) As String * 16
- Menu(1) = "wyslij "
- Menu(2) = "dodaj "
- Menu(3) = "usun "
- Menu(4) = "edytuj "
- Dim Curmenu As Byte
- Dim K As Byte
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- 'eeprom test data
- 'Dim Ss As String * 16
- 'Dim Ia As Byte
- 'Ss = Space(16)
- 'Names(1) = "pozycja 1"
- 'Names(2) = "blahblah"
- 'Addrs(1) = &HAB
- 'Addrs(2) = &HCD
- 'Cmds(1) = &H12
- 'Cmds(2) = &H34
- 'For Ia = 3 To 30
- 'Names(ia) = Ss
- 'Addrs(ia) = &HFF
- 'Cmds(ia) = &HFF
- 'Next
- Cls
- Lcd " pilot v0.2 "
- Print "--init complete--"
- Curmenu = 1
- Do
- Lowerline
- If Curmenu > 1 Then Lcd "< " Else Lcd " "
- Locate 2 , 3 : Lcd Menu(curmenu)
- If Curmenu < 4 Then Lcd " >" Else Lcd " "
- Locate 2 , 3
- K = Readkey()
- If K = Kl Then
- Decr Curmenu
- If Curmenu = 0 Then Curmenu = 1
- Elseif K = Kr Then
- Incr Curmenu
- If Curmenu = 5 Then Curmenu = 4
- Elseif K = 13 Then
- Select Case Curmenu
- Case 1 : Wyslij
- Case 2 : Dodaj
- Case 3 : Usun
- Case 4 : Edytuj
- End Select
- Cls
- Lcd " pilot v0.2 "
- End If
- Loop
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- End '|||||||||||||||
- '///////////////////////////////////////////////////////////////////////////
- Sub Wyslij()
- Local I As Byte
- Local E1b As Byte , E2b As Byte
- I = 1
- Do
- I = Chooseitem(i)
- If I = 255 Then Exit Sub
- E1b = Addrs(i)
- E2b = Cmds(i)
- If E1b <> 255 Then
- Thirdline
- Lcd " wysylanie "
- Rc5send 32 , E1b , E2b
- Waitms 100
- Rc5send 0 , E1b , E2b
- Waitms 100
- Home T
- Lcd Spc(40)
- End If
- Loop
- End Sub
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Sub Dodaj()
- Local I As Byte
- Local Es As String * 16
- Local E1 As Byte , E2 As Byte
- Local Raw As Byte
- I = 1
- Do
- I = Chooseitem(i)
- 'Print "dodaj - i=" ; I
- If I = 255 Then Exit Sub
- E1 = Addrs(i)
- If E1 = 255 Then
- Lowerline
- Lcd Spc(40)
- Home L
- Lcd " podaj nazwe dla: "
- Lcd I
- Es = Readline(16)
- Home T : Lcd Spc(40)
- Lowerline
- Lcd " przeslij kod ..."
- Print "przeslij kod ..."
- Do
- Print "dodaj do start"
- Getrc5(e1 , E2)
- Print "getrc5=" ; E1 ; " " ; E2
- Raw = Getatkbdraw()
- Print "raw=" ; Raw
- If E1 <> 255 Or Raw = 27 Then
- E1 = E1 And &B01111111
- Print "dodaj do end"
- Exit Do
- End If
- Loop
- Addrs(i) = E1
- Cmds(i) = E2
- Home T : Lcd Spc(40)
- End If
- Loop
- End Sub
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Sub Usun()
- Local I As Byte
- Local Es As String * 16
- Local E1a As Byte , E2a As Byte
- Local Tk As Byte
- I = 1
- Do
- I = Chooseitem(i)
- If I = 255 Then Exit Sub
- E1a = Addrs(i)
- If E1a <> 255 Then
- Lowerline
- Lcd Spc(40)
- Home L
- Lcd " usunac "
- Lcd I
- Lcd "? [T]"
- Do
- Tk = Getatkbd()
- Loop Until Tk <> 0
- If Tk = 116 Then
- Thirdline
- Lcd " usuwanie ..."
- Es = Space(16)
- Names(i) = Es
- Addrs(i) = 255
- Cmds(i) = 255
- Waitms 100
- Home T : Lcd Spc(40)
- End If
- End If
- Loop
- End Sub
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Sub Edytuj()
- End Sub
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Function Chooseitem(byval Pos As Byte) As Byte
- Dim Cur As Byte
- Dim Tkc As Byte
- Cur = 1
- Cur = Pos
- Dim Tmps As String * 16
- Dim Tmpb As Byte
- Tkc = 0
- Tmps = Space(16)
- Tmpb = 255
- 'Print "chooseitem enter"
- Do
- Lowerline
- Lcd Spc(40)
- Home L
- If Cur > 1 Then Lcd "< " Else Lcd " "
- Locate 2 , 3 : Tmps = Names(cur) : Lcd Tmps
- Locate 2 , 19
- If Cur < 30 Then Lcd " >" Else Lcd " "
- Tmpb = Addrs(cur)
- Fourthline
- If Tmpb = 255 Then
- Lcd " WOLNY"
- Else
- Lcd " ZAJETY: "
- Lcd Hex(tmpb)
- Lcd ":"
- Tmpb = Cmds(cur) : Lcd Hex(tmpb)
- End If
- Locate 1 , 17
- Lcd "[ ]"
- Locate 1 , 18
- Lcd Cur
- Locate 2 , 3
- Tmpb = Addrs(cur)
- 'Print Cur ; "=> " ; Tmpb ; " ";
- Tmpb = Cmds(cur)
- Print Tmpb
- Do
- Tkc = Getatkbd()
- Loop Until Tkc <> 0
- 'Print "key=" ; Tkc
- If Tkc = Kl Then
- Decr Cur
- If Cur = 0 Then Cur = 1
- Elseif Tkc = Kr Then
- Incr Cur
- If Cur = 31 Then Cur = 30
- Elseif Tkc = 13 Then
- Chooseitem = Cur
- Locate 1 , 17
- Lcd " "
- 'Print "chooseitem=" ; Chooseitem
- 'Print "chooseitem normal exit"
- Exit Function
- Elseif Tkc = 27 Then
- Chooseitem = 255
- Locate 1 , 17
- Lcd " "
- 'Print "chooseitem=" ; Chooseitem
- 'Print "chooseitem esc exit"
- Exit Function
- End If
- Loop
- End Function
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Function Readkey() As Byte
- Local Key As Byte
- Do
- Key = Getatkbd()
- If Key <> 0 Then Readkey = Key
- Loop Until Key <> 0
- End Function
- Function Readline(byval M As Byte) As String
- Local Key As Byte
- Local Txt As String * 20
- Local Txt1 As String * 20
- Local Tmp As Byte
- Local Pos As Byte
- Txt = ""
- Txt1 = ""
- Pos = 0
- Thirdline
- Do
- Do
- Key = Getatkbd()
- Loop Until Key <> 0
- If Key > 32 Then
- If Pos < M Then
- Txt = Txt + Chr(key)
- Incr Pos
- Lcd Chr(key)
- End If
- Elseif Key = 8 Then
- If Pos > 0 Then
- Tmp = Len(txt) - 1
- Txt1 = Left(txt , Tmp)
- Txt = Txt1
- Locate 3 , Pos
- Lcd " "
- Locate 3 , Pos
- Decr Pos
- If Pos = 0 Then
- Pos = 0
- Txt = ""
- Home T
- End If
- End If
- End If
- Loop Until Key = 13
- Readline = Txt
- End Function
- '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- '///////////////////////////////////////////////////////////////////////////
- Keydata:
- 'lower
- Data 0 , 0 , 0 , 204 , 202 , 200 , 201 , 0 , 0 , 0 , 0 , 205 , 203 , 0 , &H5E , 0
- Data 0 , 0 , 0 , 0 , 0 , 113 , 49 , 0 , 0 , 0 , 122 , 115 , 97 , 119 , 50 , 0
- Data 0 , 99 , 120 , 100 , 101 , 52 , 51 , 0 , 0 , 32 , 118 , 102 , 116 , 114 , 53 , 0
- Data 0 , 110 , 98 , 104 , 103 , 121 , 54 , 7 , 8 , 44 , 109 , 106 , 117 , 55 , 56 , 0
- Data 0 , 44 , 107 , 105 , 111 , 48 , 57 , 0 , 0 , 46 , 45 , 108 , 48 , 112 , 43 , 0
- Data 0 , 0 , 0 , 0 , 0 , 92 , 0 , 0 , 0 , 0 , 13 , 0 , 0 , 92 , 0 , 0
- Data 0 , 60 , 0 , 0 , 0 , 0 , 8 , 0 , 0 , 49 , 0 , 52 , 55 , 0 , 0 , 0
- Data 48 , 44 , 50 , 53 , 54 , 56 , 27 , 0 , 0 , 43 , 51 , 45 , 42 , 57 , 0 , 0
- 'upper
- Data 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
- Data 0 , 0 , 0 , 0 , 0 , 81 , 33 , 0 , 0 , 0 , 90 , 83 , 65 , 87 , 34 , 0
- Data 0 , 67 , 88 , 68 , 69 , 0 , 35 , 0 , 0 , 32 , 86 , 70 , 84 , 82 , 37 , 0
- Data 0 , 78 , 66 , 72 , 71 , 89 , 38 , 0 , 0 , 76 , 77 , 74 , 85 , 47 , 40 , 0
- Data 0 , 59 , 75 , 73 , 79 , 61 , 41 , 0 , 0 , 58 , 95 , 76 , 48 , 80 , 63 , 0
- Data 0 , 0 , 0 , 0 , 0 , 96 , 0 , 0 , 0 , 0 , 13 , 94 , 0 , 42 , 0 , 0
- Data 0 , 62 , 0 , 0 , 0 , 8 , 0 , 0 , 49 , 0 , 52 , 55 , 0 , 0 , 0 , 0
- 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