$regfile = "xm128a1def.dat"
$crystal = 32000000
$hwstack = 52
$swstack = 80
$framesize = 64
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz
Config Vport0 = C
Ddr0 = &B0000_0011
'configure the priority
Config Priority = Static , Vector = Application , Lo = Enabled
Config Com3 = 9600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM3:" For Binary As #1
Config Submode = New
Config Ft800 = Spid , Ftcs = Port0.6 , Ftpd = Port0.7
Config Spid = Hard , Master = Yes , Mode = 0 , Clockdiv = Clk32 , Data_order = Msb , Ss = None
Config Base = 0
$include "FT800.inc"
$include "FT800_Functions.inc"
Declare Sub Widgets
Declare Function Read_keypad() As Byte
Declare Function Istouch() As Byte
Dim My_cnt As Byte
Dim My_text As String * 5
Dim Read_tag As Byte
Dim Temp_tag As Byte ' used in Read_Keys() Function
Dim Sk As Byte ' used in Read_Keys() Function
Dim Read_sfk As Byte
Dim Touch_detect As Byte
Dim Tagx As Byte
Dim Opt As Byte
Dim M As Byte , N As Byte , P As Byte
Dim Read_widget As Byte
Dim Retistouch As Word
Dim Readword As Dword
Dim Tmp As Dword
Dim Flag As Byte
Key_detect Alias 0
My_text = " "
N = 31 'font size
Flag = 0
M = 0
P = 0
Spiinit
If Ft800_init() = 1 Then End
Do
Waitms 15
Incr M
My_text = Str(m)
Widgets
Loop
End
'------------------------------------------------------------------------------------------------------------
Sub Widgets
'------------------------------------------------------------------------------------------------------------
Clearcolorrgb 64 , 64 , 64
Clear_b 1 , 1 , 1
Colorrgb 255 , 255 , 255
' Flat effect and default Color background
Cmdfgcolor &H0000FF
Tagmask 1
Tag 1
Cmdnumber 50 , 30 , 29 , 0 , M
Tag 2
Cmdnumber 245 , 30 , 29 , 0 , M
Tag 3
Cmdnumber 50 , 150 , 29 , 0 , M
Tag 4
Cmdnumber 244 , 150 , 29 , 0 , M
Tag 5
Cmdbutton 300 , 200 , 100 , 50 , N , 0 , My_text
Tagmask 0
Read_widget = Read_keypad()
If Flag.key_detect > 0 Then
Flag.key_detect = 0
If Read_widget = 5 Then
P = Not P
If P = 255 Then
N = 31
'P = 0
Updatescreen
End If
If P = 0 Then
N = 20
'P = 1
Updatescreen
End If
End If
End If
Updatescreen
End Sub ' Widget_Button
'------------------------------------------------------------------------------------------------------------
Function Read_keypad() As Byte
Local Read_tag As Byte
Local Ret_tag As Byte
Read_tag = Rd8(reg_touch_tag)
If Istouch() = 0 Then Touch_detect = 0
If Read_tag <> 0 Then ' Allow if the Key is released
If Temp_tag <> Read_tag And Touch_detect = 0 Then
Temp_tag = Read_tag ' Load the Read tag to temp variable
Touch_detect = 1
End If
Else
If Temp_tag <> 0 Then
Flag.key_detect = 1
Read_tag = Temp_tag
End If
Temp_tag = 0
End If
Read_keypad = Read_tag
End Function ' Read_Keypad
'------------------------------------------------------------------------------------------------------------
Function Istouch() As Byte
Local Retistouch As Word
Retistouch = Rd16(reg_touch_raw_xy)
Retistouch = Retistouch And &H8000
Istouch = Retistouch
End Function |