"mcsbyte.lib" und "glcd.lib" sind vorhanden.


'The connections of the LCD used in this demo
'LCD pin connected to
' 1 GND GND
'2 GND GND
'3 +5V +5V
'4 -9V -9V potmeter
'5 /WR PORTC.0 (PORTD.2)
'6 /RD PORTC.1 (PORTD.3)
'7 /CE PORTC.2 (PORTD.4)
'8 C/D PORTC.3 (PORTD.5)
'9 NC not conneted
'10 RESET PORTC.4 (PORTD.6)
'11-18 D0-D7 PA (PB)
'19 FS PORTC.5 (PORTD.7)
'20 NC not connected

'Jede Ausgabe Per V24 An Das Lcd Sieht Folgendermassen Aus:

'tzzsssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcr =Texte anzeigen
'zz Ist Die Zeile Von 1..16 , Z = 00 Macht Cls
'sss Ist Die Spalte(3stellig) Von 0..20
'xxx..xxx Ist Der Auszugebende String
'Cr Muß Folgen
'Linie: lx0,y0,x1,y1,Farbe = Linie zeichnen=1 oder löschen=0
'Pixel: px0,y0,Farbe =Pixel setzen=1, löschen=0; Farbe
'Kreis: cx0,y0,x1,Farbe =Kreis x0,y0^= Mittielpunkt, X1^= Radius; Farbe= setzen=1, löschen=0

' Anschlüsse des ATMega32 Pollin Funkmodul
' ATmega 16/32 an J4
'
' XCK/T0) PB0 |1 40| PA0 (ADC0) (adc0) Pa0 |1 2| Pa1(adc1)
' (T1) PB1 |2 39| PA1 (ADC1) (adc2) Pa2 |3 4| PA3 (ADC3)
' INT2/AIN0) PB2 |3 38| PA2 (ADC2) (ADC4) PA4 |5 6| PA5 (ADC5)
' (OC0/AIN1) PB3 |4 37| Pa3 (ADC3) (ADC6) PA6 |7 8| PA7 (ADC7)
' (SS) PB4 |5 36| PA4 (ADC4) (XCK/T0) PB0 |9 10| PB1 (T1) Taster1
' (MOSI) PB5 |6 35| PA5 (ADC5) (INT2/AIN0) PB2 |11 12| PB3 (OC0/AIN1)
' (MISO) PB6 |7 34| PA6 (ADC6) (SS) PB4 |13 14| PB5 (MOSI)
' (SCK) PB7 |8 33| PA7 (ADC7) (MISO) PB6 |15 16| PB7 (SCK)
' RESET |9 32| Aref (SCL) PC0 |17 18| PC1 (SDA)
' VCC |10 31| Gnd (TCK) PC2 |19 | n.c.
' GND |11 30| Avcc (TMS) PC3 |21 22| PC4 (TMS
' XTAL2 |12 29| PC7 (TOSC2) (TDI) PC5 |23 24| PC6 (TOSC1)
' XTAL1 |13 28| PC6 (TOSC1) (TOSC2) PC7 |25 26| PD0 (RXD)
' (RXD) PD0 |14 27| PC5 (TDI) (TXD) PD1 |27 28| PD2 (INT0)
' (TXD) PD1 |15 26| PC4 (TDO) (INT1) PD3 |29 30| PD4 (OC1B)
' (INT0) PD2 |16 25| PC3 (TMS) LED2(OC1A) PD5 |31 32| PD6 (ICP1) LED1
' (INT1) PD3 |17 24| PC2 (TCK) (OC2) PD7 |33 34| AREF
' (OC1B) PD4 |18 23| PC1 (SDA) GND |35 36| VCC, AVCC
' (OC1A) PD5 |19 22| PC0 (SCL) GND |37 38| VCC, AVCC
' (ICP) PD6 |20 21| PD7 (OC2) GND |39 40| VCC, AVCC
'


' PA.0=
' PA.1=
' PA.2=
' PA.3=
' PA.4=
' PA.5=
' PA.6=
' PA.7=

