ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputGECERmt.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputGECERmt.h - GECE 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_GECE) && defined(ARDUINO_ARCH_ESP32)
26
27#include "OutputGECE.hpp"
28#include "OutputRmt.hpp"
29
30class c_OutputGECERmt : public c_OutputGECE
31{
32public:
33 // These functions are inherited from c_OutputCommon
34 c_OutputGECERmt (OM_OutputPortDefinition_t & OutputPortDefinition,
36 virtual ~c_OutputGECERmt ();
37
38 // functions to be provided by the derived class
39 void Begin ();
40 bool SetConfig (ArduinoJson::JsonObject& jsonConfig);
41 uint32_t Poll ();
42#if defined(ARDUINO_ARCH_ESP32)
43 bool RmtPoll ();
44#endif // defined(ARDUINO_ARCH_ESP32)
45 void GetStatus (ArduinoJson::JsonObject& jsonStatus);
46 void SetOutputBufferSize (uint32_t NumChannelsAvailable);
47 void PauseOutput (bool State);
48 void StartNewDataFrame();
49 bool ISR_GetNextBitToSend (rmt_item32_t & DataToSend);
50
51private:
52// The adjustments compensate for rounding errors in the calculations
53#define GECE_PIXEL_RMT_TICKS_BIT_0_HIGH uint16_t ( (GECE_PIXEL_NS_BIT_0_HIGH / RMT_TickLengthNS) + 0.0)
54#define GECE_PIXEL_RMT_TICKS_BIT_0_LOW uint16_t ( (GECE_PIXEL_NS_BIT_0_LOW / RMT_TickLengthNS) + 0.0)
55#define GECE_PIXEL_RMT_TICKS_BIT_1_HIGH uint16_t ( (GECE_PIXEL_NS_BIT_1_HIGH / RMT_TickLengthNS) - 1.0)
56#define GECE_PIXEL_RMT_TICKS_BIT_1_LOW uint16_t ( (GECE_PIXEL_NS_BIT_1_LOW / RMT_TickLengthNS) + 1.0)
57#define GECE_PIXEL_RMT_TICKS_STOP uint16_t ( (GECE_PIXEL_STOP_TIME_NS / RMT_TickLengthNS) + 1.0)
58#define GECE_PIXEL_RMT_TICKS_START uint16_t ( (GECE_PIXEL_START_TIME_NS / RMT_TickLengthNS) + 1.0)
59
60 rmt_item32_t ZeroBit {GECE_PIXEL_RMT_TICKS_BIT_0_LOW, 0, GECE_PIXEL_RMT_TICKS_BIT_0_HIGH, 1};
61 rmt_item32_t OneBit {GECE_PIXEL_RMT_TICKS_BIT_1_LOW, 0, GECE_PIXEL_RMT_TICKS_BIT_1_HIGH, 1};
62 rmt_item32_t IfgBit {GECE_PIXEL_RMT_TICKS_START / 2, 0, GECE_PIXEL_RMT_TICKS_START / 2, 0};
63 rmt_item32_t StartBit {GECE_PIXEL_RMT_TICKS_START / 2, 1, GECE_PIXEL_RMT_TICKS_START / 2, 1};
64 uint32_t StartBitCount = 0;
65 rmt_item32_t StopBit {GECE_PIXEL_RMT_TICKS_STOP / 2, 0, GECE_PIXEL_RMT_TICKS_STOP / 2, 0};
66 uint32_t StopBitCount = 0;
67 uint32_t DataPattern = 0;
68 uint32_t CurrentDataMask = 0;
69
70 // #define GECE_RMT_DEBUG_COUNTERS
71 #ifdef GECE_RMT_DEBUG_COUNTERS
72 #define INC_GECE_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 BreakBits = 0;
79 uint32_t MabBits = 0;
80 uint32_t StartBits = 0;
81 uint32_t DataBits = 0;
82 uint32_t StopBits = 0;
83 uint32_t Underrun = 0;
84 } RmtDebugCounters;
85 #else
86 #define INC_GECE_RMT_DEBUG_COUNTERS(c)
87 #endif // def GECE_RMT_DEBUG_COUNTERS
88
89 c_OutputRmt Rmt;
90
91}; // c_OutputGECERmt
92
93#endif // defined(SUPPORT_OutputProtocol_GECE) && defined(ARDUINO_ARCH_ESP32)
e_OutputProtocolType
Definition OutputMgr.hpp:78
void SetConfig(const char *DataString)
Definition main.cpp:329
Definition OutputMgrPortDefs.hpp:90