Here is the code in Bascom for my 5″ touchscreen. The schematic and code are adapted for the ledsee.com 240×128 touchscreen.
This code is not very well documentated, for a better explanation of the code check my 3″ application note at the Bascom web site.

Download code, schematic and buttons

$regfile = "m128def.DAT"
$crystal = 7372800
$baud = 19200
$eepleave
$loadersize = 512
$hwstack = 100
$swstack = 75
$framesize = 40


Config Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6
Config Adc = Single , Prescaler = Auto , Reference = Internal
Config Timer1 = Timer , Prescale = 1024
Const Timer1preload = 58336
Config Pinb.4 = Output
Rxtx Alias Porte.2
Speaker Alias Portf.7
Backlight Alias Portb.4
Const Buttonreturndelay = 20                                'Buttonreturndelay in ms
Dim Temp As Byte , X As Word , Y As Word
Dim Hoofdmenutijdrun As Bit
Dim Row As Byte , Keyarray(3) As Byte , Col As Byte , Key As Byte , Keylus As Byte
Dim Keypressed As Byte , Menu As Byte , Holdmenu As Bit
Dim Tijdcount As Byte
Enable Ovf1
Enable Interrupts
On Timer1 1secint
Start Adc
Start Timer1
Reset Hoofdmenutijdrun



' Main
Reset Backlight                                             'switch backlight on
 Cls
Cursor Off
Temp = 0
Gosub Showbasisknoppen
Gosub Showhoofdmenu
Do
'Your main prog here
   Gosub Readtouch
   Gosub Bepaaltoets
If Menu > 1 Then
    Hoofdmenutijdrun = 1
Else
   Hoofdmenutijdrun = 0
End If

If Keypressed > 0 Then
 Select Case Menu
  Case 1 : Select Case Keypressed                           'Hoofdmenu
                  Case 11 : Gosub Foutje                    'Key not used, so beep
                  Case 12 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 13 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 14 : Gosub Showwandmeubelmenu
                  Case 21 : Gosub Foutje
                  Case 22 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 23 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 24 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 31 : Gosub Foutje
                  Case 32 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 33 : Gosub Showjaloezvoormenu
                  Case 34 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 41 : Gosub Foutje
                  Case 42 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 43 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu             'Current menu must be reload to refill the buttons
                  Case 44 : Gosub Showhoofdmenu2
                  End Select
  Case 2 : Select Case Keypressed                           'Jaloezieen voor menu
                  Case 11 : Gosub Foutje
                  Case 12 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 13 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 14 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 21 : Gosub Foutje
                  Case 22 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 23 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 24 : Gosub Foutje
                  Case 31 : Gosub Foutje
                  Case 32 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 33 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showjaloezvoormenu        'Current menu must be reload to refill the buttons
                  Case 34 : Gosub Foutje
                  Case 41 : Gosub Foutje
                  Case 42 : Gosub Foutje
                  Case 43 : Gosub Foutje
                  Case 44 : Gosub Showhoofdmenu
                  End Select

 Case 12 : Select Case Keypressed                           'Wandmeubel
                  Case 11 : Gosub Foutje
                  Case 12 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 13 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 14 : Gosub Foutje
                  Case 21 : Gosub Foutje
                  Case 22 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 23 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 24 : Gosub Foutje
                  Case 31 : Gosub Foutje
                  Case 32 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 33 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 34 : Gosub Foutje
                  Case 41 : Gosub Foutje
                  Case 42 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 43 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showwandmeubelmenu        'Current menu must be reload to refill the buttons
                  Case 44 : Gosub Showhoofdmenu             ' esc knop
                  End Select

  Case 21 : Select Case Keypressed                          'Hoofdmenu 2
                  Case 11 : Gosub Foutje
                  Case 12 : Print "you pressed key " ; Keypressed ; " in menu " ; Menu
                            Gosub Showhoofdmenu2            'Current menu must be reload to refill the buttons
                  Case 13 : Gosub Foutje
                  Case 14 : Gosub Showhoofdmenu             'Back to hoofdmenu1
                  Case 21 : Gosub Foutje
                  Case 22 : Gosub Foutje
                  Case 23 : Gosub Foutje
                  Case 24 : Gosub Foutje
                  Case 31 : Gosub Foutje
                  Case 32 : Gosub Foutje
                  Case 33 : Gosub Foutje
                  Case 34 : Gosub Foutje
                  Case 41 : Gosub Foutje
                  Case 42 : Gosub Foutje
                  Case 43 : Gosub Foutje
                  Case 44 : Gosub Foutje
                  End Select

