Files
stc32g128k/App/rgb.h

29 lines
1.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __RGB_H__
#define __RGB_H__
#include "config.h"
/* ====== SPI 控制与级联 WS2812B (FCOB 幻彩灯条) 驱动接口 ====== */
/**
* @brief 初始化 SPI 控制器以驱动 RGB 幻彩灯条
* @details 将 SPI 引脚切换映射到第二组物理引脚 (P2.2~P2.5),并配置 SPI 模块为
* 主机模式 (Master),将通讯时钟速率设置为 3.0 MHz以利用 SPI 字节发送功能
* 高效产生 WS2812B 所需的精确脉冲宽度时序。
*/
void SPI_Init(void);
/**
* @brief 向 FCOB 幻彩灯条发送两颗级联 LED 灯珠的 GRB 三原色数据
* @param g1 LED 1 的绿色亮度 (0~255)
* @param r1 LED 1 的红色亮度 (0~255)
* @param b1 LED 1 的蓝色亮度 (0~255)
* @param g2 LED 2 的绿色亮度 (0~255)
* @param r2 LED 2 的红色亮度 (0~255)
* @param b2 LED 2 的蓝色亮度 (0~255)
* @note 由于 WS2812B 内部芯片使用 GRB 顺序,此函数将色彩数据组合编码后通过 SPI 发送出去。
*/
void RGB_Send(u8 g1, u8 r1, u8 b1, u8 g2, u8 r2, u8 b2);
#endif // __RGB_H__