ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputTLS3001Rmt.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputTLS3001Rmt.h - TLS3001 driver code for ESPixelStick RMT 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_TLS3001) && defined (ARDUINO_ARCH_ESP32)
26
27#include "OutputTLS3001.hpp"
28#include "OutputRmt.hpp"
30
31class c_OutputTLS3001Rmt : public c_OutputTLS3001
32{
33public:
34 // These functions are inherited from c_OutputCommon
35 c_OutputTLS3001Rmt(OM_OutputPortDefinition_t & OutputPortDefinition,
37 virtual ~c_OutputTLS3001Rmt ();
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 void SetBitTimes ();
52
53protected:
54 friend class fsm_RMT_state_SendSync;
55 friend class fsm_RMT_state_SendReset;
56 friend class fsm_RMT_state_SendDataStart;
57 friend class fsm_RMT_state_SendData;
58 friend class fsm_RMT_state_SendDataIdle;
59 friend class fsm_RMT_state;
60 OutputTLS3001RmtFsmStates_t CurrentFsmState = OutputTLS3001RmtFsmStates_t::TLS3001DataIdle;
61
62 fsm_RMT_state_SendSync fsm_RMT_state_SendSync_imp;
63 fsm_RMT_state_SendReset fsm_RMT_state_SendReset_imp;
64 fsm_RMT_state_SendDataStart fsm_RMT_state_SendDataStart_imp;
65 fsm_RMT_state_SendData fsm_RMT_state_SendData_imp;
66 fsm_RMT_state_SendDataIdle fsm_RMT_state_SendDataIdle_imp;
67
68 rmt_item32_t RmtResetOneMsDelay;
69 uint32_t NumResetDelayBits = 1;
70
71 rmt_item32_t RmtSyncIdle;
72 uint32_t NumSyncIdleBits = 1;
73
74 rmt_item32_t RmtIfgBit;
75 uint32_t NumIfgBitsPerFrame = 1;
76
77 #define TLS3001_PIXEL_RMT_TICKS_BIT uint16_t(TLS3001_PIXEL_NS_BIT / RMT_TickLengthNS)
78 const rmt_item32_t RmtOneBit = {TLS3001_PIXEL_RMT_TICKS_BIT / 2, 1, TLS3001_PIXEL_RMT_TICKS_BIT / 2, 0};
79 const rmt_item32_t RmtZeroBit = {TLS3001_PIXEL_RMT_TICKS_BIT / 2, 0, TLS3001_PIXEL_RMT_TICKS_BIT / 2, 1};
80
81 bool SendingData = false;
82
83 c_OutputRmt Rmt;
84
85 // #define USE_TLS3001RMT_COUNTERS
86 #ifdef USE_TLS3001RMT_COUNTERS
87 #define INCREMENT_TLS3001_COUNTER(c) (++TLS3001RMTCounters.c)
88 #define INCREMENT_TLS3001_FSM_COUNTER(c) (++Parent->TLS3001RMTCounters.c)
89 struct TLS3001RMTCounters_t
90 {
91 uint32_t FrameStarted = 0;
92 uint32_t FrameErrorNotFinished = 0;
93 uint32_t MinFrameLenMs = uint32_t(-1);
94 uint32_t MaxFrameLenMs = 0;
95 uint32_t MinPollTimeMs = uint32_t(-1);
96 uint32_t MaxPollTimeMs = 0;
97 uint32_t PollCounter = 0;
98 uint32_t TooSoon = 0;
99 uint32_t NoGpio = 0;
100 uint32_t SendReset_Init = 0;
101 uint32_t SendReset_GetNextBitToSend = 0;
102 uint32_t SendSync_Init = 0;
103 uint32_t SendSync_GetNextBitToSend = 0;
104 uint32_t SendDataStart_Init = 0;
105 uint32_t SendDataStart_GetNextBitToSend = 0;
106 uint32_t SendData_Init = 0;
107 uint32_t SendData_GetNextBitToSend = 0;
108 uint32_t SendData_RefreshData = 0;
109 uint32_t SendDataIdle_Init = 0;
110 uint32_t SendDataIdle_GetNextBitToSend = 0;
111 } TLS3001RMTCounters;
112
113 #else
114 #define INCREMENT_TLS3001_COUNTER(c)
115 #define INCREMENT_TLS3001_FSM_COUNTER(c)
116 #endif // def USE_TLS3001RMT_COUNTERS
117
118}; // c_OutputTLS3001Rmt
119
120#endif // defined(SUPPORT_OutputProtocol_TLS3001) && defined (ARDUINO_ARCH_ESP32)
e_OutputProtocolType
Definition OutputMgr.hpp:78
void SetConfig(const char *DataString)
Definition main.cpp:329
Definition OutputMgrPortDefs.hpp:90