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, 2026 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 bool ISR_GetNextDataSlicesToSend (c_OutputI2S::I2S_Item_t * DataToSend, uint32_t numSlices, c_OutputI2S::I2S_Item_t DefaultIntensitySliceData);
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 bool ISR_SetUpNextDataToSend ();
54
55 // The adjustments compensate for rounding errors in the calculations
56 c_OutputI2S *I2Sdriver;
57
58 uint32_t DataBitMask;
59 uint32_t DataBit;
60
61 uint32_t ZeroHighBitSliceCount;
62 uint32_t ZeroLowBitSliceCount;
63
64 uint32_t OneHighBitSliceCount;
65 uint32_t OneLowBitSliceCount;
66
67 uint32_t HighBitCurrentSliceCount;
68 uint32_t LowBitCurrentSliceCount;
69
70 uint32_t FrameResetSliceCount;
71 uint32_t FrameResetCurrentSliceCount;
72
73 uint32_t IdleSliceCount;
74 uint32_t IdleCurrentSliceCount;
75
76 uint32_t DataPattern;
77 uint32_t DataPatternMask;
78
79 #define WS2811_I2S_DEBUG_COUNTERS
80 #ifdef WS2811_I2S_DEBUG_COUNTERS
81 #define INC_WS2811_I2S_DEBUG_COUNTER(c) (I2SDebugCounters.c++)
82 struct
83 {
84 uint32_t GetDataSlices;
85 uint32_t FrameStarts;
86 uint32_t FrameEnds;
87 uint32_t IdleBitSlices;
88 uint32_t FrameResetBitSlices;
89 uint32_t DataBitSlices;
90 uint32_t DataBytes;
91 uint32_t BitSliceHigh;
92 uint32_t BitSliceLow;
93 uint32_t NextDataBit;
94 uint32_t DataBits;
95 uint32_t DataBitEnd;
96 uint32_t DataByteEnd;
97 uint32_t UnKnownFrameState;
98 } I2SDebugCounters;
99 #else
100 #define INC_WS2811_I2S_DEBUG_COUNTER(c)
101 #endif // def WS2811_I2S_DEBUG_COUNTERS
102
103 enum OutputWS2811I2S_FSM_States
104 {
105 _OutputWS2811I2S_FSM_State_FrameReset,
106 _OutputWS2811I2S_FSM_State_DataHigh,
107 _OutputWS2811I2S_FSM_State_DataLow,
108 _OutputWS2811I2S_FSM_State_Idle
109 };
110 OutputWS2811I2S_FSM_States volatile OutputWS2811I2S_FSM_State = OutputWS2811I2S_FSM_States::_OutputWS2811I2S_FSM_State_Idle;
111
112}; // c_OutputWS2811I2S
113
114#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