$regfile = "m128def.dat"
$crystal = 16000000
$hwstack = 500
$swstack = 500
$framesize = 250
$lib "XV-TFT.lib"
' SPI Definition für das Display
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 16 , Noss = 1
Spiinit
$include "init_xv_tft.bas" 'Die Routinen der Library einbinden
Config Pine.7 = Input 'Encoder
Config Pine.6 = Input 'Encoder
Porte.6 = 1 'Pullup einschalten
Porte.7 = 1 'Pullup einschalten
Enable Interrupts 'Interrups aktivieren
Enable Int7
Config Int7 = Change 'INT7 bei wechselnder Flanke
On Int7 Encodea 'bei Interrupt Springe in Encoderdecodierung
Dim A As Byte 'Encoder Zählvariable
A = 0
Config Portf = Output 'Port zur Signalisierung LEDs
Portf = A
Declare Sub Set_button
Declare Sub Read_button
' Variablen Definitionen
Dim I As Word
Dim X1(20) As Word
Dim Y1(20) As Word
Dim Button_text(20) As String * 10
Dim Button_nr As Word
'Programmbeginn
Wait 1
Bitwait Display_busy , Set 'Auf Initialisierung Display warten
Call Touchpanel_setconfig(&H0000001)
Call Setdisplaymode(displaymode_landscape)
Call Setbacklightintensity(255) 'Max. Backlight Brightness
'Call Set_font(8)
Call Setuserflashmemoryfont(1 , 0) 'User Font 0 = Ariel 1 = Calibri
Do
Call Setpencolor(0 , 0 , 0)
Call Setbrushcolor(255 , 255 , 255)
Call Fillscreen_brushcolor() 'Clear Screen
Call Setbrushcolor(255 , 255 , 255)
X1(1) = 2 : Y1(1) = 2 : Button_text(1) = "ANT1" 'ANT1B
X1(2) = 55 : Y1(2) = 2 : Button_text(2) = "ANT2" 'ANT1B
X1(3) = 2 : Y1(3) = 187 : Button_text(3) = " 160" '160B
X1(4) = 55 : Y1(4) = 187 : Button_text(4) = " 80" '80B
X1(5) = 108 : Y1(5) = 187 : Button_text(5) = " 40" '40B
X1(6) = 161 : Y1(6) = 187 : Button_text(6) = " 30" '30B
X1(7) = 214 : Y1(7) = 187 : Button_text(7) = "Beam" 'BeamB
X1(8) = 267 : Y1(8) = 187 : Button_text(8) = " Man" 'ManB
For I = 1 To 8
Call Set_button
Next I
Call Read_button
Call Displaydecimal16(10 , 80 , Button_nr )
Wait 1
Loop
'ende Hauptschleife
Sub Set_button
Local X2 As Word
Local Y2 As Word
Local Xt As Word
Local Yt As Word
Call Setbrushcolor(51 , 180 , 255) 'Hintergrund hellblau einstellen
X2 = X1(i) + 50 : Y2 = Y1(i) + 50
Xt = X1(i) + 5 : Yt = Y1(i) + 18
Call Drawrect_brushcolorfill(x1(i) , Y1(i) , X2 , Y2) 'Butten setzen
Call Drawrect_pencolor(x1(i) , Y1(i) , X2 , Y2)
Call Displaytext(xt , Yt , Button_text(i) )
End Sub
Sub Read_button
Local I As Word
Local X2 As Word
Local Y2 As Word
Do
Loop Until Display_tint = 0 'warten bis Touchmeldung am Pin B6 erfolgt
Call Touchpanel_readevent()
If T_event.0 = 1 Then Call Touchpanel_readdown() 'Koordinaten abfragen
For I = 1 To 8 'betätigten Butten ermitteln
X2 = X1(i) + 50 : Y2 = Y1(i) + 50
If Xwert > X1(i) And Xwert < X2 And Ywert > Y1(i) And Ywert < Y2 Then Button_nr = I
Next I
End Sub
End
'Interruptroutine Encoderdecodierung ==========================================================
Encodea:
If Pine.6 = 0 And Pine.7 = 1 Then A = A + 1
If Pine.6 = 1 And Pine.7 = 0 Then A = A + 1
If Pine.6 = 1 And Pine.7 = 1 Then A = A - 1
If Pine.6 = 0 And Pine.7 = 0 Then A = A - 1
Portf = A
Return