$regfile = "m32def.dat"
$crystal = 8000000
$lib "glcdks108.lib"
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portd , Ce = 3 , Ce2 = 4 , Cd = 0 , Rd = 1 , Reset = 6 , Enable = 2 'Config Graphic LCD Pins
Config Adc = Single , Prescaler = Auto , Reference = Avcc 'Config A/D Devices
Config Portc = Output : 'Normaly Off
Dim X As Word , Y As Word 'Dimension X And Y For Touch Pad
Dim Lcds As Byte : Lcds = 1 'Dimension Picture Number Variable
Dim Row As Byte , Col As Byte 'Dimension Row And Col Variable
Dim Inter As Byte
Cls
'Cd = Rs
'Ce = Cs1
'Ce2 = Cs2
'Rd = R/W
'Enable = E
'Vcc = RST = VCC
Up:
Do
Gosub Readtouch 'Read Where is Selected
Gosub Whichkey 'Read Which Key is Selected
Gosub Glcd 'Change LCD Statues
Waitms 220
Loop
End 'END Of Program
Readtouch:
Config Pina.0 = Output ' Makes port A.0 output
Config Pina.2 = Output ' Makes port A.0 output
Set Porta.0 ' Sets port A.0 High
Reset Porta.2 ' Sets port A.2 Low
Ddra.1 = 0 ' Sets port A.1 as input
Ddra.3 = 0 ' Sets port A.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
'Print "VALUE Y : " ; Y ' for debugging
Config Pina.1 = Output ' Makes port A.1 output
Config Pina.3 = Output ' Makes port A.3 output
Reset Porta.1 ' Sets port A.1 Low
Set Porta.3 ' Sets port A.3 High
Ddra.0 = 0 ' Sets port A.0 as input
Ddra.2 = 0 ' Sets port A.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
'Print "VALUE X : " ; X
Return
Whichkey:
Select Case X ' For the Column value
Case 740 To 900 : Col = 1
Case 130 To 300 : Col = 2
Case Else Col = 0
End Select
Select Case Y ' For the Row value
Case 225 To 490 : Row = 1
Case 560 To 800 : Row = 2
Case Else Row = 0
End Select
'Select State
If Col = 1 And Row = 1 Then
Incr Lcds
If Lcds > 8 Then Lcds = 8
End If
If Col = 2 And Row = 1 Then
Inter = Lcds - 1
Reset Portc.inter
End If
If Col = 1 And Row = 2 Then
Decr Lcds
If Lcds < 1 Then Lcds = 1
End If
If Col = 2 And Row = 2 Then
Inter = Lcds - 1
Set Portc.inter
End If
Return
Glcd:
Select Case Lcds
Case 1 : Showpic 0 , 0 , 1
Case 2 : Showpic 0 , 0 , 2
Case 3 : Showpic 0 , 0 , 3
Case 4 : Showpic 0 , 0 , 4
Case 5 : Showpic 0 , 0 , 5
Case 6 : Showpic 0 , 0 , 6
Case 7 : Showpic 0 , 0 , 7
Case 8 : Showpic 0 , 0 , 8
End Select
Return
'Graphic Character's
1:
$bgf "1.bgf"
2:
$bgf "2.bgf"
3:
$bgf "3.bgf"
4:
$bgf "4.bgf"
5:
$bgf "5.bgf"
6:
$bgf "6.bgf"
7:
$bgf "7.bgf"
8:
$bgf "8.bgf"