Sourcecode
V24 to LCD

V24 to LCD

Download: V24tolcd.bas [ KB]



'------------------------------------------------------ '------------------------------------------------------
'Titel                    : V24 to LCD
'Name                     : V24-Lcd.bas
'Autor                    : Arno Schweißinger
'Datum                    : 02.03.2008
'MicroContorller          : AtMega8 16MHz
'Hardware                 : Display HD 44780-kompatibel,
'                           MAX232
'Stromversorgung:         : 5V für Logik
'In Planung               : Schaltbare Ausgänge
'                           Escape Sequenzen
'------------------------------------------------------


$regfile = "m8def.dat"
$crystal = 3686400
$baud = 9600

Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.5 , Rs = Portc.4
Config Lcd = 24 * 2

$lib "mcsbyte.lbx"                                          'use byte library for smaller code

Dim C As Byte
Dim Zeile1 As String * 24
Const Info1 = "9600 Baud, 8 Bit, 1 Stop"
Const Info2 = "########################"

Declare Sub Escape
Declare Sub Formfeed

'-------------------------
'      Hauptprogramm
'-------------------------
Print Info2
Initlcd
Cursor Off Noblink                                          'hide cursor
Cls
Lcd Info1
Wait 1
Call Formfeed
Do                                                          ' Endlosschleife
 Do                                                        ' Zeilenabfrage
   C = Waitkey()
   Select Case C
     Case 12 : Call Formfeed                               ' Seite löschen
     Case 27 : Call Escape                                 ' ESC Sequenz
     Case Is < 32 :                                        ' Steuerzeichen, ausfiltern
     Case Else:                                            '
       Lcd Chr(c)
       Zeile1 = Zeile1 + Chr(c)
   End Select
 Loop Until C = 13                                         ' Carriage Return
 Cls
 Locate 1 , 1
 Lcd Zeile1
 Zeile1 = ""
 Locate 2 , 1
Loop
End                                                         ' ende Hauptprogramm

Sub Formfeed
 Zeile1 = ""
 Cls
End Sub

Sub Escape
' Hier sollen einmal die Escape Sequenzen stehen
End Sub