|
@@ -3,7 +3,7 @@
|
3
|
3
|
#include "DriverJeuLaser.h"
|
4
|
4
|
|
5
|
5
|
|
6
|
|
-#define SEUIL_MIN 0x00093510
|
|
6
|
+#define SEUIL_MIN 0x00020510
|
7
|
7
|
#define SEUIL_MAX 0x01933510
|
8
|
8
|
|
9
|
9
|
|
|
@@ -25,7 +25,7 @@ short int dma_buff[64] ;
|
25
|
25
|
|
26
|
26
|
int res[4];
|
27
|
27
|
|
28
|
|
-char cible_active;
|
|
28
|
+char cible_active, LED_cible_active;
|
29
|
29
|
|
30
|
30
|
typedef struct {
|
31
|
31
|
short int valeur_k, score, confirmations;
|
|
@@ -41,22 +41,44 @@ void jouerSon() {
|
41
|
41
|
|
42
|
42
|
|
43
|
43
|
void changer_cible(){
|
44
|
|
-
|
|
44
|
+
|
45
|
45
|
int i;
|
46
|
46
|
|
47
|
47
|
for(i = 0; i < 4; i++){
|
48
|
|
- tous_joueurs[i].confirmations = 0;
|
49
|
48
|
Prepare_Afficheur(i+1,tous_joueurs[i].score);
|
50
|
49
|
}
|
51
|
50
|
|
52
|
|
- int prochaine_cible = (rand() % 4 + 1);
|
|
51
|
+ int prochaine_cible = cible_active;
|
|
52
|
+ int LED_prochaine_cible;
|
|
53
|
+ while(prochaine_cible == cible_active){
|
|
54
|
+ prochaine_cible = (rand() % 4 + 1);
|
|
55
|
+ }
|
53
|
56
|
|
54
|
57
|
Choix_Capteur(prochaine_cible);
|
55
|
58
|
|
56
|
|
- Prepare_Set_LED(prochaine_cible);
|
57
|
|
- Prepare_Clear_LED(cible_active);
|
58
|
|
- //Mise_A_Jour_Afficheurs_LED();
|
|
59
|
+ if(prochaine_cible == 1){
|
|
60
|
+ LED_prochaine_cible = LED_Cible_1;
|
|
61
|
+ }
|
|
62
|
+ else if(prochaine_cible == 2){
|
|
63
|
+ LED_prochaine_cible = LED_Cible_2;
|
|
64
|
+ }
|
|
65
|
+ else if(prochaine_cible == 3){
|
|
66
|
+ LED_prochaine_cible = LED_Cible_3;
|
|
67
|
+ }
|
|
68
|
+ else {
|
|
69
|
+ LED_prochaine_cible = LED_Cible_4;
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ Prepare_Clear_LED(LED_cible_active);
|
|
73
|
+ Prepare_Set_LED(LED_prochaine_cible);
|
|
74
|
+ Mise_A_Jour_Afficheurs_LED();
|
59
|
75
|
cible_active = prochaine_cible;
|
|
76
|
+ LED_cible_active = LED_prochaine_cible;
|
|
77
|
+ jouerSon();
|
|
78
|
+
|
|
79
|
+ for(i = 0; i < 4; i++){
|
|
80
|
+ tous_joueurs[i].confirmations = 0;
|
|
81
|
+ }
|
60
|
82
|
}
|
61
|
83
|
|
62
|
84
|
|
|
@@ -90,9 +112,8 @@ void faire_dft() {
|
90
|
112
|
if(tous_joueurs[i].confirmations < 5){
|
91
|
113
|
tous_joueurs[i].confirmations++;
|
92
|
114
|
if(tous_joueurs[i].confirmations == 5){
|
93
|
|
- jouerSon();
|
94
|
115
|
tous_joueurs[i].score++;
|
95
|
|
- //changer_cible();
|
|
116
|
+ changer_cible();
|
96
|
117
|
}
|
97
|
118
|
}
|
98
|
119
|
}
|
|
@@ -118,9 +139,10 @@ CLOCK_Configure();
|
118
|
139
|
|
119
|
140
|
//on décide de faire une DFT toutes les 5 ms
|
120
|
141
|
Systick_Period_ff(360000);
|
121
|
|
- Systick_Prio_IT(1,faire_dft);
|
122
|
|
- SysTick_On;
|
123
|
|
- SysTick_Enable_IT; // activer l'interruption configurée
|
|
142
|
+
|
|
143
|
+ //on met priorité 9 car la mise à jour de la LED est de priorité 8
|
|
144
|
+ Systick_Prio_IT(9,faire_dft);
|
|
145
|
+
|
124
|
146
|
Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
|
125
|
147
|
|
126
|
148
|
//il faut configurer la fréquence d'échantillonage de l'ADC
|
|
@@ -135,14 +157,14 @@ CLOCK_Configure();
|
135
|
157
|
//initialiser les pistolets
|
136
|
158
|
Init_Affichage();
|
137
|
159
|
|
138
|
|
- srand(20);
|
|
160
|
+ srand(21);
|
139
|
161
|
|
140
|
162
|
|
141
|
163
|
|
142
|
164
|
int nbCycles = PeriodeSonMicroSec * 72; //PeriodeSonMicroSec * 0.000001 * 72 000 000
|
143
|
165
|
|
144
|
166
|
Timer_1234_Init_ff( TIM4, nbCycles);
|
145
|
|
- Timer_1234_Init_ff( TIM1, 72000000 * 3); // Permet de lancer le timer de changement de cible toutes les 3 secondes
|
|
167
|
+ //Timer_1234_Init_ff( TIM5, 72000000 * 3); // Permet de lancer le timer de changement de cible toutes les 3 secondes
|
146
|
168
|
|
147
|
169
|
//avant de config le timer on va mettre la taille de l'index supérieur à la taille du fichier audio
|
148
|
170
|
//comme ça, le logiciel ne va pas jouer le son de suite
|
|
@@ -151,7 +173,9 @@ CLOCK_Configure();
|
151
|
173
|
|
152
|
174
|
|
153
|
175
|
Active_IT_Debordement_Timer( TIM4, 2, CallBackSon );
|
154
|
|
- Active_IT_Debordement_Timer( TIM1, 2, changer_cible);
|
|
176
|
+
|
|
177
|
+ //on l'active avec une priorité de 9 car la led est de priorité 8
|
|
178
|
+ //Active_IT_Debordement_Timer( TIM5, 9, changer_cible);
|
155
|
179
|
|
156
|
180
|
PWM_Init_ff( TIM3, 3, 720); //initialisation de la PWM sur canal 3 timer 3
|
157
|
181
|
|
|
@@ -163,11 +187,10 @@ CLOCK_Configure();
|
163
|
187
|
|
164
|
188
|
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
165
|
189
|
|
166
|
|
-
|
167
|
|
-
|
168
|
|
-
|
169
|
|
-
|
170
|
|
-
|
|
190
|
+ SysTick_On;
|
|
191
|
+ SysTick_Enable_IT; // activer l'interruption configurée
|
|
192
|
+ changer_cible();
|
|
193
|
+
|
171
|
194
|
while (1)
|
172
|
195
|
{
|
173
|
196
|
}
|