Code:
'---------------------------------------------------------------------------
' PS2-Tastatur
'
' Günter Gerold
'---------------------------------------------------------------------------
$regfile = "m8def.dat"
$crystal = 8000000
$baud = 38400
$hwstack = 40
$swstack = 16
$framesize = 32
Declare Sub Writeserinp
Declare Sub Lcdanzeige
Config Serialin = Buffered , Size = 63
Config Serialout = Buffered , Size = 63
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portb.1 , Rs = Portb.0
Config Lcdbus = 4
Config Lcd = 16 * 2
Config Keyboard = Pind.2 , Data = Pind.6 , Keydata = Keydata
Config Watchdog = 512 'Mit dem Watchdogtimer ist das an- und abstecken der Tastatur im Betrieb möglich
On Int0 Isr0
Enable Int0
Config Int0 = Falling
Dim Lcd_dirty As Bit
Dim Serinpstr As String * 63
Dim Strsize As Byte
Dim Strlang As Byte
Dim Fbstring As String * 33
Dim Lcdstring As String * 33
Dim Lcdstringptr(33) As Byte At Lcdstring Overlay
Dim Lcdstringoben As String * 16
Dim Lcdstringunten As String * 16
Dim Taste As Word
Dim Timerlearn As Bit
Dim Lcd_command As Bit
Dim Ib As Byte
Deflcdchar 4 , 14 , 17 , 17 , 22 , 17 , 25 , 22 , 16 ' ß
Deflcdchar 1 , 17 , 14 , 17 , 17 , 31 , 17 , 17 , 32 ' Ä
Deflcdchar 2 , 17 , 14 , 17 , 17 , 17 , 17 , 14 , 32 ' Ö
Deflcdchar 3 , 17 , 32 , 17 , 17 , 17 , 17 , 14 , 32 ' Ü
Enable Interrupts
Echo Off
Cursor Off
Start Watchdog
Cls
Do
If Lcd_dirty = 1 Then
Lcd_dirty = 0
Call Lcdanzeige
End If
Reset Watchdog
Loop
'---------------------------------------------------------------------------
' Writeserinp
' Leitet den empfangenen String zum nächsten Modul weiter
'---------------------------------------------------------------------------
Sub Writeserinp
Print Serinpstr ' Befehl Weiterreichen
End Sub
'---------------------------------------------------------------------------
' LCD Anzeige
'
' Routine zum konvertieren des FBstrings für LCD.
' die Sonderzeichen haben andere Asciicodes...
' Zeilenumbruch des Displays
'---------------------------------------------------------------------------
Sub Lcdanzeige
Lcdstring = Fbstring
For Ib = 1 To Len(lcdstring)
Select Case Lcdstringptr(ib)
Case 129:
Lcdstringptr(ib) = 245
Case 132:
Lcdstringptr(ib) = 225
Case 148:
Lcdstringptr(ib) = 239
Case 225:
Lcdstringptr(ib) = 4
Case 142:
Lcdstringptr(ib) = 1
Case 153:
Lcdstringptr(ib) = 2
Case 154:
Lcdstringptr(ib) = 3
End Select
Next Ib 'nächstes zeichen
Locate 1 , 1
Lcdstringoben = Left(lcdstring , 16)
Lcd Lcdstringoben ; " "
Lowerline
Strsize = Len(lcdstring)
Lcdstringunten = Mid(lcdstring , 17 , 32)
Lcd Lcdstringunten ; " "
If Lcd_command = 1 Then
Stop Watchdog
Waitms 500
Start Watchdog
Fbstring = ""
Lcd_command = 0
Lcd_dirty = 1
End If
End Sub
'---------------------------------------------------------------------------
' Isr0
' Interruptroutine für die Tastatur
' der externe Interrupt 0 überwacht die Dataleitung der Tastatur
'---------------------------------------------------------------------------
Isr0: 'interrupt routine
Taste = Getatkbd() 'Get data from AT keyboard
Select Case Taste
Case 13:
Serinpstr = Fbstring
Fbstring = ""
Call Writeserinp
Case 8:
If Len(fbstring) = 1 Then
Fbstring = ""
Else
Strlang = Len(fbstring) - 1
Fbstring = Left(fbstring , Strlang)
End If
Case 171: 'F-Tasten auslesen
Readeeprom Fbstring , 1
Lcdstring = Fbstring
Case 172:
Readeeprom Fbstring , 31
Lcdstring = Fbstring
Case 173:
Readeeprom Fbstring , 61
Lcdstring = Fbstring
Case 174:
Readeeprom Fbstring , 91
Lcdstring = Fbstring
Case 175:
Readeeprom Fbstring , 121
Lcdstring = Fbstring
Case 176:
Readeeprom Fbstring , 151
Lcdstring = Fbstring
Case 177:
Readeeprom Fbstring , 181
Lcdstring = Fbstring
Case 178:
Readeeprom Fbstring , 211
Lcdstring = Fbstring
Case 179:
Readeeprom Fbstring , 241
Lcdstring = Fbstring
Case 181: 'Shift und F-Taste: Befehl unter F-Taste speichern
Writeeeprom Fbstring , 1
Timerlearn = 1
Case 182:
Writeeeprom Fbstring , 31
Timerlearn = 1
Case 183:
Writeeeprom Fbstring , 61
Timerlearn = 1
Case 184:
Writeeeprom Fbstring , 91
Timerlearn = 1
Case 185:
Writeeeprom Fbstring , 121
Timerlearn = 1
Case 186:
Writeeeprom Fbstring , 151
Timerlearn = 1
Case 187:
Writeeeprom Fbstring , 181
Timerlearn = 1
Case 188:
Writeeeprom Fbstring , 211
Timerlearn = 1
Case 189:
Writeeeprom Fbstring , 241
Timerlearn = 1
Case 190: 'Rollen: Befehl ständig senden
Case 191: 'Shift und Rollen: Das Timerarray wird programmiert
Case Else:
If Taste <> 0 Then
Fbstring = Fbstring + Chr(taste)
End If
End Select
'End If
Set Gifr.intf0
Taste = 0
Lcd_dirty = 1
Return
'---------------------------------------------------------------------------
' Keydata
' Codetabelle für die Tastatur
' da Tastaturen keinen Ascii-Code ausgeben wird in dieser Tabelle
' jeder Taste ein Ascii-Code zugewiesen
'---------------------------------------------------------------------------
Keydata:
'Kleinbuchstaben
Data 0 , 179 , 0 , 175 , 173 , 171 , 172 , 0 , 0 , 180 , 178 , 176 , 174 , 0 , 0 , 0
Data 0 , 0 , 0 , 0 , 0 , 113 , 49 , 4 , 4 , 4 , 121 , 115 , 97 , 119 , 50 , 0
Data 0 , 99 , 120 , 100 , 101 , 52 , 51 , 4 , 4 , 32 , 118 , 102 , 116 , 114 , 53 , 0
Data 0 , 110 , 98 , 104 , 103 , 122 , 54 , 7 , 8 , 44 , 109 , 106 , 117 , 55 , 56 , 0
Data 0 , 44 , 107 , 105 , 111 , 48 , 57 , 4 , 4 , 46 , 45 , 108 , 148 , 112 , 225 , 0
Data 0 , 0 , 132 , 228 , 129 , 92 , 4 , 4 , 4 , 4 , 13 , 4 , 4 , 35 , 0 , 0
Data 0 , 60 , 0 , 0 , 0 , 0 , 8 , 0 , 0 , 49 , 0 , 52 , 55 , 0 , 0 , 0
Data 48 , 44 , 177 , 53 , 54 , 56 , 0 , 0 , 0 , 43 , 51 , 45 , 42 , 57 , 190 , 0
'Grossbuchstaben
Data 0 , 189 , 0 , 185 , 183 , 181 , 182 , 0 , 0 , 0 , 188 , 186 , 184 , 0 , 0 , 0
Data 0 , 0 , 0 , 0 , 0 , 81 , 33 , 0 , 0 , 0 , 89 , 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 , 90 , 38 , 0 , 0 , 76 , 77 , 74 , 85 , 47 , 40 , 0
Data 0 , 59 , 75 , 73 , 79 , 61 , 41 , 0 , 0 , 58 , 95 , 76 , 153 , 80 , 63 , 0
Data 0 , 0 , 142 , 0 , 154 , 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 , 187 , 53 , 54 , 56 , 0 , 0 , 0 , 43 , 51 , 45 , 42 , 57 , 191 , 0
Lesezeichen