sentry_chassis_hzz/bsp/bsp_led.c

22 lines
523 B
C

#include "bsp_led.h"
#include "main.h"
extern TIM_HandleTypeDef htim5;
void aRGB_led_show(uint32_t aRGB)
{
static uint8_t alpha;
static uint16_t red,green,blue;
alpha = (aRGB & 0xFF000000) >> 24;
red = ((aRGB & 0x00FF0000) >> 16) * alpha;
green = ((aRGB & 0x0000FF00) >> 8) * alpha;
blue = ((aRGB & 0x000000FF) >> 0) * alpha;
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_1, blue);
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_2, green);
__HAL_TIM_SetCompare(&htim5, TIM_CHANNEL_3, red);
}