ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputTLS3001RmtFsm.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputTLS3001RmtFsm.h - TLS3001 driver code for ESPixelStick RMT Channel
4*
5* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
6* Copyright (c) 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// forward declaration
28class c_OutputTLS3001Rmt;
29
30enum OutputTLS3001RmtFsmStates_t
31{
32 TLS3001Reset = 0,
33 TLS3001Sync,
34 TLS3001DataStart,
35 TLS3001DataSend,
36 TLS3001DataIdle
37};
38
39/*****************************************************************************/
40/*
41 * Generic fsm base class.
42 */
43/*****************************************************************************/
44class fsm_RMT_state
45{
46public:
47 fsm_RMT_state() {}
48 virtual ~fsm_RMT_state() {}
49 void SetParent(c_OutputTLS3001Rmt *_Parent) {Parent = _Parent;};
50 virtual void GetDriverName (String& Name) = 0;
51public:
52 c_OutputTLS3001Rmt *Parent = nullptr;
53 uint32_t NumberOfOneBitsToSend = 0;
54 uint32_t CommandCodeMask = 0;
55 uint32_t NumberOfZeroBitsToSend = 0;
56 uint32_t NumberOfIdleBitsToSend = 0;
57
58}; // fsm_RMT_state
59
60/*****************************************************************************/
61class fsm_RMT_state_SendSync : public fsm_RMT_state
62{
63public:
64 fsm_RMT_state_SendSync() {}
65 virtual ~fsm_RMT_state_SendSync() {}
66 IRAM_ATTR void Init();
67 IRAM_ATTR bool ISR_GetNextBitToSend (uint32_t &DataToSend);
68 virtual void GetDriverName (String& Name) { Name = "TLS3001SYN"; }
69private:
70 const uint8_t CommandCode = 0b0001;
71}; // fsm_RMT_state_SendSync
72
73/*****************************************************************************/
74class fsm_RMT_state_SendReset : public fsm_RMT_state
75{
76public:
77 fsm_RMT_state_SendReset() {}
78 virtual ~fsm_RMT_state_SendReset() {}
79 IRAM_ATTR void Init();
80 IRAM_ATTR bool ISR_GetNextBitToSend (uint32_t &DataToSend);
81 virtual void GetDriverName (String& Name) { Name = "TLS3001RST"; }
82private:
83 const uint8_t CommandCode = 0b0100;
84}; // fsm_RMT_state_SendReset
85
86/*****************************************************************************/
87class fsm_RMT_state_SendDataStart : public fsm_RMT_state
88{
89public:
90 fsm_RMT_state_SendDataStart() {}
91 virtual ~fsm_RMT_state_SendDataStart() {}
92 IRAM_ATTR void Init();
93 IRAM_ATTR bool ISR_GetNextBitToSend (uint32_t &DataToSend);
94 virtual void GetDriverName (String& Name) { Name = "TLS3001STR"; }
95private:
96 const uint8_t CommandCode = 0b0010;
97
98}; // fsm_RMT_state_SendDataStart
99
100/*****************************************************************************/
101class fsm_RMT_state_SendData : public fsm_RMT_state
102{
103public:
104 fsm_RMT_state_SendData() {}
105 virtual ~fsm_RMT_state_SendData() {}
106 IRAM_ATTR void Init();
107 IRAM_ATTR bool ISR_GetNextBitToSend (uint32_t &DataToSend);
108 IRAM_ATTR bool ISR_RefreshData ();
109 virtual void GetDriverName (String& Name) { Name = "TLS3001DAT"; }
110private:
111 uint32_t DataPattern = 0;
112 uint32_t DataPatternMask = 0;
113 bool MoreDataAvailable = false;
114 uint32_t NumPostDataBitsToSend = 0;
115}; // fsm_RMT_state_SendData
116
117/*****************************************************************************/
118class fsm_RMT_state_SendDataIdle : public fsm_RMT_state
119{
120public:
121 fsm_RMT_state_SendDataIdle() {}
122 virtual ~fsm_RMT_state_SendDataIdle() {}
123 IRAM_ATTR void Init();
124 IRAM_ATTR bool ISR_GetNextBitToSend (uint32_t &DataToSend);
125 virtual void GetDriverName (String& Name) { Name = "TLS3001IDL"; }
126private:
127}; // fsm_RMT_state_SendData
128
129#endif // defined(SUPPORT_OutputProtocol_TLS3001) && defined (ARDUINO_ARCH_ESP32)
void GetDriverName(String &Name)
Definition main.cpp:121