WS2822S
Diff: WS2822S.h
- Revision:
- 0:2fc093733833
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WS2822S.h Tue Mar 13 14:25:02 2018 +0000 @@ -0,0 +1,52 @@ +#pragma once + +#include "mbed.h" + +// WS2822S RGB LED control class +// by tessecraft R 2018.03.12 + +class WS2822S_Ctrl +{ +private: + // MTBP:H → BREAK:L → MAB:H → (FirstFrame all Low) → Data 8bit → ... MTBP:H → BREAK:L → MAB:H → ... + + // COLOR Timing names (unit : us) +#define C_MTBP (1000) +#define C_BREAK (88) +#define C_MAB (8) + // Address Timing names +#define A_MTBP (88) +#define A_BREAK (5000) +#define A_MAB (8) + // common StopBit +#define STOP_BIT (8) +private: + // pin + DigitalOut ColorPin; + DigitalOut AddressPin; +private: + // pixcel NUM + int PixcelNum; + // display data + uint8_t **Display; +private: + // Expansion DMX512 protocol + void PutDataHeader(int MTBP, int BREAK, int MAB, DigitalOut* pin, bool AddressHigh = false); + // Color or Address data out + void PutDataHeader(bool AddressHeader = false); + // data put + void DataPut8(uint8_t data, DigitalOut* pin); +public: + WS2822S_Ctrl(PinName ColorPinName, PinName AddressPinName, int PixcelNum); + ~WS2822S_Ctrl(); +public: + // SetPixcelData + void SetColor(int pos, uint8_t R, uint8_t G, uint8_t B); + // Clear Setted color + void ClearColor(uint8_t R = 0, uint8_t G = 0, uint8_t B = 0); + // Output Data + void OutputData(); +public: + // WriteAddress + void OutputAddress(); +}; \ No newline at end of file