代码拉取完成,页面将自动刷新
#ifndef __WS2812B_H__
#define __WS2812B_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**************************************************************
*
* @brief 驱动WS2812B的方式
*
* ************************************************************/
#define WS2812B_DRV_MODE_SPI 0
#define WS2812B_DRV_MODE_RMT 1
#define WS2812B_DRV_MODE_PWM 2
#define WS2812B_DRV_MODE WS2812B_DRV_MODE_RMT
#define WS2812B_PIXEL_NUM 1
#define WS2812B_GRB 24
#define WS2812B_BREATHING_RATIO 4
#define WS2812B_BREATHING_LEVEL (510*WS2812B_BREATHING_RATIO)
/**************************************************************
*
* @brief spi驱动WS2812B
*
* ************************************************************/
#if (WS2812B_DRV_MODE == WS2812B_DRV_MODE_SPI)
#define WS2812B_SPI_HOST SPI3_HOST
#define WS2812B_SPI_DMA_CHANNEL 3
#define WS2812B_SPI_MOSI_PIN 14
#define WS2812B_SPI_TH 0xF8 //11111000
#define WS2812B_SPI_TL 0XE0 //11100000
#define WS2812B_SPI_RST 0X00 //00000000
void ws2812b_spi_init(uint32_t pin_mosi, uint32_t dma_ch);
/**************************************************************
*
* @brief RMT驱动WS2812B
*
* ************************************************************/
#elif (WS2812B_DRV_MODE == WS2812B_DRV_MODE_RMT)
#include "driver/rmt.h"
#define WS2812B_RMT_CHANNEL RMT_CHANNEL_0
#define WS2812B_RMT_PIN 14
#define WS2812B_RMT_CLK_DIV 2 /*!< RMT counter clock divider */
//#define RMT_TICK_1_NS (1/(80000000/RMT_CLK_DIV)) /*!< RMT counter value for 10 us.(Source clock is APB clock) */
// APB_CLK 80MHz, clock_cycle = 1/80/RMT_CLK_DIV = 25ns
#define WS2812B_RMT_T0H 14 // 0 bit high
#define WS2812B_RMT_T1H 28 // 1 bit high time
#define WS2812B_RMT_T0L 32 // low time for either bit
#define WS2812B_RMT_T1L 24 // low time for either bit
void ws2812b_rmt_init(uint32_t pin_rmt, uint32_t rmt_ch);
#elif (WS2812B_DRV_MODE == WS2812B_DRV_MODE_PWM)
#endif
/**************************************************************
*
* @brief WS2812B api
*
* ************************************************************/
void ws2812b_set_breathing0(uint32_t rgb, uint8_t wait);
void ws2812b_set_breathing1(uint32_t rgb);
void ws2812b_rainbow(uint8_t wait);
void ws2812b_set_pixel_rgb(uint32_t n, uint32_t rgb);
void ws2812b_set_pixel_grb(uint32_t n, uint32_t grb);
void ws2812b_fill_color(uint32_t rgb);
void ws2812b_close_all(void);
#ifdef __cplusplus
}
#endif
#endif //end of file
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。