WS2812B Liblary this use SPI
Diff: WS2812B.h
- Revision:
- 6:21a721b31a20
- Parent:
- 5:62b6ac21c199
--- a/WS2812B.h Wed Jul 17 14:06:08 2019 +0000 +++ b/WS2812B.h Sat Dec 21 15:33:10 2019 +0000 @@ -10,6 +10,8 @@ #ifndef STM32F4xx_WS2812B_HPP #define STM32F4xx_WS2812B_HPP +enum RGB {B,G,R}; + class WS2812B { public: @@ -26,11 +28,14 @@ void Reset() { wait_us(50); } void Clear(int k); // k 個の LED を消灯 void Brightness(double brightness); + uint32_t BrightAdjust(uint32_t x,double brightness); + void Normalize(bool a = true); private: uint32_t *colors; int bufferSize; double bright; + bool normalize; SPI spi_; SPI_TypeDef *mySpi_; @@ -40,10 +45,11 @@ void Send3Bytes(uint16_t x0, uint16_t x1, uint16_t x2); void T0HL() { Send3Bytes(0b11111111, 0b0, 0b0); } // 0 を送る void T1HL() { Send3Bytes(0b11111111, 0b11111111, 0b0); } // 1 を送る - //void T0HL() { Send3Bytes(0b11100000); } // 0 を送る - //void T1HL() { Send3Bytes(0b11111000); } // 1 を送る void SendByteNorm(uint8_t x); // データをそのまま送る void SendByteInv(uint8_t x); // データを反転して送る + + uint8_t getRGB(uint32_t color,RGB rgb); + uint32_t NormalizeAdjust(uint32_t x); // コピー・コンストラクタと代入演算子は使用禁止 WS2812B(const WS2812B&);