ili931_touch.c
This commit is contained in:
parent
862fc8da97
commit
de2abc2cc7
233
Core/Src/main.c
233
Core/Src/main.c
@ -26,7 +26,8 @@
|
||||
//#include "ili9341_touch.h"
|
||||
#include "ILI9341_STM32_Driver.h"
|
||||
#include "ILI9341_GFX.h"
|
||||
//#include "ili9341_touch.h"
|
||||
#include "ili9341_touch.h"
|
||||
//#include "xpt2046.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@ -61,26 +62,42 @@ UART_HandleTypeDef huart6;
|
||||
|
||||
/* Definitions for touchhistory */
|
||||
osThreadId_t touchhistoryHandle;
|
||||
const osThreadAttr_t touchhistory_attributes = { .name = "touchhistory",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityNormal, };
|
||||
const osThreadAttr_t touchhistory_attributes = {
|
||||
.name = "touchhistory",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityNormal,
|
||||
};
|
||||
/* Definitions for draw */
|
||||
osThreadId_t drawHandle;
|
||||
const osThreadAttr_t draw_attributes = { .name = "draw", .stack_size = 1024 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow, };
|
||||
const osThreadAttr_t draw_attributes = {
|
||||
.name = "draw",
|
||||
.stack_size = 512 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
/* Definitions for reactiongame */
|
||||
osThreadId_t reactiongameHandle;
|
||||
const osThreadAttr_t reactiongame_attributes = { .name = "reactiongame",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityLow, };
|
||||
const osThreadAttr_t reactiongame_attributes = {
|
||||
.name = "reactiongame",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
/* Definitions for gamepicker */
|
||||
osThreadId_t gamepickerHandle;
|
||||
const osThreadAttr_t gamepicker_attributes = { .name = "gamepicker",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityLow, };
|
||||
const osThreadAttr_t gamepicker_attributes = {
|
||||
.name = "gamepicker",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
/* Definitions for presses */
|
||||
osMessageQueueId_t pressesHandle;
|
||||
const osMessageQueueAttr_t presses_attributes = { .name = "presses" };
|
||||
const osMessageQueueAttr_t presses_attributes = {
|
||||
.name = "presses"
|
||||
};
|
||||
/* Definitions for display */
|
||||
osMutexId_t displayHandle;
|
||||
const osMutexAttr_t display_attributes = { .name = "display" };
|
||||
const osMutexAttr_t display_attributes = {
|
||||
.name = "display"
|
||||
};
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
@ -313,13 +330,26 @@ void UserInput() {
|
||||
// snake.Dir = LEFT;
|
||||
uint16_t x, y;
|
||||
|
||||
//if (ILI9341_TouchGetCoordinates(&x, &y)) { // Only act if touch detected
|
||||
x = getX();
|
||||
y = getY();
|
||||
if (x != 0 || y != 0) {
|
||||
int a = x;
|
||||
}
|
||||
int ia = HAL_GPIO_ReadPin(ILI9341_TOUCH_IRQ_GPIO_Port,
|
||||
ILI9341_TOUCH_IRQ_Pin) == GPIO_PIN_RESET;
|
||||
|
||||
if (ILI9341_TouchGetCoordinates(&x, &y)) { // Only act if touch detected
|
||||
if ((x == 123 || x == 124 || x == 125 || x == 126) && y == 0) {
|
||||
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < touchbuffersize - 1; i++) {
|
||||
touchcoord.x[i] = touchcoord.x[i + 1];
|
||||
touchcoord.y[i] = touchcoord.y[i + 1];
|
||||
//}
|
||||
touchcoord.x[touchbuffersize - 1] = x;
|
||||
touchcoord.y[touchbuffersize - 1] = y;
|
||||
}
|
||||
char dir;
|
||||
if (x < 107) {
|
||||
dir = 'L'; // Left
|
||||
@ -335,11 +365,13 @@ void UserInput() {
|
||||
|
||||
// Send the direction to the queue
|
||||
//if (!prevpressed && ILI9341_TouchPressed()) {
|
||||
|
||||
osStatus_t status = osMessageQueuePut(pressesHandle, &dir, 0, 0);
|
||||
if (status != osOK) {
|
||||
// Optional: Handle error
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
prevpressed = 1;
|
||||
//} else {
|
||||
prevpressed = 0;
|
||||
@ -354,7 +386,6 @@ void UserInput() {
|
||||
touchcoord.y[touchbuffersize - 1] = ILI9341_SCREEN_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Function for creating the game board & rendering
|
||||
void GameRender() {
|
||||
@ -480,7 +511,8 @@ void GameRender() {
|
||||
* @brief The application entry point.
|
||||
* @retval int
|
||||
*/
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
@ -516,6 +548,7 @@ int main(void) {
|
||||
ILI9341_Init();
|
||||
ILI9341_SetRotation(SCREEN_HORIZONTAL_1);
|
||||
ILI9341_FillScreen(MAGENTA);
|
||||
//void XPT2046_Init();
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@ -539,21 +572,25 @@ int main(void) {
|
||||
|
||||
/* Create the queue(s) */
|
||||
/* creation of presses */
|
||||
//pressesHandle = osMessageQueueNew (16, sizeof(char), &presses_attributes);
|
||||
pressesHandle = osMessageQueueNew (16, sizeof(char), &presses_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_QUEUES */
|
||||
/* add queues, ... */
|
||||
/* USER CODE END RTOS_QUEUES */
|
||||
|
||||
/* Create the thread(s) */
|
||||
/* creation of touchhistory */
|
||||
//touchhistoryHandle = osThreadNew(StartTouchHist, NULL, &touchhistory_attributes);
|
||||
touchhistoryHandle = osThreadNew(StartTouchHist, NULL, &touchhistory_attributes);
|
||||
|
||||
/* creation of draw */
|
||||
drawHandle = osThreadNew(snakegame, NULL, &draw_attributes);
|
||||
|
||||
/* creation of reactiongame */
|
||||
//reactiongameHandle = osThreadNew(startreactiongame, NULL, &reactiongame_attributes);
|
||||
|
||||
/* creation of gamepicker */
|
||||
//gamepickerHandle = osThreadNew(gamepicker_entry, NULL, &gamepicker_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
|
||||
@ -626,9 +663,10 @@ int main(void) {
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void) {
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
@ -642,20 +680,22 @@ void SystemClock_Config(void) {
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** 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_HSI;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
@ -665,7 +705,8 @@ void SystemClock_Config(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2C1_Init(void) {
|
||||
static void MX_I2C1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 0 */
|
||||
|
||||
@ -683,7 +724,8 @@ static void MX_I2C1_Init(void) {
|
||||
hi2c1.Init.OwnAddress2 = 0;
|
||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C1_Init 2 */
|
||||
@ -697,7 +739,8 @@ static void MX_I2C1_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI1_Init(void) {
|
||||
static void MX_SPI1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI1_Init 0 */
|
||||
|
||||
@ -719,7 +762,8 @@ static void MX_SPI1_Init(void) {
|
||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi1.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK) {
|
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI1_Init 2 */
|
||||
@ -733,7 +777,8 @@ static void MX_SPI1_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI2_Init(void) {
|
||||
static void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
@ -750,12 +795,13 @@ static void MX_SPI2_Init(void) {
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
|
||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK) {
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
@ -769,14 +815,15 @@ static void MX_SPI2_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM1_Init(void) {
|
||||
static void MX_TIM1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 0 */
|
||||
|
||||
/* USER CODE END TIM1_Init 0 */
|
||||
|
||||
TIM_Encoder_InitTypeDef sConfig = { 0 };
|
||||
TIM_MasterConfigTypeDef sMasterConfig = { 0 };
|
||||
TIM_Encoder_InitTypeDef sConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 1 */
|
||||
|
||||
@ -797,13 +844,14 @@ static void MX_TIM1_Init(void) {
|
||||
sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
|
||||
sConfig.IC2Filter = 0;
|
||||
if (HAL_TIM_Encoder_Init(&htim1, &sConfig) != HAL_OK) {
|
||||
if (HAL_TIM_Encoder_Init(&htim1, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM1_Init 2 */
|
||||
@ -817,14 +865,15 @@ static void MX_TIM1_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM4_Init(void) {
|
||||
static void MX_TIM4_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM4_Init 0 */
|
||||
|
||||
/* USER CODE END TIM4_Init 0 */
|
||||
|
||||
TIM_Encoder_InitTypeDef sConfig = { 0 };
|
||||
TIM_MasterConfigTypeDef sMasterConfig = { 0 };
|
||||
TIM_Encoder_InitTypeDef sConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM4_Init 1 */
|
||||
|
||||
@ -844,13 +893,14 @@ static void MX_TIM4_Init(void) {
|
||||
sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
|
||||
sConfig.IC2Filter = 0;
|
||||
if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) {
|
||||
if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM4_Init 2 */
|
||||
@ -864,15 +914,16 @@ static void MX_TIM4_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM5_Init(void) {
|
||||
static void MX_TIM5_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM5_Init 0 */
|
||||
|
||||
/* USER CODE END TIM5_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = { 0 };
|
||||
TIM_MasterConfigTypeDef sMasterConfig = { 0 };
|
||||
TIM_OC_InitTypeDef sConfigOC = { 0 };
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM5_Init 1 */
|
||||
|
||||
@ -883,40 +934,43 @@ static void MX_TIM5_Init(void) {
|
||||
htim5.Init.Period = 4294967295;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim5) != HAL_OK) {
|
||||
if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK) {
|
||||
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) {
|
||||
if (HAL_TIM_PWM_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_2)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_3)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4)
|
||||
!= HAL_OK) {
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM5_Init 2 */
|
||||
@ -931,7 +985,8 @@ static void MX_TIM5_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_USART6_UART_Init(void) {
|
||||
static void MX_USART6_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART6_Init 0 */
|
||||
|
||||
@ -948,7 +1003,8 @@ static void MX_USART6_UART_Init(void) {
|
||||
huart6.Init.Mode = UART_MODE_TX_RX;
|
||||
huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart6.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
if (HAL_UART_Init(&huart6) != HAL_OK) {
|
||||
if (HAL_UART_Init(&huart6) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART6_Init 2 */
|
||||
@ -960,7 +1016,8 @@ static void MX_USART6_UART_Init(void) {
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
static void MX_DMA_Init(void) {
|
||||
static void MX_DMA_Init(void)
|
||||
{
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||
@ -980,8 +1037,9 @@ static void MX_DMA_Init(void) {
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_GPIO_Init(void) {
|
||||
GPIO_InitTypeDef GPIO_InitStruct = { 0 };
|
||||
static void MX_GPIO_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
||||
|
||||
/* USER CODE END MX_GPIO_Init_1 */
|
||||
@ -995,10 +1053,10 @@ static void MX_GPIO_Init(void) {
|
||||
HAL_GPIO_WritePin(LED_BLUE_GPIO_Port, LED_BLUE_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, DISPLAY_CS_Pin | DISPLAY_RES_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, DISPLAY_CS_Pin|DISPLAY_RES_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, TOUCH_CS_Pin | DISPLAY_DC_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOB, TOUCH_CS_Pin|DISPLAY_DC_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin : LED_BLUE_Pin */
|
||||
GPIO_InitStruct.Pin = LED_BLUE_Pin;
|
||||
@ -1008,14 +1066,14 @@ static void MX_GPIO_Init(void) {
|
||||
HAL_GPIO_Init(LED_BLUE_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : DISPLAY_CS_Pin DISPLAY_RES_Pin */
|
||||
GPIO_InitStruct.Pin = DISPLAY_CS_Pin | DISPLAY_RES_Pin;
|
||||
GPIO_InitStruct.Pin = DISPLAY_CS_Pin|DISPLAY_RES_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : TOUCH_CS_Pin DISPLAY_DC_Pin */
|
||||
GPIO_InitStruct.Pin = TOUCH_CS_Pin | DISPLAY_DC_Pin;
|
||||
GPIO_InitStruct.Pin = TOUCH_CS_Pin|DISPLAY_DC_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
@ -1043,20 +1101,26 @@ static void MX_GPIO_Init(void) {
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_StartTouchHist */
|
||||
void StartTouchHist(void *argument) {
|
||||
void StartTouchHist(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
|
||||
for (;;) {
|
||||
UserInput();
|
||||
|
||||
if (osMutexAcquire(displayHandle, osWaitForever) == osOK) {
|
||||
// Mutex successfully locked
|
||||
// ILI9341_DrawPixel(touchcoord.x[touchbuffersize - 1],
|
||||
ILI9341_DrawPixel(touchcoord.x[touchbuffersize - 1],
|
||||
touchcoord.y[touchbuffersize - 1], MAGENTA);
|
||||
ILI9341_DrawPixel(touchcoord.x[0], touchcoord.y[0], MAGENTA);
|
||||
//ILI9341_DrawPixel(touchcoord.x[touchbuffersize - 1],
|
||||
// touchcoord.y[touchbuffersize - 1], ILI9341_MAGENTA);
|
||||
// ILI9341_DrawPixel(touchcoord.x[0], touchcoord.y[0], ILI9341_WHITE);
|
||||
osMutexRelease(displayHandle);
|
||||
}
|
||||
|
||||
osDelay(1);
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
@ -1068,14 +1132,15 @@ void StartTouchHist(void *argument) {
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_snakegame */
|
||||
void snakegame(void *argument) {
|
||||
void snakegame(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN snakegame */
|
||||
/* Infinite loop */
|
||||
ILI9341_FillScreen(BLACK);
|
||||
GameInit();
|
||||
GameRender();
|
||||
for (;;) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
//uint16_t x,y;
|
||||
//ILI9341_TouchGetCoordinates(&x, &y);
|
||||
GameRender();
|
||||
@ -1086,11 +1151,6 @@ void snakegame(void *argument) {
|
||||
|
||||
//ILI9341_FillScreen(timer%0xFFFF);
|
||||
UpdateGame();
|
||||
if(i==6){
|
||||
int a=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1104,7 +1164,8 @@ void snakegame(void *argument) {
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_startreactiongame */
|
||||
void startreactiongame(void *argument) {
|
||||
void startreactiongame(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN startreactiongame */
|
||||
/* Infinite loop */
|
||||
uint32_t lasttimestamp = osKernelGetTickCount();
|
||||
@ -1175,7 +1236,8 @@ void startreactiongame(void *argument) {
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_gamepicker_entry */
|
||||
void gamepicker_entry(void *argument) {
|
||||
void gamepicker_entry(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN gamepicker_entry */
|
||||
/* Infinite loop */
|
||||
for (;;) {
|
||||
@ -1211,11 +1273,13 @@ void gamepicker_entry(void *argument) {
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM2) {
|
||||
if (htim->Instance == TIM2)
|
||||
{
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
@ -1227,7 +1291,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
*/
|
||||
void Error_Handler(void) {
|
||||
void Error_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
__disable_irq();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user