Tir secondaire
This commit is contained in:
parent
9b5fb92e86
commit
c80d0c4817
3 changed files with 136 additions and 41 deletions
|
@ -6,6 +6,8 @@ Queue "Queue_J\nchoc joueur" as Queue_J
|
|||
Queue "Queue_E\nchoc ennemie" as Queue_E
|
||||
Queue "Queue_F\nfin du jeu" as Queue_F
|
||||
Queue "Queue_N\nnouveau projectile" as Queue_N
|
||||
component "Table_ennemis" as table
|
||||
component "joueur" as J
|
||||
component t_gm[
|
||||
Thread : game_master
|
||||
===
|
||||
|
@ -63,4 +65,8 @@ Queue_N --> [t_proj]
|
|||
[t_gm]..>[t_ennemie] : suspend
|
||||
[t_gm]..>[t_proj] : suspend
|
||||
|
||||
[t_j1] ..> J : ecris
|
||||
[t_ennemie] ..> table : ecris
|
||||
[t_proj] ..> J : lis
|
||||
[t_proj] ..> table : lis
|
||||
@enduml
|
||||
|
|
167
Core/Src/main.c
167
Core/Src/main.c
|
@ -77,6 +77,7 @@ osThreadId Joueur_1Handle;
|
|||
osThreadId Block_EnemieHandle;
|
||||
osThreadId ProjectileHandle;
|
||||
osThreadId HUDHandle;
|
||||
osThreadId chargeurHandle;
|
||||
osMessageQId Queue_FHandle;
|
||||
osMessageQId Queue_NHandle;
|
||||
osMessageQId Queue_JHandle;
|
||||
|
@ -102,11 +103,12 @@ static void MX_DMA2D_Init(void);
|
|||
static void MX_CRC_Init(void);
|
||||
static void MX_RNG_Init(void);
|
||||
static void MX_ADC1_Init(void);
|
||||
void f_GameMaster(void const *argument);
|
||||
void f_Joueur_1(void const *argument);
|
||||
void f_block_enemie(void const *argument);
|
||||
void f_projectile(void const *argument);
|
||||
void f_HUD(void const *argument);
|
||||
void f_GameMaster(void const * argument);
|
||||
void f_Joueur_1(void const * argument);
|
||||
void f_block_enemie(void const * argument);
|
||||
void f_projectile(void const * argument);
|
||||
void f_HUD(void const * argument);
|
||||
void f_chargeur(void const * argument);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
uint8_t proba_bernoulli(uint32_t numerateur, uint32_t denominateur);
|
||||
|
@ -178,6 +180,22 @@ struct Collision
|
|||
uint8_t damage;
|
||||
};
|
||||
|
||||
struct Led
|
||||
{
|
||||
GPIO_TypeDef* port;
|
||||
uint16_t pin;
|
||||
};
|
||||
|
||||
struct Led Leds[] = {
|
||||
{LED18_GPIO_Port, LED18_Pin},
|
||||
{LED17_GPIO_Port, LED17_Pin},
|
||||
{LED16_GPIO_Port, LED16_Pin},
|
||||
{LED15_GPIO_Port, LED15_Pin},
|
||||
{LED14_GPIO_Port, LED14_Pin},
|
||||
{LED13_GPIO_Port, LED13_Pin},
|
||||
{LED12_GPIO_Port, LED12_Pin},
|
||||
{LED11_GPIO_Port, LED11_Pin}};
|
||||
|
||||
// Définition des paramètres du joueurs
|
||||
|
||||
struct Joueur joueur = {200, 200, 1, 1, 3, {0, 0, 0, -1, MISSILE_AMI, 1, 1}};
|
||||
|
@ -188,6 +206,8 @@ uint32_t LCD_COLOR_BACKGROUND = LCD_COLOR_BLACK;
|
|||
|
||||
// Number of waves of enemies before the game is won.
|
||||
uint8_t wave = 0;
|
||||
uint8_t kill = 0;
|
||||
uint8_t charge = 0;
|
||||
|
||||
// Tableau des monstres (8 par ligne, sur 3 ligne)
|
||||
struct Monster Table_ennemis[8][3];
|
||||
|
@ -314,6 +334,10 @@ int main(void)
|
|||
osThreadDef(HUD, f_HUD, osPriorityBelowNormal, 0, 1024);
|
||||
HUDHandle = osThreadCreate(osThread(HUD), NULL);
|
||||
|
||||
/* definition and creation of chargeur */
|
||||
osThreadDef(chargeur, f_chargeur, osPriorityBelowNormal, 0, 128);
|
||||
chargeurHandle = osThreadCreate(osThread(chargeur), NULL);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
vQueueAddToRegistry(Queue_NHandle, "Queue Missile");
|
||||
vQueueAddToRegistry(Queue_JHandle, "Queue Missile");
|
||||
|
@ -404,7 +428,8 @@ void SystemClock_Config(void)
|
|||
}
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
|
@ -414,7 +439,7 @@ void SystemClock_Config(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC | RCC_PERIPHCLK_CLK48;
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_CLK48;
|
||||
PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
|
||||
PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
|
||||
PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;
|
||||
|
@ -475,6 +500,7 @@ static void MX_ADC1_Init(void)
|
|||
/* USER CODE BEGIN ADC1_Init 2 */
|
||||
|
||||
/* USER CODE END ADC1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -524,6 +550,7 @@ static void MX_ADC3_Init(void)
|
|||
/* USER CODE BEGIN ADC3_Init 2 */
|
||||
|
||||
/* USER CODE END ADC3_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -554,6 +581,7 @@ static void MX_CRC_Init(void)
|
|||
/* USER CODE BEGIN CRC_Init 2 */
|
||||
|
||||
/* USER CODE END CRC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -591,6 +619,7 @@ static void MX_DAC_Init(void)
|
|||
/* USER CODE BEGIN DAC_Init 2 */
|
||||
|
||||
/* USER CODE END DAC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -627,6 +656,7 @@ static void MX_DMA2D_Init(void)
|
|||
/* USER CODE BEGIN DMA2D_Init 2 */
|
||||
|
||||
/* USER CODE END DMA2D_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -688,6 +718,7 @@ static void MX_LTDC_Init(void)
|
|||
/* USER CODE BEGIN LTDC_Init 2 */
|
||||
|
||||
/* USER CODE END LTDC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -713,6 +744,7 @@ static void MX_RNG_Init(void)
|
|||
/* USER CODE BEGIN RNG_Init 2 */
|
||||
|
||||
/* USER CODE END RNG_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -759,6 +791,7 @@ static void MX_TIM1_Init(void)
|
|||
/* USER CODE BEGIN TIM1_Init 2 */
|
||||
|
||||
/* USER CODE END TIM1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -803,6 +836,7 @@ static void MX_TIM2_Init(void)
|
|||
/* USER CODE BEGIN TIM2_Init 2 */
|
||||
|
||||
/* USER CODE END TIM2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -868,6 +902,7 @@ static void MX_TIM3_Init(void)
|
|||
|
||||
/* USER CODE END TIM3_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim3);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -912,6 +947,7 @@ static void MX_TIM5_Init(void)
|
|||
/* USER CODE BEGIN TIM5_Init 2 */
|
||||
|
||||
/* USER CODE END TIM5_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -990,6 +1026,7 @@ static void MX_TIM8_Init(void)
|
|||
|
||||
/* USER CODE END TIM8_Init 2 */
|
||||
HAL_TIM_MspPostInit(&htim8);
|
||||
|
||||
}
|
||||
|
||||
/* FMC initialization function */
|
||||
|
@ -1031,7 +1068,7 @@ static void MX_FMC_Init(void)
|
|||
|
||||
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
Error_Handler( );
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN FMC_Init 2 */
|
||||
|
@ -1062,7 +1099,7 @@ static void MX_GPIO_Init(void)
|
|||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOE, LED14_Pin | LED15_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOE, LED14_Pin|LED15_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
|
||||
|
@ -1080,7 +1117,8 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOH, LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOH, LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin
|
||||
|LED2_Pin|LED18_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(EXT_RST_GPIO_Port, EXT_RST_Pin, GPIO_PIN_RESET);
|
||||
|
@ -1092,7 +1130,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : ARDUINO_SCL_D15_Pin ARDUINO_SDA_D14_Pin */
|
||||
GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin | ARDUINO_SDA_D14_Pin;
|
||||
GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin|ARDUINO_SDA_D14_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
@ -1101,7 +1139,8 @@ static void MX_GPIO_Init(void)
|
|||
|
||||
/*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D2_Pin
|
||||
ULPI_D1_Pin ULPI_D4_Pin */
|
||||
GPIO_InitStruct.Pin = ULPI_D7_Pin | ULPI_D6_Pin | ULPI_D5_Pin | ULPI_D2_Pin | ULPI_D1_Pin | ULPI_D4_Pin;
|
||||
GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D2_Pin
|
||||
|ULPI_D1_Pin|ULPI_D4_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -1109,13 +1148,13 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : BP2_Pin BP1_Pin */
|
||||
GPIO_InitStruct.Pin = BP2_Pin | BP1_Pin;
|
||||
GPIO_InitStruct.Pin = BP2_Pin|BP1_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : LED14_Pin LED15_Pin */
|
||||
GPIO_InitStruct.Pin = LED14_Pin | LED15_Pin;
|
||||
GPIO_InitStruct.Pin = LED14_Pin|LED15_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
@ -1142,14 +1181,14 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : OTG_FS_PowerSwitchOn_Pin LED16_Pin */
|
||||
GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin | LED16_Pin;
|
||||
GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin|LED16_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : LED3_Pin LCD_DISP_Pin */
|
||||
GPIO_InitStruct.Pin = LED3_Pin | LCD_DISP_Pin;
|
||||
GPIO_InitStruct.Pin = LED3_Pin|LCD_DISP_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
@ -1175,7 +1214,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : TP3_Pin NC2_Pin */
|
||||
GPIO_InitStruct.Pin = TP3_Pin | NC2_Pin;
|
||||
GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
||||
|
@ -1190,7 +1229,8 @@ static void MX_GPIO_Init(void)
|
|||
|
||||
/*Configure GPIO pins : LED13_Pin LED17_Pin LED11_Pin LED12_Pin
|
||||
LED2_Pin LED18_Pin */
|
||||
GPIO_InitStruct.Pin = LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin;
|
||||
GPIO_InitStruct.Pin = LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin
|
||||
|LED2_Pin|LED18_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
@ -1219,7 +1259,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PC7 PC6 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_7 | GPIO_PIN_6;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -1235,7 +1275,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : BP_JOYSTICK_Pin RMII_RXER_Pin */
|
||||
GPIO_InitStruct.Pin = BP_JOYSTICK_Pin | RMII_RXER_Pin;
|
||||
GPIO_InitStruct.Pin = BP_JOYSTICK_Pin|RMII_RXER_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
||||
|
@ -1249,7 +1289,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */
|
||||
GPIO_InitStruct.Pin = ULPI_STP_Pin | ULPI_DIR_Pin;
|
||||
GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -1264,7 +1304,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(EXT_RST_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */
|
||||
GPIO_InitStruct.Pin = LCD_SCL_Pin | LCD_SDA_Pin;
|
||||
GPIO_InitStruct.Pin = LCD_SCL_Pin|LCD_SDA_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -1272,7 +1312,7 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */
|
||||
GPIO_InitStruct.Pin = ULPI_CLK_Pin | ULPI_D0_Pin;
|
||||
GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -1280,12 +1320,13 @@ static void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB14 PB15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_14 | GPIO_PIN_15;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
@ -1401,7 +1442,7 @@ uint8_t colision_missile(uint16_t m_pos_x, uint16_t m_pos_y, uint16_t o_pos_x, u
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_GameMaster */
|
||||
void f_GameMaster(void const *argument)
|
||||
void f_GameMaster(void const * argument)
|
||||
{
|
||||
/* init code for LWIP */
|
||||
MX_LWIP_Init();
|
||||
|
@ -1444,7 +1485,7 @@ void f_GameMaster(void const *argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_Joueur_1 */
|
||||
void f_Joueur_1(void const *argument)
|
||||
void f_Joueur_1(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN f_Joueur_1 */
|
||||
TickType_t xLastWakeTime;
|
||||
|
@ -1455,7 +1496,8 @@ void f_Joueur_1(void const *argument)
|
|||
|
||||
struct Missile missile;
|
||||
|
||||
uint8_t bouton_relache = 1;
|
||||
uint8_t bp_1_relache = 1;
|
||||
uint8_t bp_2_relache = 1;
|
||||
|
||||
ADC_ChannelConfTypeDef sConfig3 = {0};
|
||||
sConfig3.Rank = ADC_REGULAR_RANK_1;
|
||||
|
@ -1516,18 +1558,35 @@ void f_Joueur_1(void const *argument)
|
|||
if (joueur.health <= 0)
|
||||
xQueueSend(Queue_FHandle, &end, 0);
|
||||
|
||||
if ((!HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin)) && bouton_relache)
|
||||
if ((!HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin)) && bp_1_relache)
|
||||
{
|
||||
bouton_relache = 0;
|
||||
bp_1_relache = 0;
|
||||
missile = joueur.missile;
|
||||
missile.x = joueur.x + joueur_width / 2;
|
||||
missile.y = joueur.y;
|
||||
xQueueSend(Queue_NHandle, &missile, 0);
|
||||
HAL_GPIO_TogglePin(LED11_GPIO_Port, LED11_Pin);
|
||||
}
|
||||
if (HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin))
|
||||
|
||||
bouton_relache = 1;
|
||||
bp_1_relache = 1;
|
||||
|
||||
if ((!HAL_GPIO_ReadPin(BP2_GPIO_Port, BP2_Pin)) && bp_2_relache && (charge == 8))
|
||||
{
|
||||
bp_2_relache = 0;
|
||||
missile = joueur.missile;
|
||||
missile.x = joueur.x + joueur_width / 2;
|
||||
missile.y = joueur.y;
|
||||
for (int idx_tirs = -3; idx_tirs <= 3; idx_tirs++)
|
||||
{
|
||||
missile.dy = -3;
|
||||
missile.dx = idx_tirs;
|
||||
xQueueSend(Queue_NHandle, &missile, 0);
|
||||
}
|
||||
charge = 0;
|
||||
}
|
||||
if (HAL_GPIO_ReadPin(BP2_GPIO_Port, BP2_Pin))
|
||||
|
||||
bp_2_relache = 1;
|
||||
|
||||
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
||||
}
|
||||
|
@ -1541,7 +1600,7 @@ void f_Joueur_1(void const *argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_block_enemie */
|
||||
void f_block_enemie(void const *argument)
|
||||
void f_block_enemie(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN f_block_enemie */
|
||||
|
||||
|
@ -1563,6 +1622,8 @@ void f_block_enemie(void const *argument)
|
|||
while (xQueueReceive(Queue_EHandle, &collision, 0) == pdPASS)
|
||||
{
|
||||
Table_ennemis[collision.idx1][collision.idx2].health -= collision.damage;
|
||||
if (Table_ennemis[collision.idx1][collision.idx2].health <= 0)
|
||||
kill++;
|
||||
}
|
||||
|
||||
for (int idx1 = 0; idx1 < 8; idx1++)
|
||||
|
@ -1648,7 +1709,7 @@ void f_block_enemie(void const *argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_projectile */
|
||||
void f_projectile(void const *argument)
|
||||
void f_projectile(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN f_projectile */
|
||||
TickType_t xLastWakeTime;
|
||||
|
@ -1735,25 +1796,54 @@ void f_projectile(void const *argument)
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_HUD */
|
||||
void f_HUD(void const *argument)
|
||||
void f_HUD(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN f_HUD */
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount();
|
||||
const TickType_t xPeriodeTache = 100 / portTICK_PERIOD_MS; // Toutes les 200 ms
|
||||
uint8_t line_hud[50] = "";
|
||||
const uint8_t base[50] = "vie : %2u - vague : %2u";
|
||||
uint8_t line_hud[100] = "";
|
||||
const uint8_t base[100] = "vie : %2u - vague : %2u - kill : %2u";
|
||||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
sprintf(line_hud, base, (uint)joueur.health, (uint)wave);
|
||||
sprintf(line_hud, base, (uint)joueur.health, (uint)wave, (uint)kill);
|
||||
lcd_plot_text_line(0, line_hud, Couleur_missile);
|
||||
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
||||
}
|
||||
/* USER CODE END f_HUD */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Header_f_chargeur */
|
||||
/**
|
||||
* @brief Function implementing the chargeur thread.
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_f_chargeur */
|
||||
void f_chargeur(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN f_chargeur */
|
||||
TickType_t xLastWakeTime;
|
||||
xLastWakeTime = xTaskGetTickCount();
|
||||
const TickType_t xPeriodeTache = 5000/ 8 / portTICK_PERIOD_MS; // Toutes les 200 ms
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
if (charge < 8)
|
||||
{
|
||||
charge++;
|
||||
for (int idx = 0; idx<=8; idx++){
|
||||
HAL_GPIO_WritePin(Leds[idx].port, Leds[idx].pin, !(charge<idx));
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelayUntil(&xLastWakeTime, xPeriodeTache);
|
||||
}
|
||||
/* USER CODE END f_chargeur */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
* @note This function is called when TIM6 interrupt took place, inside
|
||||
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
||||
|
@ -1766,8 +1856,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM6)
|
||||
{
|
||||
if (htim->Instance == TIM6) {
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
|
|
@ -17,7 +17,7 @@ FREERTOS.INCLUDE_vTaskDelayUntil=1
|
|||
FREERTOS.IPParameters=Tasks01,configUSE_APPLICATION_TASK_TAG,configUSE_RECURSIVE_MUTEXES,configUSE_COUNTING_SEMAPHORES,configUSE_IDLE_HOOK,configUSE_MALLOC_FAILED_HOOK,configCHECK_FOR_STACK_OVERFLOW,configTOTAL_HEAP_SIZE,FootprintOK,Mutexes01,INCLUDE_vTaskDelayUntil,configENABLE_FPU,Queues01,configRECORD_STACK_HIGH_ADDRESS,configGENERATE_RUN_TIME_STATS
|
||||
FREERTOS.Mutexes01=MutexLCD,Dynamic,NULL
|
||||
FREERTOS.Queues01=Queue_F,8,enum End_type,0,Dynamic,NULL,NULL;Queue_N,8,struct Missile,0,Dynamic,NULL,NULL;Queue_J,8,uint8_t,0,Dynamic,NULL,NULL;Queue_E,8,struct Collision,0,Dynamic,NULL,NULL
|
||||
FREERTOS.Tasks01=GameMaster,2,1024,f_GameMaster,Default,NULL,Dynamic,NULL,NULL;Joueur_1,1,1024,f_Joueur_1,Default,NULL,Dynamic,NULL,NULL;Block_Enemie,-2,1024,f_block_enemie,Default,NULL,Dynamic,NULL,NULL;Projectile,0,1024,f_projectile,Default,NULL,Dynamic,Dynamic,NULL;HUD,-1,1024,f_HUD,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.Tasks01=GameMaster,2,1024,f_GameMaster,Default,NULL,Dynamic,NULL,NULL;Joueur_1,1,1024,f_Joueur_1,Default,NULL,Dynamic,NULL,NULL;Block_Enemie,-2,1024,f_block_enemie,Default,NULL,Dynamic,NULL,NULL;Projectile,0,1024,f_projectile,Default,NULL,Dynamic,Dynamic,NULL;HUD,-1,1024,f_HUD,Default,NULL,Dynamic,NULL,NULL;chargeur,-1,128,f_chargeur,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
|
||||
FREERTOS.configENABLE_FPU=1
|
||||
FREERTOS.configGENERATE_RUN_TIME_STATS=0
|
||||
|
|
Loading…
Reference in a new issue