End Select

 Keypressed = 0
End If
Loop


'=== Subroutines===


1secint:
If Hoofdmenutijdrun = 1 Then
   Incr Tijdcount
        If Tijdcount => 10 Then                             'Time delay return to hoofdmenu (mainmenu)
        Hoofdmenutijdrun = 0 : Tijdcount = 0
         If Holdmenu = 0 Then
          Gosub Showhoofdmenu
         End If
         Else
        End If
End If
Timer1 = Timer1preload
Return



Showwandmeubelmenu:
Menu = 12 : Holdmenu = 0
Showpic 0 , 0 , Hwandmeubel                                 'show a comnpressed picture
Showpic 6 , 36 , Ledsaan
Showpic 6 , 68 , Ledsuit
Showpic 6 , 100 , Leeg
Showpic 66 , 36 , Beidedeurenup
Showpic 66 , 68 , Beidedeurendown
Showpic 66 , 100 , Leeg
Showpic 126 , 36 , Linkerdeurup
Showpic 126 , 68 , Linkerdeurdown
Showpic 126 , 100 , Leeg
Showpic 186 , 36 , Rechterdeurup
Showpic 186 , 68 , Rechterdeurdown
Showpic 186 , 100 , Esc
Return


Showjaloezvoormenu:
Menu = 2 : Holdmenu = 0
Showpic 0 , 0 , Hjalvoor                                    'show a comnpressed picture
Showpic 6 , 36 , Pijlomhoog
Showpic 6 , 68 , Stopbutton
Showpic 6 , 100 , Pijlomlaag
Showpic 66 , 36 , Jalvf1
Showpic 66 , 68 , Jalvf3
Showpic 66 , 100 , Leeg
Showpic 126 , 36 , Jalvf2
Showpic 126 , 68 , Jalvf4
Showpic 126 , 100 , Leeg
Showpic 186 , 36 , Leeg
Showpic 186 , 68 , Leeg
Showpic 186 , 100 , Esc
Return


Showhoofdmenu:
Menu = 1 : Holdmenu = 0
Showpic 0 , 0 , Headerhoofdmenu                             'show a comnpressed picture
Showpic 6 , 36 , Lichteettafel
Showpic 66 , 36 , Lichtsalontafel
Showpic 126 , 36 , Lichtkeuken
Showpic 186 , 36 , Schemerlamp
Showpic 6 , 68 , Lichttuin
Showpic 66 , 68 , Leeg
Showpic 126 , 68 , Jalvoor
Showpic 186 , 68 , Jalachter
Showpic 6 , 100 , Wandmeubel
Showpic 66 , 100 , Versterker
Showpic 126 , 100 , Autoprog
Showpic 186 , 100 , Pijlrechts
Return

Showhoofdmenu2:
Menu = 21 : Holdmenu = 1
'Normaly the screen will go after 10sec back to the main menu. With Holdmenu=1 the screen will stay in this menu.
Showpic 0 , 0 , Hhoofdmenu2                                 'show a comnpressed picture
Showpic 6 , 36 , Leeg
Showpic 66 , 36 , Leeg
Showpic 126 , 36 , Leeg
Showpic 186 , 36 , Leeg
Showpic 6 , 68 , Leeg
Showpic 66 , 68 , Leeg
Showpic 126 , 68 , Leeg
Showpic 186 , 68 , Leeg
Showpic 6 , 100 , Pijllinks
Showpic 66 , 100 , Leeg
Showpic 126 , 100 , Leeg
Showpic 186 , 100 , Leeg
Return





Bepaaltoets:
Select Case X
            Case 160 To 317 : Col = 10
            Case 318 To 477 : Col = 20
            Case 478 To 633 : Col = 30
            Case 634 To 788 : Col = 40
            Case Else Col = 0
End Select
Select Case Y
            Case 329 To 414 : Row = 1
            Case 415 To 497 : Row = 2
            Case 498 To 584 : Row = 3
            Case 585 To 652 : Row = 4
            Case Else Row = 0
End Select
Key = Col + Row
'locate 4 , 2 : Lcd "Je drukte op knop ; " ; key
If Key > 0 Then
  Keyarray(keylus) = Key
  Incr Keylus
  If Keylus > 3 Then Keylus = 1
   If Keyarray(1) = Keyarray(2) Then
       If Keyarray(2) = Keyarray(3) Then
                  '  If Buzzertoggle = 0 then
                      Sound Speaker , 1 , 65000
                           Keypressed = Key
                           Gosub Showpressedkey
                           Tijdcount = 0
       End If
   End If
 End If
Return

Showpressedkey:                                             'Routine for "animated" buttons
Select Case Keypressed
Case 12
   Showpic 0 , 33 , Knopin
     Waitms Buttonreturndelay
   Showpic 0 , 33 , Knop
Case 13
   Showpic 0 , 65 , Knopin
     Waitms Buttonreturndelay
   Showpic 0 , 65 , Knop
Case 14
   Showpic 0 , 97 , Knopin
     Waitms Buttonreturndelay
   Showpic 0 , 97 , Knop
Case 22
   Showpic 61 , 33 , Knopin
     Waitms Buttonreturndelay
   Showpic 61 , 33 , Knop
Case 23
   Showpic 61 , 65 , Knopin
     Waitms Buttonreturndelay
   Showpic 61 , 65 , Knop
Case 24
   Showpic 61 , 97 , Knopin
     Waitms Buttonreturndelay
   Showpic 61 , 97 , Knop
Case 32
   Showpic 121 , 33 , Knopin
     Waitms Buttonreturndelay
   Showpic 121 , 33 , Knop
Case 33
   Showpic 121 , 65 , Knopin
     Waitms Buttonreturndelay
   Showpic 121 , 65 , Knop
Case 34
   Showpic 121 , 97 , Knopin
     Waitms Buttonreturndelay
   Showpic 121 , 97 , Knop
Case 42
Showpic 181 , 33 , Knopin
     Waitms Buttonreturndelay
   Showpic 181 , 33 , Knop
Case 43
Showpic 181 , 65 , Knopin
     Waitms Buttonreturndelay
   Showpic 181 , 65 , Knop
 Case 44
Showpic 181 , 97 , Knopin
     Waitms Buttonreturndelay
   Showpic 181 , 97 , Knop
End Select
Return

Showbasisknoppen:
Showpic 0 , 33 , Knop
Showpic 0 , 65 , Knop
Showpic 0 , 97 , Knop
Showpic 61 , 33 , Knop
Showpic 61 , 65 , Knop
Showpic 61 , 97 , Knop
Showpic 121 , 33 , Knop
Showpic 121 , 65 , Knop
Showpic 121 , 97 , Knop
Showpic 181 , 33 , Knop
Showpic 181 , 65 , Knop
Showpic 181 , 97 , Knop
Return

Readtouch:
Config Pinf.0 = Output
Config Pinf.2 = Output
Set Portf.0
Reset Portf.2
Ddrf.1 = 0 : Portf.1 = 1
Ddrf.3 = 0 : Portf.3 = 1
Waitms 20
Y = Getadc(3)
Y = 1024 - Y
'Locate 4 , 2 : Lcd "WAARDE X ; " ; X : Waitms 200
Config Pinf.1 = Output
Config Pinf.3 = Output
Set Portf.1
Reset Portf.3
Ddrf.0 = 0 : Portf.0 = 1
Ddrf.2 = 0 : Portf.2 = 1
Waitms 20
X = Getadc(2)
X = 1024 - X
'locate 4 , 2 : Lcd "WAARDE Y ; " ; Y :waitms 200
Return



