' GLCD test mit Pollin 120346 mit LC7981 ' tipps : http://www.mikrocontroller.net/topic/83008 ' http://www.mikrocontroller.net/topic/156831#new ' RN: http://www.roboternetz.de/phpBB2/viewtopic.php?t=43741 $regfile = "m32def.dat" $crystal = 16000000 $hwstack = 160 $swstack = 30 $framesize = 20 ' Belegung Grafik-LCD ControlPort: ' Pin - LCD - Bascom ' 0 - nc ' 1 - nc ' 2 - RS - Cd ' 3 - R/W - Rd ' 4 - E - Wr ' 5 - CS - Ce ' 6 - Res - Reset ' 7 - Beleuchtung_Power ' optimiert für PortC ! 'Config Portc = Output 'Portc = &B01110100 ' Touch werte ' LCD 1 ' X+ 800 Links, X- 175 Rechts -> 625 ' Y+ 715 Oben, Y- 290 Unten -> 425 ' LCD 2 ' X+ 790 Links, X- 190 Rechts -> 600 ' Y+ 715 Oben, Y- 290 Unten -> 425 ' $lib "glcdLC7981.lib" $include "font8x8.font" Dim X As Word Dim Y As Word Dim Xold As Word Dim Yold As Word Dim Xg As Word Dim Yg As Word Dim Tmpstr As String * 10 Dim R As Byte Print Print "LC7981 Graphic Test" Waitms 350 ' Mode: 6 -> Text, 8 -> Graphic Config Graphlcd = 128 * 64sed , Dataport = Portd , Controlport = Portc , Ce = 1 , Cd = 5 , Rd = 4 , Enable = 3 , Reset = 0 , Mode = 6 Config Adc = Single , Prescaler = Auto , Reference = Avcc Sound Portd.7 , 400 , 450 'BEEP bei RN-Mega128Funk Cls Setfont Font8x8 Lcdat 3 , 1 , "Hallo, da ist LC7981" Lcdat 73 , 1 , "Hier ist Zeile Y=73" , 255 'Demo Das Zeichen Pixelweise In Zeilen Positioniert Werden Können 'For X = 3 To 9 ' Y = 50 + X ' Lcdat Y , X , "H" 'Next X 'Box(120 , 45) -(140 , 60) , 255 'Boxfill(130 , 55) -(150 , 70) , 255 'Locate 1 , 1 'For X = 0 To 280 '' Value = Low(x) ' Glcdcmd &H0C ' Glcddata &H20 'Next X 'Print "Touch" 'Locate 1 , 1 'Lcd "Touch" 'Locate 1 , 2 'Lcd "Ausgabe auf UART" 'Start Adc 'Xold = 1 'Yold = 1 'Locate 2 , 1 'Lcd "X :" 'Locate 3 , 1 'Lcd "Y :" 'Print 'Print "crossline" 'Line(0 , 10) -(159 , 70) , 255 'Print "circle" 'Circle(50 , 30) , 20 , 255 'Print "Line Y=20" 'Locate 1 , 1 'For X = 1 To 159 ' Print X ; " " ; ' Value = Low(x) ' Xold = X / 8 ' Locate 3 , Xold ' Xg = X And 7 ' Print Xold ; " " ; Xg ' Glcdcmd &H0F ' Glcddata Xg 'Next X 'Print 'Print "dot 10,10" 'Pset 10 , 10 , 255 'For X = 1 To 140 ' Pset X , 7 , 255 ' set the pixel '' Waitms 500 ' Print X ; " " ; 'Next 'Print 'Print "Line X=10 & 20" 'Line(10 , 15) -(10 , 70) , 255 'Line(20 , 18) -(20 , 65) , 255 'For Y = 15 To 70 ' Pset 10 , Y , 255 ' set the pixel ' Pset 20 , Y , 255 ' set the pixel ' Print Y ; " " ; '' Waitms 500 'Next 'Print 'X = 0 'Y = 0 'Print "Start Loop" 'Do ' Gosub Readtouch ' If X > 670 Then X = 0 ' If Y > 470 Then Y = 0 ' Xg = X / 4 ' Yg = Y / 6 ' If Xg < 160 And Yg < 80 Then ' Pset Xg , Yg , 255 ' End If ' Print "Xg: " ; Xg ; " Yg" ; Yg ' If X <> Xold Then ' Locate 2 , 5 'Tmpstr = Str(x) 'Lcd Format(tmpstr , " 0") ; " " ' End If ' If Y <> Yold Then ' Locate 3 , 5 'Tmpstr = Str(y) 'Lcd Format(tmpstr , " 0") ; " " ' End If ' Xold = X ' Yold = Y ' Locate 10 , 26 ' Tmpstr = Str(xg) ' Print "X " ; Format(tmpstr , " 0") ; ' Tmpstr = Str(yg) ' Print ", Y " ; Format(tmpstr , " 0") ' Waitms 10 'Loop End 'Readtouch: 'Config Porta.0 = Output ' Makes port A.0 output 'Config Porta.1 = Output ' Makes port A.1 output 'Reset Porta.0 ' Sets port A.0 High 'Set Porta.1 ' Sets port A.1 Low 'Reset Porta.2 'Reset Porta.3 'Ddra.2 = 0 ' Sets port A.2 as input 'Ddra.3 = 0 ' Sets port A.3 as input because we need it now as ad input 'Waitms 15 ' Wait until the port is stable 'Y = Getadc(2) ' Read the ad value for the y 'Y = Y - 290 'Print "VALUE Y : " ; Y ' for debugging 'Config Porta.2 = Output ' Makes port A.2 output 'Config Porta.3 = Output ' Makes port A.3 output 'Set Porta.2 ' Sets port A.2 Low 'Reset Porta.3 ' Sets port A.3 High 'Reset Porta.0 'Reset Porta.1 'Ddra.0 = 0 ' Sets port A.0 as input 'Ddra.1 = 0 ' Sets port A.1 as input because we need it now as ad input 'Waitms 15 ' Wait until the port is stable 'X = Getadc(0) ' Read the ad value for the x 'X = X - 190 'Print "VALUE X : " ; X 'Return