' GLCD test mit Pollin 120346 mit LC7981 ' tipps : http://www.mikrocontroller.net/topic/83008 $regfile = "M32def.dat" $crystal = 16000000 $baud = 38400 $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" 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 = Portb , Controlport = Portc , Ce = 5 , Cd = 2 , Rd = 3 , Enable = 4 , Reset = 6 , Mode = 8 Config Adc = Single , Prescaler = Auto , Reference = Avcc Sound Portd.7 , 400 , 450 'BEEP bei RN-Mega128Funk Cls '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 :" 'Line(0 , 0) -(159 , 79) , 255 'Print "Line Y=20" 'For X = 1 To 140 ' Pset X , 20 , 255 ' set the pixel '' Waitms 500 ' Print X ; " " ; 'Next Print Print "Line X=30 & 50" For Y = 1 To 70 Pset 30 , Y , 255 ' set the pixel Pset 50 , 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 / 8 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 100 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