/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"
#include "adc.h"
#include "i2c.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
#include "readpin.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "oled.h"
#include "variables.h"
/* USER CODE END Includes */

void car_move(unsigned char ctrl)
{
		ctrl = ReadPin();
		if(ctrl == 16)
		{
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_3,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4,0);
		}
		else if(ctrl == 8)
		{
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_3,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4,0);
		}
		else if(ctrl == 14)
		{
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_3,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4,0);
		}
		else if(ctrl == 2)
		{
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_3,0);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4,33999);
		}
		else
		{
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_3,33999);
			__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_4,33999);
		}

}