' Datenport B
' PortB.0 = D0
' PortB.1 = D1
' PortB.2 = D2
' PortB.3 = D3
' PortB.4 = D4
' PortB.5 = D5
' PortB.6 = D6
' PortB.7 = D7


' PC.0=
' PC.1=
' PC.2=
' PC.3=
' PC.4=
' PC.5=
' PC.6=
' PC.7=

' Steuerport
' PD.0=(RXD)
' PD.1=(TXD)
' PD.2= /WR
' PD.3= /RD
' PD.4= /CE
' PD.5= C/D
' PD.6= ?LCD-RESET
' PD.7= ?FS (Fond selekt)


$regfile = "m32def.dat"
$crystal = 16000000 '7372800 8000000 16000000
$baud = 9600
'$lib "glcd1.lib"

$hwstack = 100 ' Hardwarestack
$swstack = 54 ' Softwarestack
$framesize = 64 ' Framsize

Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portb , Wr = 0 , Rd = 1 , Ce = 2 , Cd = 3 , Reset = 4 , Fs = 5 , Mode = 8

Dim X As Byte ', Y As Byte
Dim X0 As Byte , Y0 As Byte 'Zeile-Spalte Start
Dim X1 As Byte , Y1 As Byte 'Zeile-Spalte Ende;X1 auch Radius
Dim Farbe As Byte 'setzen, löschen
Dim C As Byte ' Zeichen von COM
Dim L As Byte ' Stringlänge
Dim Lmax As Byte 'maximale Stringlänge
Dim I As Byte 'Schleifenzähler
Dim J As Bit 'ComString komplett
Dim Pos As Byte 'Position des ","
Dim Zeile As Byte
Dim Spalte As Byte
Dim Ch As String * 2 ' Str-Wert des aktuellen Zeichens zum LCD
Dim Texte As String * 26 'Anzuzeigender String
Dim Text As String * 10 'eingelesener COM-String

'Const _aglcd_loop = 1280 '64*20Bytes jeweils Upper und Lower Screen C lib???
'Const _atlcd_loop = 160 '8*20Bytes jeweils Upper und Lower Screen
'Const _aglcd_cols = 20

Enable Interrupts
On Urxc Comin 'define serial receive ISR
Enable Urxc 'enable receive isr

Cls

Cursor Off
'Cls

Wait 1

'$sim

'------------
'Hautprogramm
'------------
L = 0
Lmax = 40
J = 0

