1
1
#include "GestureDetect.h"
2
2
3
3
//variabelen die niet mogen veranderen na weg gaan van methodes
4
- static int disMean [amountSensorUsed ][ maxMean ];
5
- static uint8_t disMeanindex [amountSensorUsed ];
4
+ static int disMean [AMOUNT_SENSOR_USED ][ MAX_MEAN ];
5
+ static uint8_t disMeanindex [AMOUNT_SENSOR_USED ];
6
6
7
7
static bool LR_links = false;
8
8
static bool LR_rechts = false;
@@ -31,65 +31,65 @@ bool checkIndex(uint8_t id);
31
31
commands detectgesture (int16_t left , int8_t leftStatus , int16_t center , int8_t centerStatus , int16_t right , int8_t rightStatus )
32
32
{
33
33
// DU gesture
34
- if (left < maxDistance && (leftStatus == 0 || leftStatus == 7 ) && !DU_center && !DU_boven && center > maxDistance && right > maxDistance )
34
+ if (left < MAX_DISTANCE && (leftStatus == 0 || leftStatus == 7 ) && !DU_center && !DU_boven && center > MAX_DISTANCE && right > MAX_DISTANCE )
35
35
{
36
36
DU_onder = true;
37
37
}
38
38
39
- if (right < maxDistance && (rightStatus == 0 || rightStatus == 7 ) && !DU_center && DU_onder && center > maxDistance )
39
+ if (right < MAX_DISTANCE && (rightStatus == 0 || rightStatus == 7 ) && !DU_center && DU_onder && center > MAX_DISTANCE )
40
40
{
41
41
DU_center = true;
42
42
}
43
43
44
- if (center < maxDistance && (centerStatus == 0 || centerStatus == 7 ) && DU_center && DU_onder )
44
+ if (center < MAX_DISTANCE && (centerStatus == 0 || centerStatus == 7 ) && DU_center && DU_onder )
45
45
{
46
46
DU_boven = true;
47
47
}
48
48
49
49
// UD gesture
50
- if (center < maxDistance && centerStatus == 0 && !UD_center && !UD_onder && left > maxDistance && right > maxDistance )
50
+ if (center < MAX_DISTANCE && centerStatus == 0 && !UD_center && !UD_onder && left > MAX_DISTANCE && right > MAX_DISTANCE )
51
51
{
52
52
UD_boven = true;
53
53
}
54
54
55
- if (right < maxDistance && rightStatus == 0 && !UD_onder && UD_boven && left > maxDistance )
55
+ if (right < MAX_DISTANCE && rightStatus == 0 && !UD_onder && UD_boven && left > MAX_DISTANCE )
56
56
{
57
57
UD_center = true;
58
58
}
59
59
60
- if (left < maxDistance && leftStatus == 0 && UD_center && UD_boven )
60
+ if (left < MAX_DISTANCE && leftStatus == 0 && UD_center && UD_boven )
61
61
{
62
62
UD_onder = true;
63
63
}
64
64
65
65
// LR gesture
66
- if (left < maxDistance && leftStatus == 0 && !LR_center && !LR_rechts && center > maxDistance && right > maxDistance )
66
+ if (left < MAX_DISTANCE && leftStatus == 0 && !LR_center && !LR_rechts && center > MAX_DISTANCE && right > MAX_DISTANCE )
67
67
{
68
68
LR_links = true;
69
69
}
70
70
71
- if (center < maxDistance && centerStatus == 0 && !LR_rechts && LR_links && right > maxDistance )
71
+ if (center < MAX_DISTANCE && centerStatus == 0 && !LR_rechts && LR_links && right > MAX_DISTANCE )
72
72
{
73
73
LR_center = true;
74
74
}
75
75
76
- if (right < maxDistance && rightStatus == 0 && LR_center && LR_links )
76
+ if (right < MAX_DISTANCE && rightStatus == 0 && LR_center && LR_links )
77
77
{
78
78
LR_rechts = true;
79
79
}
80
80
81
81
// RL gesture
82
- if (right < maxDistance && rightStatus == 0 && !RL_center && !RL_links && center > maxDistance && left > maxDistance )
82
+ if (right < MAX_DISTANCE && rightStatus == 0 && !RL_center && !RL_links && center > MAX_DISTANCE && left > MAX_DISTANCE )
83
83
{
84
84
RL_rechts = true;
85
85
}
86
86
87
- if (center < maxDistance && centerStatus == 0 && !RL_links && RL_rechts && left > maxDistance )
87
+ if (center < MAX_DISTANCE && centerStatus == 0 && !RL_links && RL_rechts && left > MAX_DISTANCE )
88
88
{
89
89
RL_center = true;
90
90
}
91
91
92
- if (left < maxDistance && leftStatus == 0 && RL_center && RL_rechts )
92
+ if (left < MAX_DISTANCE && leftStatus == 0 && RL_center && RL_rechts )
93
93
{
94
94
RL_links = true;
95
95
}
@@ -125,7 +125,7 @@ void checkResetTimer()
125
125
timerMeasurment = HAL_GetTick ();
126
126
}
127
127
long temp = HAL_GetTick ();
128
- if (timerMeasurementSet && (temp - timerMeasurment ) > timerMeasurmentTimeout )
128
+ if (timerMeasurementSet && (temp - timerMeasurment ) > TIMER_MEASUREMENT_TIMEOUT )
129
129
{
130
130
timerMeasurementSet = false;
131
131
DU_boven = false;
@@ -146,11 +146,11 @@ void checkResetTimer()
146
146
int16_t getMean (uint8_t id )
147
147
{
148
148
tempMean = 0 ;
149
- for (size_t i = 0 ; i < maxMean ; i ++ )
149
+ for (size_t i = 0 ; i < MAX_MEAN ; i ++ )
150
150
{
151
151
tempMean += disMean [id ][i ];
152
152
}
153
- tempMean /= maxMean ;
153
+ tempMean /= MAX_MEAN ;
154
154
return tempMean ;
155
155
}
156
156
int getCountMean (uint8_t id )
@@ -168,14 +168,14 @@ void setMeanVal(uint8_t id, int16_t distance)
168
168
}
169
169
uint8_t getMaxMean ()
170
170
{
171
- return maxMean ;
171
+ return MAX_MEAN ;
172
172
}
173
173
uint8_t getMaxDis ()
174
174
{
175
- return maxDistance ;
175
+ return MAX_DISTANCE ;
176
176
}
177
177
bool checkIndex (uint8_t id ){
178
- if (disMeanindex [id ] < maxMean - 1 )
178
+ if (disMeanindex [id ] < MAX_MEAN - 1 )
179
179
disMeanindex [id ]++ ;
180
180
else
181
181
disMeanindex [id ] = 0 ;
0 commit comments