Hallo zusammen,
ich habe ein problem mit einem 4-Wire Touchscreen. Wenn ich folgenden Code benutze, dann kann ich den Touchscreen zwar auslesen, aber wenn ich mit einem Stift eine Linie von links nach rechts ziehe, dann wird aber eine Linie von rechts nach links gezeichnet. Und wenn ich eine Linie von oben nach unten ziehe, dann wird eine Linie von unten nach oben gezeichnet. Also quasi invertiert. Ich sitz grad irgendwie auf dem Schlauch. Angeschlossen ist der Touch über 100 Ohm Reihenwiderstände am Mega128 PF0 - PF3. Hier der Code:
Kann mir jemand einen Tip geben, wie ich dieses Problem lösen könnte ?Code:$regfile = "m128def.dat" $crystal = 16000000 $hwstack = 100 $swstack = 75 $framesize = 40 Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 2 , Cd = 3 , Wr = 0 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 8 Config Adc = Single , Prescaler = Auto , Reference = Internal Dim X As Word , Y As Word Dim X2 As Single , Y2 As Single Dim X3 As Single , Y3 As Single Dim X4 As Byte , Y4 As Byte Start Adc Cursor Off Cls Locate 1 , 1 : Lcd "T6963 mit Touchscreen an ATMega128" Locate 3 , 1 Lcd "Y-Koordinate analog: " Locate 4 , 1 Lcd "X-Koordinate analog: " Do Gosub Readtouch Locate 3 , 22 Lcd Y ; " " Locate 4 , 22 Lcd X ; " " If Y > 330 Then Y3 = Y - 346 Y2 = Y3 / 2.89 Y4 = Y2 Else Y4 = 0 End If If X > 150 Then X3 = X - 160 X2 = X3 / 2.78 X4 = X2 Else X4 = 0 End If Locate 5 , 1 Lcd X4 ; " " Locate 6 , 1 Lcd Y4 ; " " Pset X4 , Y4 , 255 Loop End Readtouch: Config Pinf.0 = Output ' Makes port F.0 output Config Pinf.2 = Output ' Makes port F.0 output Set Portf.0 ' Sets port F.0 High Reset Portf.2 ' Sets port F.2 Low Ddrf.1 = 0 ' Sets port F.1 as input Ddrf.3 = 0 ' Sets port F.1 as input because we need it now as ad input Waitms 20 ' Wait until the port is stable Y = Getadc(3) ' Read the ad value for the y Y = 1024 - Y ' Invert the reading Config Pinf.1 = Output ' Makes port F.1 output Config Pinf.3 = Output ' Makes port F.3 output Reset Portf.3 ' Sets port F.3 Low Set Portf.1 ' Sets port F.1 High Ddrf.0 = 0 ' Sets port F.0 as input Ddrf.2 = 0 ' Sets port F.2 as input because we need it now as ad input Waitms 20 ' Wait until the port is stable X = Getadc(2) ' Read the ad value for the x X = 1024 - X ' Invert the reading Return
Danke und Gruß
BlaueLed







Zitieren

Lesezeichen