ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputUCS1903Rmt.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputUCS1903Rmt.h - UCS1903 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
26#if defined(SUPPORT_OutputProtocol_UCS1903) && defined(ARDUINO_ARCH_ESP32)
27
28#include "OutputUCS1903.hpp"
29#include "OutputRmt.hpp"
30
31class c_OutputUCS1903Rmt : public c_OutputUCS1903
32{
33public:
34 // These functions are inherited from c_OutputCommon
35 c_OutputUCS1903Rmt (OM_OutputPortDefinition_t & OutputPortDefinition,
37 virtual ~c_OutputUCS1903Rmt ();
38
39 // functions to be provided by the derived class
40 void Begin ();
41 bool SetConfig (ArduinoJson::JsonObject& jsonConfig);
42 uint32_t Poll ();
43 bool RmtPoll ();
44 void GetStatus (ArduinoJson::JsonObject& jsonStatus);
45 void SetOutputBufferSize (uint32_t NumChannelsAvailable);
46 void PauseOutput(bool State);
47 bool ISR_GetNextBitToSend (rmt_item32_t &DataToSend);
48 void StartNewDataFrame();
49
50private:
51
52// The adjustments compensate for rounding errors in the calculations
53#define UCS1903_PIXEL_RMT_TICKS_BIT_0_HIGH uint16_t ( (UCS1903_PIXEL_NS_BIT_0_HIGH / RMT_TickLengthNS) + 0.0)
54#define UCS1903_PIXEL_RMT_TICKS_BIT_0_LOW uint16_t ( (UCS1903_PIXEL_NS_BIT_0_LOW / RMT_TickLengthNS) + 0.0)
55#define UCS1903_PIXEL_RMT_TICKS_BIT_1_HIGH uint16_t ( (UCS1903_PIXEL_NS_BIT_1_HIGH / RMT_TickLengthNS) - 1.0)
56#define UCS1903_PIXEL_RMT_TICKS_BIT_1_LOW uint16_t ( (UCS1903_PIXEL_NS_BIT_1_LOW / RMT_TickLengthNS) + 1.0)
57#define UCS1903_PIXEL_RMT_TICKS_IDLE uint16_t ( (UCS1903_PIXEL_IDLE_TIME_NS / RMT_TickLengthNS) + 1.0)
58
59// {{UCS1903_PIXEL_RMT_TICKS_IDLE / 10, 0, UCS1903_PIXEL_RMT_TICKS_IDLE / 10, 1}, c_OutputRmt::RmtDataBitIdType_t::RMT_INTERFRAME_GAP_ID},
60
61 rmt_item32_t ZeroBit = {UCS1903_PIXEL_RMT_TICKS_BIT_0_HIGH, 0, UCS1903_PIXEL_RMT_TICKS_BIT_0_LOW, 1};
62 rmt_item32_t OneBit = {UCS1903_PIXEL_RMT_TICKS_BIT_1_HIGH, 0, UCS1903_PIXEL_RMT_TICKS_BIT_1_LOW, 1};
63 rmt_item32_t IfgBit;
64 uint32_t IfgBitCount;
65 uint32_t IfgBitCurrentCount;
66 uint32_t DataPattern;
67 uint32_t DataPatternMask;
68
69 // #define UCS1903_RMT_DEBUG_COUNTERS
70 #ifdef UCS1903_RMT_DEBUG_COUNTERS
71 #define INC_UCS1903_RMT_DEBUG_COUNTERS(c) (++RmtDebugCounters.c)
72 struct
73 {
74 uint32_t GetNextBit = 0;
75 uint32_t FrameStarts = 0;
76 uint32_t FrameEnds = 0;
77 uint32_t BreakBits = 0;
78 uint32_t MabBits = 0;
79 uint32_t StartBits = 0;
80 uint32_t DataBits = 0;
81 uint32_t StopBits = 0;
82 uint32_t Underrun = 0;
83 } RmtDebugCounters;
84 #else
85 #define INC_UCS1903_RMT_DEBUG_COUNTERS(c)
86 #endif // def UCS1903_RMT_DEBUG_COUNTERS
87
88 c_OutputRmt Rmt;
89
90}; // c_OutputUCS1903Rmt
91
92#endif // defined(SUPPORT_OutputProtocol_UCS1903) && defined(ARDUINO_ARCH_ESP32)
e_OutputProtocolType
Definition OutputMgr.hpp:78
void SetConfig(const char *DataString)
Definition main.cpp:329
Definition OutputMgrPortDefs.hpp:90