Skip to content

Commit 329d645

Browse files
add #define names
1 parent 54ed077 commit 329d645

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed
56.9 KB
Binary file not shown.

Code PlatformIO/gesture Control Final/include/main.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ extern "C"
7373

7474
/* Exported constants --------------------------------------------------------*/
7575
/* USER CODE BEGIN EC */
76-
#define amountSensor 5
77-
#define amountSensorUsed 3
76+
#define AMOUNT_SENSOR 5
77+
#define AMOUNT_SENSOR_USED 3
7878
/* USER CODE END EC */
7979

8080
/* Exported macro ------------------------------------------------------------*/

Code PlatformIO/gesture Control Final/lib/Gesture_Detect/src/GestureDetect.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "GestureDetect.h"
22

33
//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];
66

77
static bool LR_links = false;
88
static bool LR_rechts = false;
@@ -31,65 +31,65 @@ bool checkIndex(uint8_t id);
3131
commands detectgesture(int16_t left, int8_t leftStatus, int16_t center, int8_t centerStatus, int16_t right, int8_t rightStatus)
3232
{
3333
// 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)
3535
{
3636
DU_onder = true;
3737
}
3838

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)
4040
{
4141
DU_center = true;
4242
}
4343

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)
4545
{
4646
DU_boven = true;
4747
}
4848

4949
// 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)
5151
{
5252
UD_boven = true;
5353
}
5454

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)
5656
{
5757
UD_center = true;
5858
}
5959

60-
if (left < maxDistance && leftStatus == 0 && UD_center && UD_boven)
60+
if (left < MAX_DISTANCE && leftStatus == 0 && UD_center && UD_boven)
6161
{
6262
UD_onder = true;
6363
}
6464

6565
// 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)
6767
{
6868
LR_links = true;
6969
}
7070

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)
7272
{
7373
LR_center = true;
7474
}
7575

76-
if (right < maxDistance && rightStatus == 0 && LR_center && LR_links)
76+
if (right < MAX_DISTANCE && rightStatus == 0 && LR_center && LR_links)
7777
{
7878
LR_rechts = true;
7979
}
8080

8181
// 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)
8383
{
8484
RL_rechts = true;
8585
}
8686

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)
8888
{
8989
RL_center = true;
9090
}
9191

92-
if (left < maxDistance && leftStatus == 0 && RL_center && RL_rechts)
92+
if (left < MAX_DISTANCE && leftStatus == 0 && RL_center && RL_rechts)
9393
{
9494
RL_links = true;
9595
}
@@ -125,7 +125,7 @@ void checkResetTimer()
125125
timerMeasurment = HAL_GetTick();
126126
}
127127
long temp = HAL_GetTick();
128-
if (timerMeasurementSet && (temp - timerMeasurment) > timerMeasurmentTimeout)
128+
if (timerMeasurementSet && (temp - timerMeasurment) > TIMER_MEASUREMENT_TIMEOUT)
129129
{
130130
timerMeasurementSet = false;
131131
DU_boven = false;
@@ -146,11 +146,11 @@ void checkResetTimer()
146146
int16_t getMean(uint8_t id)
147147
{
148148
tempMean = 0;
149-
for (size_t i = 0; i < maxMean; i++)
149+
for (size_t i = 0; i < MAX_MEAN; i++)
150150
{
151151
tempMean += disMean[id][i];
152152
}
153-
tempMean /= maxMean;
153+
tempMean /= MAX_MEAN;
154154
return tempMean;
155155
}
156156
int getCountMean(uint8_t id)
@@ -168,14 +168,14 @@ void setMeanVal(uint8_t id, int16_t distance)
168168
}
169169
uint8_t getMaxMean()
170170
{
171-
return maxMean;
171+
return MAX_MEAN;
172172
}
173173
uint8_t getMaxDis()
174174
{
175-
return maxDistance;
175+
return MAX_DISTANCE;
176176
}
177177
bool checkIndex(uint8_t id){
178-
if (disMeanindex[id] < maxMean - 1)
178+
if (disMeanindex[id] < MAX_MEAN - 1)
179179
disMeanindex[id]++;
180180
else
181181
disMeanindex[id] = 0;

Code PlatformIO/gesture Control Final/lib/Gesture_Detect/src/GestureDetect.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include "main.h"
1818
#include "stdbool.h"
1919

20-
#define maxMean 4
21-
#define maxDistance 300
22-
#define timerMeasurmentTimeout 1500U
20+
#define MAX_MEAN 4
21+
#define MAX_DISTANCE 300
22+
#define TIMER_MEASUREMENT_TIMEOUT 1500U
2323

2424

2525
/**

Code PlatformIO/gesture Control Final/lib/Gesture_Detect/src/calibrationData.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ VL53LX_CalibrationData_t getCalibrationData(VL53L3CX_Object_t *dev)
131131
}
132132
void setCalibrationData(VL53L3CX_Object_t *dev, uint8_t index, VL53LX_CalibrationData_t *data)
133133
{
134-
int xtalk_kcps[amountSensorUsed][6] = {
134+
int xtalk_kcps[AMOUNT_SENSOR_USED][6] = {
135135
{8543, 16939, 25335, 33731, 42127, 50523},
136136
{7912, 15684, 23456, 31228, 39000, 46772},
137137
{2742, 5456, 8170, 10884, 13598, 16314}};
138138

139-
int xtalk_bin_data[amountSensorUsed][12] = {
139+
int xtalk_bin_data[AMOUNT_SENSOR_USED][12] = {
140140
{2, 423, 458, 141, 0, 0, 0, 0, 0, 0, 0, 0},
141141
{20, 446, 447, 111, 0, 0, 0, 0, 0, 0, 0, 0},
142142
{24, 416, 479, 105, 0, 0, 0, 0, 0, 0, 0, 0}};

Code PlatformIO/gesture Control Final/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
/* Private variables ---------------------------------------------------------*/
6060

6161
/* USER CODE BEGIN PV */
62-
volatile uint8_t isReady[amountSensor] = {false, false, false,false,false};
63-
volatile uint8_t hasRead[amountSensor] = {false, false, false, false, false};
62+
volatile uint8_t isReady[AMOUNT_SENSOR] = {false, false, false,false,false};
63+
volatile uint8_t hasRead[AMOUNT_SENSOR] = {false, false, false, false, false};
6464

6565
#ifdef DATACOLLECTION
6666
long timerDataCollection = 0;
@@ -74,7 +74,7 @@ Sensor_Definition_t left = {XSHUT_1, 1};
7474
Sensor_Definition_t right = {XSHUT_3, 2};
7575

7676
// Resultaat van de meetingen die de afstand, status en timestamp bevat voor amountSensorUsed aantal keer aangemaakt
77-
struct resultaat resultaat[amountSensorUsed];
77+
struct resultaat resultaat[AMOUNT_SENSOR_USED];
7878

7979
bool objectPresent = false;
8080
bool prevObjectPresent = false;
@@ -129,7 +129,7 @@ int main(void)
129129

130130
/* USER CODE BEGIN SysInit */
131131
// Define de sensor objecten amountSensorUsed keer.
132-
VL53L3CX_Object_t sensor[amountSensorUsed];
132+
VL53L3CX_Object_t sensor[AMOUNT_SENSOR_USED];
133133
/* USER CODE END SysInit */
134134

135135
/* Initialize all configured peripherals */

0 commit comments

Comments
 (0)