ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputWS2811Rmt.hpp
Go to the documentation of this file.
1
#pragma once
2
/*
3
* OutputWS2811Rmt.h - WS2811 driver code for ESPixelStick RMT 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(ARDUINO_ARCH_ESP32)
26
27
#include "
OutputWS2811.hpp
"
28
#include "
OutputRmt.hpp
"
29
30
class
c_OutputWS2811Rmt :
public
c_OutputWS2811
31
{
32
public
:
33
// These functions are inherited from c_OutputCommon
34
c_OutputWS2811Rmt (
OM_OutputPortDefinition_t
& OutputPortDefinition,
35
c_OutputMgr::e_OutputProtocolType
outputType);
36
virtual
~c_OutputWS2811Rmt ();
37
38
// functions to be provided by the derived class
39
void
Begin ();
40
bool
SetConfig
(ArduinoJson::JsonObject& jsonConfig);
41
uint32_t Poll ();
42
bool
RmtPoll ();
43
void
GetStatus (ArduinoJson::JsonObject& jsonStatus);
44
void
SetOutputBufferSize (uint32_t NumChannelsAvailable);
45
void
PauseOutput(
bool
State);
46
bool
ISR_GetNextBitToSend (rmt_item32_t &DataToSend);
47
void
StartNewDataFrame();
48
49
private
:
50
51
#ifdef USE_RMT_DEBUG_COUNTERS
52
uint32_t CanRefresh = 0;
53
uint32_t CannotRefresh = 0;
54
#endif
// def USE_RMT_DEBUG_COUNTERS
55
// The adjustments compensate for rounding errors in the calculations
56
#define WS2811_PIXEL_RMT_TICKS_BIT_0_HIGH uint16_t ( (WS2811_PIXEL_NS_BIT_0_HIGH / RMT_TickLengthNS) + 0.0)
57
#define WS2811_PIXEL_RMT_TICKS_BIT_0_LOW uint16_t ( (WS2811_PIXEL_NS_BIT_0_LOW / RMT_TickLengthNS) + 0.0)
58
#define WS2811_PIXEL_RMT_TICKS_BIT_1_HIGH uint16_t ( (WS2811_PIXEL_NS_BIT_1_HIGH / RMT_TickLengthNS) - 1.0)
59
#define WS2811_PIXEL_RMT_TICKS_BIT_1_LOW uint16_t ( (WS2811_PIXEL_NS_BIT_1_LOW / RMT_TickLengthNS) + 1.0)
60
#define WS2811_PIXEL_RMT_TICKS_IDLE uint16_t ( (WS2811_PIXEL_IDLE_TIME_NS / RMT_TickLengthNS) + 1.0)
61
62
rmt_item32_t ZeroBit;
63
rmt_item32_t OneBit;
64
rmt_item32_t IfgBit;
65
uint32_t IfgBitCount;
66
uint32_t IfgBitCurrentCount;
67
uint32_t DataPattern;
68
uint32_t DataPatternMask;
69
70
// #define WS2811_RMT_DEBUG_COUNTERS
71
#ifdef WS2811_RMT_DEBUG_COUNTERS
72
#define INC_WS2811_RMT_DEBUG_COUNTERS(c) (++RmtDebugCounters.c)
73
struct
74
{
75
uint32_t GetNextBit = 0;
76
uint32_t FrameStarts = 0;
77
uint32_t FrameEnds = 0;
78
uint32_t StartBits = 0;
79
uint32_t IfgBits = 0;
80
uint32_t DataBits = 0;
81
uint32_t DataBytes = 0;
82
uint32_t StopBits = 0;
83
uint32_t Underrun = 0;
84
} RmtDebugCounters;
85
#else
86
#define INC_WS2811_RMT_DEBUG_COUNTERS(c)
87
#endif
// def WS2811_RMT_DEBUG_COUNTERS
88
89
c_OutputRmt Rmt;
90
91
};
// c_OutputWS2811Rmt
92
93
#endif
// defined(SUPPORT_OutputProtocol_WS2811) && defined(ARDUINO_ARCH_ESP32)
ESPixelStick.h
OutputRmt.hpp
OutputWS2811.hpp
c_OutputMgr::e_OutputProtocolType
e_OutputProtocolType
Definition
OutputMgr.hpp:78
SetConfig
void SetConfig(const char *DataString)
Definition
main.cpp:329
OM_OutputPortDefinition_t
Definition
OutputMgrPortDefs.hpp:90
include
output
OutputWS2811Rmt.hpp
Generated by
1.12.0