Ajustements pour jeu final
This commit is contained in:
parent
c27baa174f
commit
34acb2e2be
1 changed files with 44 additions and 21 deletions
|
@ -3,7 +3,7 @@
|
||||||
#include "DriverJeuLaser.h"
|
#include "DriverJeuLaser.h"
|
||||||
|
|
||||||
|
|
||||||
#define SEUIL_MIN 0x00093510
|
#define SEUIL_MIN 0x00020510
|
||||||
#define SEUIL_MAX 0x01933510
|
#define SEUIL_MAX 0x01933510
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ short int dma_buff[64] ;
|
||||||
|
|
||||||
int res[4];
|
int res[4];
|
||||||
|
|
||||||
char cible_active;
|
char cible_active, LED_cible_active;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short int valeur_k, score, confirmations;
|
short int valeur_k, score, confirmations;
|
||||||
|
@ -41,22 +41,44 @@ void jouerSon() {
|
||||||
|
|
||||||
|
|
||||||
void changer_cible(){
|
void changer_cible(){
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 4; i++){
|
for(i = 0; i < 4; i++){
|
||||||
tous_joueurs[i].confirmations = 0;
|
|
||||||
Prepare_Afficheur(i+1,tous_joueurs[i].score);
|
Prepare_Afficheur(i+1,tous_joueurs[i].score);
|
||||||
}
|
}
|
||||||
|
|
||||||
int prochaine_cible = (rand() % 4 + 1);
|
int prochaine_cible = cible_active;
|
||||||
|
int LED_prochaine_cible;
|
||||||
|
while(prochaine_cible == cible_active){
|
||||||
|
prochaine_cible = (rand() % 4 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
Choix_Capteur(prochaine_cible);
|
Choix_Capteur(prochaine_cible);
|
||||||
|
|
||||||
Prepare_Set_LED(prochaine_cible);
|
if(prochaine_cible == 1){
|
||||||
Prepare_Clear_LED(cible_active);
|
LED_prochaine_cible = LED_Cible_1;
|
||||||
//Mise_A_Jour_Afficheurs_LED();
|
}
|
||||||
|
else if(prochaine_cible == 2){
|
||||||
|
LED_prochaine_cible = LED_Cible_2;
|
||||||
|
}
|
||||||
|
else if(prochaine_cible == 3){
|
||||||
|
LED_prochaine_cible = LED_Cible_3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LED_prochaine_cible = LED_Cible_4;
|
||||||
|
}
|
||||||
|
|
||||||
|
Prepare_Clear_LED(LED_cible_active);
|
||||||
|
Prepare_Set_LED(LED_prochaine_cible);
|
||||||
|
Mise_A_Jour_Afficheurs_LED();
|
||||||
cible_active = prochaine_cible;
|
cible_active = prochaine_cible;
|
||||||
|
LED_cible_active = LED_prochaine_cible;
|
||||||
|
jouerSon();
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++){
|
||||||
|
tous_joueurs[i].confirmations = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,9 +112,8 @@ void faire_dft() {
|
||||||
if(tous_joueurs[i].confirmations < 5){
|
if(tous_joueurs[i].confirmations < 5){
|
||||||
tous_joueurs[i].confirmations++;
|
tous_joueurs[i].confirmations++;
|
||||||
if(tous_joueurs[i].confirmations == 5){
|
if(tous_joueurs[i].confirmations == 5){
|
||||||
jouerSon();
|
|
||||||
tous_joueurs[i].score++;
|
tous_joueurs[i].score++;
|
||||||
//changer_cible();
|
changer_cible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,9 +139,10 @@ CLOCK_Configure();
|
||||||
|
|
||||||
//on décide de faire une DFT toutes les 5 ms
|
//on décide de faire une DFT toutes les 5 ms
|
||||||
Systick_Period_ff(360000);
|
Systick_Period_ff(360000);
|
||||||
Systick_Prio_IT(1,faire_dft);
|
|
||||||
SysTick_On;
|
//on met priorité 9 car la mise à jour de la LED est de priorité 8
|
||||||
SysTick_Enable_IT; // activer l'interruption configurée
|
Systick_Prio_IT(9,faire_dft);
|
||||||
|
|
||||||
Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
|
Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
|
||||||
|
|
||||||
//il faut configurer la fréquence d'échantillonage de l'ADC
|
//il faut configurer la fréquence d'échantillonage de l'ADC
|
||||||
|
@ -135,14 +157,14 @@ CLOCK_Configure();
|
||||||
//initialiser les pistolets
|
//initialiser les pistolets
|
||||||
Init_Affichage();
|
Init_Affichage();
|
||||||
|
|
||||||
srand(20);
|
srand(21);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int nbCycles = PeriodeSonMicroSec * 72; //PeriodeSonMicroSec * 0.000001 * 72 000 000
|
int nbCycles = PeriodeSonMicroSec * 72; //PeriodeSonMicroSec * 0.000001 * 72 000 000
|
||||||
|
|
||||||
Timer_1234_Init_ff( TIM4, nbCycles);
|
Timer_1234_Init_ff( TIM4, nbCycles);
|
||||||
Timer_1234_Init_ff( TIM1, 72000000 * 3); // Permet de lancer le timer de changement de cible toutes les 3 secondes
|
//Timer_1234_Init_ff( TIM5, 72000000 * 3); // Permet de lancer le timer de changement de cible toutes les 3 secondes
|
||||||
|
|
||||||
//avant de config le timer on va mettre la taille de l'index supérieur à la taille du fichier audio
|
//avant de config le timer on va mettre la taille de l'index supérieur à la taille du fichier audio
|
||||||
//comme ça, le logiciel ne va pas jouer le son de suite
|
//comme ça, le logiciel ne va pas jouer le son de suite
|
||||||
|
@ -151,7 +173,9 @@ CLOCK_Configure();
|
||||||
|
|
||||||
|
|
||||||
Active_IT_Debordement_Timer( TIM4, 2, CallBackSon );
|
Active_IT_Debordement_Timer( TIM4, 2, CallBackSon );
|
||||||
Active_IT_Debordement_Timer( TIM1, 2, changer_cible);
|
|
||||||
|
//on l'active avec une priorité de 9 car la led est de priorité 8
|
||||||
|
//Active_IT_Debordement_Timer( TIM5, 9, changer_cible);
|
||||||
|
|
||||||
PWM_Init_ff( TIM3, 3, 720); //initialisation de la PWM sur canal 3 timer 3
|
PWM_Init_ff( TIM3, 3, 720); //initialisation de la PWM sur canal 3 timer 3
|
||||||
|
|
||||||
|
@ -163,11 +187,10 @@ CLOCK_Configure();
|
||||||
|
|
||||||
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
||||||
|
|
||||||
|
SysTick_On;
|
||||||
|
SysTick_Enable_IT; // activer l'interruption configurée
|
||||||
|
changer_cible();
|
||||||
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue