ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputWS2811I2S.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputWS2811I2S.h - WS2811 driver code for ESPixelStick I2S Channel
4*
5* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
6* Copyright (c) 2015, 2025 Shelby Merrick
7* http://www.forkineye.com
8*
9* This program is provided free for you to use in any way that you wish,
10* subject to the laws and regulations where you are using it. Due diligence
11* is strongly suggested before using this code. Please give credit where due.
12*
13* The Author makes no warranty of any kind, express or implied, with regard
14* to this program or the documentation contained in this document. The
15* Author shall not be liable in any event for incidental or consequential
16* damages in connection with, or arising out of, the furnishing, performance
17* or use of these programs.
18*
19* This is a derived class that converts data in the output buffer into
20* pixel intensities and then transmits them through the configured serial
21* interface.
22*
23*/
24#include "ESPixelStick.h"
25#if defined(SUPPORT_OutputProtocol_WS2811) && defined(SUPPORT_I2S)
26
27#include "OutputWS2811.hpp"
28#include "OutputI2S.hpp"
29
30class c_OutputWS2811I2S : public c_OutputWS2811
31{
32public:
33 // These functions are inherited from c_OutputCommon
34 c_OutputWS2811I2S (OM_OutputPortDefinition_t & OutputPortDefinition,
36 virtual ~c_OutputWS2811I2S ();
37
38 // functions to be provided by the derived class
39 void Begin ();
40 bool SetConfig (ArduinoJson::JsonObject& jsonConfig);
41 uint32_t Poll () {return 0;}
42 void GetStatus (ArduinoJson::JsonObject& jsonStatus);
43 void SetOutputBufferSize (uint32_t NumChannelsAvailable);
44 void PauseOutput(bool State);
45 void ISR_GetNextDataSlicesToSend (c_OutputI2S::I2S_Item_t * DataToSend, uint32_t numSlices);
46 void ISR_StartNewDataFrame();
47
48 // to be removed when the I2S driver is fully implemented
49 virtual bool RmtPoll() {return false;}
50
51private:
52 void CalculateFrameBitSlices ();
53
54 // The adjustments compensate for rounding errors in the calculations
55 c_OutputI2S *I2Sdriver;
56
57 uint32_t DataBitMask;
58 uint32_t DataBit;
59
60 uint32_t ZeroHighBitSliceCount;
61 uint32_t ZeroLowBitSliceCount;
62
63 uint32_t OneHighBitSliceCount;
64 uint32_t OneLowBitSliceCount;
65
66 uint32_t HighBitCurrentSliceCount;
67 uint32_t LowBitCurrentSliceCount;
68
69 uint32_t FrameResetSliceCount;
70 uint32_t FrameResetCurrentSliceCount;
71
72 uint32_t IdleSliceCount;
73 uint32_t IdleCurrentSliceCount;
74
75 uint32_t DataPattern;
76 uint32_t DataPatternMask;
77
78 #define WS2811_I2S_DEBUG_COUNTERS
79 #ifdef WS2811_I2S_DEBUG_COUNTERS
80 #define INC_WS2811_I2S_DEBUG_COUNTERS(c) (++I2SDebugCounters.c)
81 struct
82 {
83 uint32_t GetDataSlices;
84 uint32_t FrameStarts;
85 uint32_t FrameEnds;
86 uint32_t IdleBitSlices;
87 uint32_t FrameResetBitSlices;
88 uint32_t DataBitSlices;
89 uint32_t DataBytes;
90 uint32_t BitSliceHigh;
91 uint32_t BitSliceLow;
92 uint32_t NextDataBit;
93 uint32_t DataBits;
94 uint32_t DataBitEnd;
95 uint32_t DataByteEnd;
96 } I2SDebugCounters;
97 #else
98 #define INC_WS2811_I2S_DEBUG_COUNTERS(c)
99 #endif // def WS2811_I2S_DEBUG_COUNTERS
100
101}; // c_OutputWS2811I2S
102
103#endif // defined(SUPPORT_OutputProtocol_WS2811) && defined(SUPPORT_I2S)
e_OutputProtocolType
Definition OutputMgr.hpp:87
void SetConfig(const char *DataString)
Definition main.cpp:329
Definition OutputMgrPortDefs.hpp:90