164 lines
5.4 KiB
C
164 lines
5.4 KiB
C
#include "main.h"
|
|
#include "usart.h"
|
|
#include "gpio.h"
|
|
#include "oled.h"
|
|
#include "led.h"
|
|
|
|
void led(unsigned char color, unsigned char number)
|
|
{
|
|
/*unsigned char transfer[5];
|
|
transfer[0] = 2;
|
|
transfer[1] = 0;*/
|
|
if (number==1)
|
|
{
|
|
switch (color)
|
|
{
|
|
case 0:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
break;
|
|
case 1:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
break;
|
|
case 2:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
break;
|
|
case 3:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); //B
|
|
break;
|
|
case 4 :
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
break;
|
|
case 5:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); //B
|
|
break;
|
|
case 6:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); //B
|
|
break;
|
|
case 7:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); //B
|
|
break;
|
|
default:
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
}
|
|
}
|
|
/*else if (number==2)
|
|
{
|
|
switch (color)
|
|
{
|
|
case 0:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 1:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 1;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 2:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 2;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 3:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 3;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 4 :
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 4;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 5:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 5;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 6:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 6;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
case 7:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 7;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
break;
|
|
default:
|
|
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
transfer[0] = 2;
|
|
transfer[1] = 9;
|
|
HAL_UART_Transmit(&huart1,transfer, 2 ,1000);
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //R
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); //B
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET); //G
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET); //R
|
|
}
|
|
*/
|
|
/*transfer[0] = 2;
|
|
transfer[1] = 0;*/
|
|
|
|
}
|
|
|
|
|