$regfile = "m128can.dat"
$crystal = 16000000
$hwstack = 200
$swstack = 200
$framesize = 700
$notypecheck
Config Ft800 = Spi , Ftsave = 0 , Ftdebug = 0 , Ftcs = Portb.0 , Ftpd = Portb.7
Config Base = 0
Config Submode = New
Config Spihard = Hard, Interrupt = Off, Data_Order = Msb, Master = Yes, Polarity = Low, Phase = 0, Clockrate = 4, Noss = 1
Spsr = 1 ' Makes SPI run at double speed
$include "FT800.inc"
$include "FT800_Functions.inc"
Dim Obroty As Word , Temperatura As Word , Advance As Byte , Pasek As Word , Procent As Word , Startt As Bit
Dim tagx As Byte
Dim opt 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 Flag As Byte
Declare Sub Screen1
Declare Function Read_keypad() As Byte
Declare Function Istouch() As Byte
Const Maxx = 1
Const Minn = 3
Const Midd = 2
Const Menu = 4
Const Badvance = 5
Const Res = 6
Const Start_stop = 7
Key_detect Alias 0
Spiinit
If Ft800_init() = 1 Then End
Do
Read_sfk = Read_keypad()
If Flag.key_detect > 0 Then
Flag.key_detect = 0
If Read_sfk = Badvance Then
Toggle Advance
End If
If Read_sfk = Start_stop Then
Toggle Startt
End If
If Read_sfk = Res Then
Config Watchdog = 16
Start Watchdog
Do
Loop
End If
End If
Call Screen1
Waitms 10
Loop
Function Read_Keypad() As Byte
'------------------------------------------------------------------------------------------------------------
Local Read_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
Sub Screen1
Clearscreen
Clearcolorrgb &HA0 , &HA0 , &HA0
Clear_b 1 , 1 , 1
'------------------------------buttons----------------------------------------
'CmdButton x, y, w, h ,font, options, text
Cmdfgcolor Black
Cmdgradcolor White
Tag Maxx
Cmdbutton 260 , 8 , 85 , 30 , 28 , 0 , "Max"
Cmdfgcolor Black
Cmdgradcolor White
Tag Midd '
Cmdbutton 260 , 39 , 85 , 30 , 28 , 0 , "Mid"
Cmdfgcolor Black
Cmdgradcolor White
Tag Minn
Cmdbutton 260 , 69 , 85 , 30 , 28 , 0 , "Min"
Cmdfgcolor Black
Cmdgradcolor White
Tag Menu
Cmdbutton 360 , 8 , 114 , 32 , 28 , 0 , "Menu"
Cmdfgcolor Black
Cmdgradcolor White
Tag Start_stop
Cmdbutton 360 , 177 , 114 , 58 , 28 , 0 , "Start/Stop"
'------------------------------------- dial gauge------------------------------
'
'CmdGauge x, y, r, options, major, minor, val, range
Cmdbgcolor &H0066CC
Colorrgb &H00 , &H00 , &H00
Cmdgauge 130 , 130 , 125 , 0 , 10 , 5 , Obroty , 2000
Cmdfgcolor Blue
Cmdgradcolor Black
'
'------------------------------progress bar------------------------------------
'CmdProgress x, y, w, h, options, val, range
Colorrgb &H99 , &HCC , &HFF
Cmdbgcolor &H606060
Cmdprogress 232 , 245 , 235 , 25 , 0 , Pasek , 999
Procent = Pasek / 10
If Procent > 35 Then Colorrgb &H00 , &H00 , &H00 Else Colorrgb &HFF , &HFF , &H00
Cmdnumber 320 , 245 , 23 , 0 , Procent
Cmdtext 350 , 245 , 23 , 0 , "%"
'-----------------------------------------LED----------------------------------
'CmdDial x, y, r ,options, val
If Startt = 0 Then
Cmdfgcolor &HFF0000
'Cmdbgcolor &H000080
Cmddial 460 , 190 , 7 , 0 , &H8000
End If
If Startt = 255 Then
Cmdfgcolor &H00FF00
Cmddial 460 , 190 , 7 , 0 , &H8000
End If
'--------------------------------Temperature------------------------------------
'CmdProgress x, y, w, h, options, val, range
Colorrgb &HFF , &H00 , &H00
Cmdbgcolor &H606060
Cmdprogress 268 , 134 , 180 , 22 , 0 , Temperatura , 100
Colorrgb &HFF , &HFF , &HFF
Cmdtext 350 , 134 , 22 , 0 , "C'"
Cmdnumber 320 , 134 , 22 , 0 , Temperatura
'-----------------------------------scale dial--------------------------------------------
Colorrgb &H00 , &H00 , &H
Cmdtext 63 , 204 , 21 , 0 , "0"
Cmdtext 10 , 154 , 21 , 0 , "200"
Cmdtext 8 , 105 , 21 , 0 , "400"
Cmdtext 25 , 60 , 21 , 0 , "600"
Cmdtext 60 , 30 , 21 , 0 , "800"
Cmdtext 110 , 10 , 22 , 0 , "1000"
Cmdtext 175 , 30 , 21 , 0 , "1200"
Cmdtext 210 , 60 , 21 , 0 , "1400"
Cmdtext 228 , 105 , 21 , 0 , "1600"
Cmdtext 225 , 154 , 21 , 0 , "1800"
Cmdtext 180 , 204 , 21 , 0 , "2000"
Cmdnumber 100 , 180 , 25 , 0 , Obroty
'---------------------------------------------reset----------------------
Tag Res '
Cmdgradcolor White
'Cmdbgcolor White
Cmdfgcolor Blue
Colorrgb 255 , 255 , 255
Cmdbutton 4 , 234 , 34 , 34 , 28 , 0 , "R"
'-------------------------------Advance----------------------toggle switch------------
If Advance = 0 Then
Colorrgb &HFF , &HFF , &HFF
Cmdbgcolor Red
Cmdfgcolor White
Tag Badvance
Cmdtoggle 255 , 198 , 80 , 27 , 0 , 0 , "Off" + Gap + "On" ' 0=off 198
End If
If Advance = 255 Then
Colorrgb &HFF , &HFF , &HFF
Cmdbgcolor Green
Cmdfgcolor White
Tag Badvance
Cmdtoggle 255 , 198 , 80 , 27 , 0 , 65535 , "Off" + Gap + "On" '65535=on
End If
Updatescreen
End Sub
|