|
楼主 |
发表于 2010-1-15 19:32:16
|
显示全部楼层
以下是电容触摸板的程序模块:
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\电容触摸板传感器缓存
Dim Cap(8) As Byte , Cap_tmp As Byte , Cap_smp(2) As Byte , Cap_smo(2) As Byte
Dim Cap_vol As Byte , Cap_lock As Byte
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\电容 (提供cap_vol)
Cap_sensor:
For Cap_tmp = 1 To 8
Cap(cap_tmp) = 0
Next Cap_tmp
Cap_tmp = 0
Config Porte.2 = Output
Porte.2 = 0 : Waitms 1
Config Porte.2 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.2 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp > 3 Then Cap(1) = 1
Cap_tmp = 0
Config Porte.3 = Output
Porte.3 = 0 : Waitms 1
Config Porte.3 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.3 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp > 4 Then Cap(2) = 1
Cap_tmp = 0
Config Porte.4 = Output
Porte.4 = 0 : Waitms 1
Config Porte.4 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.4 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp > 4 Then Cap(3) = 1
Cap_tmp = 0
Config Porte.5 = Output
Porte.5 = 0 : Config Porte.5 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.5 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp < 3 Then Cap(4) = 1
Cap_tmp = 0 : Config Porte.6 = Output
Porte.6 = 0
Config Porte.6 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.6 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp < 3 Then Cap(5) = 1
Cap_tmp = 0
Config Porte.7 = Output
Porte.7 = 0 : Config Porte.7 = Input
Do
Cap_tmp = Cap_tmp + 1
If Pine.7 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp < 3 Then Cap(6) = 1
Cap_tmp = 0
Config Portg.0 = Output
Portg.0 = 0 : Config Portg.0 = Input
Do
Cap_tmp = Cap_tmp + 1
If Ping.0 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp > 3 Then Cap(7) = 1
Cap_tmp = 0
Config Portg.1 = Output
Portg.1 = 0 : Config Portg.1 = Input
Do
Cap_tmp = Cap_tmp + 1
If Ping.1 = 1 Or Cap_tmp > 50 Then Exit Do
Loop
If Cap_tmp < 3 Then Cap(8) = 1
If Cap(1) = 1 Or Cap(2) = 1 Or Cap(3) = 1 Or Cap(4) = 1 Or Cap(5) = 1 Or Cap(6) = 1 Or Cap(7) = 1 Or Cap(8) = 1 Then
Cap_smp(1) = 0 : Cap_smp(2) = 0
If Cap(1) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(2) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(3) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(4) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(5) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(6) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(7) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
If Cap(8) = 0 Then
Cap_smp(1) = Cap_smp(1) + 1
End If
End If
End If
End If
End If
End If
End If
End If
If Cap_smo(1) > Cap_smp(1) Then
Cap_smo(1) = Cap_smp(1)
If Cap_lock = 1 Then Cap_vol = Cap_vol - 6
Cap_lock = 1
End If
If Cap_smo(1) < Cap_smp(1) Then
Cap_smo(1) = Cap_smp(1)
If Cap_lock = 1 Then Cap_vol = Cap_vol + 6
Cap_lock = 1
End If
Else
Cap_lock = 0
End If
Return
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\电容 -end |
|