- 12V Akku mit 280 Ah bauen         
Ergebnis 1 bis 10 von 10

Thema: Touchscreen Ansteuerung 192x64 Display

Baum-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #8
    Benutzer Stammmitglied Avatar von ScummVM
    Registriert seit
    02.04.2010
    Ort
    Österreich
    Beiträge
    79
    Hi,

    X/Y konnte ich herausfinden. So weit läuft es mal - allerdings bekomme ich Y Werte nur auf der unteren Displayhälfte und X Werte nur auf der rechten Displayhälfte.

    Hier mein Testcode:
    Code:
    $regfile = "m128def.dat"                                    ' specify the used micro
    $crystal = 14745600                                         ' used crystal frequency
    $baud = 19200                                               ' use baud rate
    $hwstack = 32                                               ' default use 32 for the hardware stack
    $swstack = 10                                               ' default use 10 for the SW stack
    $framesize = 40                                             ' default use 40 for the frame space
    
    $lib "glcdKS108-192x64.lib"
    
    
    Wait 2
    
    'First we define that we use a graphic LCD
    Config Graphlcd = 192 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 0 , Ce2 = 1 , Ce3 = 2 , Cd = 3 , Rd = 4 , Enable = 5 , Reset = 6 , 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
    Declare Sub Readtouch()
    
    Start Adc
    'Cursor Off
    Cls
    
    Setfont Font5x5
    Lcdat 1 , 1 , "KS108 mit Touch an Mega128"
    Lcdat 3 , 1 , "Y analog: "
    Lcdat 4 , 1 , "X analog: "
    
    Do
     Gosub Readtouch
     Lcdat 3 , 47 , Y ; "  "
     Lcdat 4 , 47 , X ; "  "
    Loop
    End
    
    Sub 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.1                                            ' Sets port F.1 Low
       Set Portf.3                                              ' Sets port F.3 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
    End Sub
    
    $include "font5x5.font"
    Miniaturansichten angehängter Grafiken Miniaturansichten angehängter Grafiken 1_211.jpg   2_167.jpg  

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiFePO4 Speicher Test