-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyProcess.cpp
More file actions
75 lines (65 loc) · 1.84 KB
/
Copy pathKeyProcess.cpp
File metadata and controls
75 lines (65 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "KeyProcess.h"
#include "mbed.h"
#include "Key_Configure.h"
//bool KeyProcess::delay_timeout=1;
void KeyProcess::TriggerTime(uint16_t DelayTimes,uint16_t CycleTimes)
{
this->DelayTimes=DelayTimes;this->CycleTimes=CycleTimes;
}
void KeyProcess::process()
{
if(!State)//NO KEY
{
//Cycle.stop();
return;
}
if(State==FIRST_KEY)
{
Trans_flag=1;
Cycle.reset();
if(Delay_flag && TriggerFlag[FIRST_KEY])
{
// First Key set Timer
Delay_flag=0;
Cycle.start();
Delay.attach(this,&KeyProcess::DelayTimeOut,DelayTimes/1000.0f);
ProcessState=FIRST_KEY;
//FIRST
}
else
ProcessState=NO_KEY;
}
else if((TriggerFlag[HOLD_KEY]||TriggerFlag[TRANS_KEY_ONCE]||TriggerFlag[TRANS_KEY_REPEAT])
&& State==HOLD_KEY
&& ((Cycle.read_ms()>=WaitTimes && Trans_flag) || (Cycle.read_ms()>=CycleTimes && !Trans_flag)) )
{
if(Trans_flag && TriggerFlag[TRANS_KEY_ONCE])//Got problem Here
{
ProcessState=TRANS_KEY_ONCE;
//State=NO_KEY;
//return;
}
else if(TriggerFlag[HOLD_KEY])
{
ProcessState=HOLD_KEY;
//HOLD KEY
}
else if(TriggerFlag[TRANS_KEY_REPEAT])
{
ProcessState=TRANS_KEY_REPEAT;
}
else
ProcessState=NO_KEY;
Cycle.reset();
Trans_flag=0;
}
else if(TriggerFlag[RELEASE_KEY] && State==RELEASE_KEY)
{
ProcessState=RELEASE_KEY;
//Cycle.reset();
//t.stop();
}
else
ProcessState=NO_KEY;
State=NO_KEY;
}