2023-02-14 11:05:41 +08:00
|
|
|
#include "led.h"
|
|
|
|
#include "stdlib.h"
|
2023-02-16 15:46:04 +08:00
|
|
|
#include "memory.h"
|
2023-02-14 11:05:41 +08:00
|
|
|
#include "user_lib.h"
|
|
|
|
|
|
|
|
static uint8_t idx;
|
2023-02-16 15:46:04 +08:00
|
|
|
static LEDInstance *bsp_led_ins[LED_MAX_NUM] = {NULL};
|
2023-02-14 11:05:41 +08:00
|
|
|
|
|
|
|
LEDInstance *LEDRegister(LED_Init_Config_s *led_config)
|
|
|
|
{
|
2023-06-23 15:56:20 +08:00
|
|
|
LEDInstance *led_ins = (LEDInstance *)zmalloc(sizeof(LEDInstance));
|
2023-02-14 11:05:41 +08:00
|
|
|
// 剩下的值暂时都被置零
|
2023-03-23 19:40:36 +08:00
|
|
|
led_ins->led_pwm = PWMRegister(&led_config->pwm_config);
|
2023-02-16 15:46:04 +08:00
|
|
|
led_ins->led_switch = led_config->init_swtich;
|
|
|
|
|
2023-02-14 11:05:41 +08:00
|
|
|
bsp_led_ins[idx++] = led_ins;
|
|
|
|
return led_ins;
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:46:04 +08:00
|
|
|
void LEDSet(LEDInstance *_led, uint8_t alpha, uint8_t color_value, uint8_t brightness)
|
2023-02-14 11:05:41 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:46:04 +08:00
|
|
|
void LEDSwitch(LEDInstance *_led, uint8_t led_switch)
|
2023-02-14 11:05:41 +08:00
|
|
|
{
|
2023-02-16 15:46:04 +08:00
|
|
|
if (led_switch == 1)
|
2023-02-14 11:05:41 +08:00
|
|
|
{
|
2023-02-16 15:46:04 +08:00
|
|
|
_led->led_switch = 1;
|
2023-02-14 11:05:41 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-02-16 15:46:04 +08:00
|
|
|
_led->led_switch = 0;
|
2023-02-14 11:05:41 +08:00
|
|
|
// PWMSetPeriod(_led,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-14 17:24:44 +08:00
|
|
|
void LEDShow(uint32_t aRGB)
|
2023-02-14 11:05:41 +08:00
|
|
|
{
|
2023-07-26 14:31:49 +08:00
|
|
|
// static uint8_t alpha;
|
|
|
|
// static uint16_t red, green, blue;
|
2023-07-14 17:24:44 +08:00
|
|
|
|
2023-07-26 14:31:49 +08:00
|
|
|
// alpha = (aRGB & 0xFF000000) >> 24;
|
|
|
|
// red = ((aRGB & 0x00FF0000) >> 16) * alpha;
|
|
|
|
// green = ((aRGB & 0x0000FF00) >> 8) * alpha;
|
|
|
|
// blue = ((aRGB & 0x000000FF) >> 0) * alpha;
|
2023-02-14 11:05:41 +08:00
|
|
|
}
|