Foutje:
Sound Speaker , 2 , 65000
Waitms 50
Return


Headerhoofdmenu:
$bgf "..\TouchbuttonsLarge\HeaderHoofdmenu.bgf"
Hhoofdmenu2:
$bgf "..\TouchbuttonsLarge\HHoofdmenu2.bgf"
Hjalvoor:
$bgf "..\TouchbuttonsLarge\HJalVoor.bgf"
Hwandmeubel:
$bgf "..\TouchbuttonsLarge\HWandmeubel.bgf"
Knop:
$bgf "..\TouchbuttonsLarge\knop.bgf"
Knopin:                                                     'Button pressed in
$bgf "..\TouchbuttonsLarge\knopin.bgf"
Leeg:
$bgf "..\TouchbuttonsLarge\Leeg.bgf"
Autoprog:
$bgf "..\TouchbuttonsLarge\Autoprog.bgf"
Lichtsalontafel:
$bgf "..\TouchbuttonsLarge\Lichtsalontafel.bgf"
Lichteettafel:
$bgf "..\TouchbuttonsLarge\Lichteettafel.bgf"
Lichtkeuken:
$bgf "..\TouchbuttonsLarge\LichtKeuken.bgf"
Lichttuin:
$bgf "..\TouchbuttonsLarge\LichtTuin.bgf"
Schemerlamp:
$bgf "..\TouchbuttonsLarge\Schemerlamp.bgf"
Jalvoor:
$bgf "..\TouchbuttonsLarge\Jalvoor.bgf"
Jalachter:
$bgf "..\TouchbuttonsLarge\JalAchter.bgf"
Wandmeubel:
$bgf "..\TouchbuttonsLarge\Wandmeubel.bgf"
Versterker:
$bgf "..\TouchbuttonsLarge\Versterker.bgf"
Pijlrechts:
$bgf "..\TouchbuttonsLarge\Pijlrechts.bgf"
Pijllinks:
$bgf "..\TouchbuttonsLarge\Pijllinks.bgf"
Pijlomhoog:
$bgf "..\TouchbuttonsLarge\Pijlomhoog.bgf"
Pijlomlaag:
$bgf "..\TouchbuttonsLarge\Pijlomlaag.bgf"
Jalvf1:
$bgf "..\TouchbuttonsLarge\JalvF1.bgf"
Jalvf2:
$bgf "..\TouchbuttonsLarge\JalvF2.bgf"
Jalvf3:
$bgf "..\TouchbuttonsLarge\JalvF3.bgf"
Jalvf4:
$bgf "..\TouchbuttonsLarge\JalvF4.bgf"
Esc:
$bgf "..\TouchbuttonsLarge\Esc.bgf"
Stopbutton:
$bgf "..\TouchbuttonsLarge\Stopbutton.bgf"
F1:
$bgf "..\TouchbuttonsLarge\F1.bgf"
F2:
$bgf "..\TouchbuttonsLarge\F2.bgf"
F3:
$bgf "..\TouchbuttonsLarge\F3.bgf"
F4:
$bgf "..\TouchbuttonsLarge\F4.bgf"
Linkerdeurup:
$bgf "..\TouchbuttonsLarge\Linkerdeurup.bgf"
Linkerdeurdown:
$bgf "..\TouchbuttonsLarge\Linkerdeurdown.bgf"
Rechterdeurup:
$bgf "..\TouchbuttonsLarge\Rechterdeurup.bgf"
Rechterdeurdown:
$bgf "..\TouchbuttonsLarge\Rechterdeurdown.bgf"
Beidedeurenup:
$bgf "..\TouchbuttonsLarge\Beidedeurenup.bgf"
Beidedeurendown:
$bgf "..\TouchbuttonsLarge\Beidedeurendown.bgf"
Ledsaan:
$bgf "..\TouchbuttonsLarge\Ledsaan.bgf"
Ledsuit:
$bgf "..\TouchbuttonsLarge\Ledsuit.bgf"