Print "Grafig-LCD mit COM"
Spalte = 2
Zeile = 2
Locate Zeile , Spalte
Lcd "Grafig-LCD mit COM" '"0123456789ABCDEF"
Locate 4 , 1
Lcd "tzzssText;t0000=CLS"
Locate 5 , 1
Lcd "lX0,Y0,X1,Y1,0/1=Linie1234567890"
Locate 6 , 1
Lcd "pX0,Y0,0/1 = Punkt"
Locate 7 , 1
Lcd "kX0,Y0,X1,0/1= Kreis"
'Waitms 500
'use the new LINE statement to create a box
'LINE(X0,Y0) - (X1,Y1), on/off
'Line(0 , 0) -(159 , 62) , 255 ' diagonal line
'Line(0 , 127) -(63 , 0) , 255 ' diagonal line
'Wait 1
For I = 1 To 6
Line(0 , 0) -(159 , 0) , 255 ' horizontal upper line
Line(0 , 63) -(159 , 63) , 255 'horizontal lower line
Line(0 , 0) -(0 , 62 ) , 255 ' vertical left line
Line(159 , 0) -(159 , 62) , 255 ' vertical right line
Line(0 , 0) -(159 , 0) , 255 ' horizontal upper line
Line(1 , 1 -(160 , 1 , 255
Next I
'Wait 2
'For X = 0 To 160
'Pset X , 20 , 255 ' set the pixel
'Waitms 5
'Next

'Wait 2
'For X = 1 To 31
' Circle(40 , 32) , X , 255 ' show circle
' Wait 1
' Circle(20 , 32) , X , 0 'remove circle
'Waitms 10
'Next

'Wait 2



Do
'Toggle Portb.5
Waitms 900
If J = 1 Then Gosub Commdaten ' Anzeige
'Incr Zeile
'Incr Spalte
'Locate Zeile , Spalte
'Lcd "Grafiganzeige mit COM" '"0123456789ABCDEF"
'Print "Z=" ; Zeile ; " S=" ; Spalte ; " Text= " ; Texte

Loop

'------------------
'Ende Hauptprogramm
'------------------
'-----------------------------------------------------------
Commdaten: 'vom Hauptrechner
If J = 1 Then
Ch = Left(text , 1)
If Ch = "t" Then 'Text
Gosub Text
Elseif Ch = "p" Then 'Pixel
Gosub Pixel
Elseif Ch = "l" Then 'Linie
Gosub Linie
Elseif Ch = "k" Then 'Kreis
Gosub Kreis
Elseif Ch = "c" Then 'Komandos
'Gosub Komandos
Elseif Ch = "z" Then 'NC
'Gosub
End If
J = 0 'Flag für Anzeige
Text = "" ' Buffer leeren
L = 0 ' Länge = 0
End If
Return

'-----------------------------------------------------------
Text:
L = Len(text)
Ch = Left(text , 1)
If Ch = "t" And L > 4 Then 'erstes Zeichen ein @ und Zeichensatz länger 4 Zeichen ???
Ch = Mid(text , 2 , 2) ' Zeile holen...
If Ch = "00" Then ' Zeile = 0... ?
Cls ' ...dann CLS
Else
Zeile = Val(ch) ' ... und in Zahl wandeln
Ch = Mid(text , 4 , 2) ' Spalte holen...
Spalte = Val(ch) ' ... und in Zahl wandeln
Texte = Mid(text , 6 , L) ' Zeichen holen...
Locate Zeile , Spalte
Lcd Texte
Print "Z=" ; Zeile ; " S=" ; Spalte ; " Text= " ; Texte ; " ;Fs= " ; Portb.5
End If
Toggle Portb.5

End If


Return

'-----------------------------------------------------------
Linie:
Text = Mid(text , 2 , L) '"p"löschen
Gosub Koordinaten
X0 = X
Gosub Koordinaten
Y0 = X
Gosub Koordinaten
X1 = X
Gosub Koordinaten
Y1 = X
Gosub Koordinaten
Farbe = X
If Farbe = 1 Then Farbe = 255
For I = 1 To 6
Line(x0 , Y0) -(x1 , Y1) , Farbe
Next 1
Return
'---

Pixel:
Text = Mid(text , 2 , L) '"p"löschen
Gosub Koordinaten
X0 = X
Gosub Koordinaten
Y0 = X
Gosub Koordinaten
Farbe = X
Pset X0 , Y0 , Farbe

Return
'---

Kreis:
Text = Mid(text , 2 , L) '"p"löschen
Gosub Koordinaten
X0 = X
Gosub Koordinaten
Y0 = X
Gosub Koordinaten
X1 = X
Gosub Koordinaten
Farbe = X
If Farbe = 1 Then Farbe = 255
For I = 1 To 4
Circle(x0 , Y0) , X1 , Farbe ' show circle
Next I

Return
'---

Koordinaten:
Pos = Instr(text , ",") 'wo ist ","
Decr Pos
Ch = Left(text , Pos) 'links vom "," lesen
X = Val(ch) ': Print X
Pos = Pos + 2
Text = Mid(text , Pos , L) 'linke ziechen und "," löschen
Return
'---- ISR -------------------------------------------------------

Comin:
C = Udr ' Byte aus der UART auslesen
If C > 31 And L < Lmax Then ' Grenzen für V24-String überwachen
Incr L
Text = Text + Chr(c) ' Buffer füllen
'Print Text
Elseif C = 13 Then ' <Enter> und damit String komplett
J = 1
End If

Return
'-----------------------------------------------------------





End

Obere Hälfte voll ok untere nur Pixelwirwar