ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputTLS3001.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputTLS3001.h - TLS3001 driver code for ESPixelStick
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)
26
27#include "OutputPixel.hpp"
28
29/*
30The input signals delivered to the SDI pin must adhere to the following definitions:
31a. Valid input data must be Manchester-encoded;
32 a signal transition from high to low represents a "1,"
33 while a transition from low to high represents a "0."
34b. After the chip is powered on, a synchronization frame must be transmitted
35 first to enable the chip to detect the communication baud rate.
36 The format of the synchronization frame is:
37 15’b111111111111111 +
38 4’b0001 +
39 11’b00000000000.
40 After transmitting the synchronization frame, a delay period must be observed
41 before sending data frames; this ensures that each chip can accurately detect
42 the communication baud rate. The delay duration (in microseconds) must be greater
43 than: (Number of connected chips) ÷ (Communication baud rate in MHz) × 30.
44c. After transmitting a number of data frames, a reset frame must be sent once;
45 after waiting for 1 ms, a synchronization frame must be sent again to allow
46 the chip to eliminate accumulated errors. The format of the reset frame is:
47 15’b111111111111111 +
48 4’b0100.
49d. The format of a data frame is:
50 15’b111111111111111 +
51 4’b0010 (Data Header) +
52 39-bit data for the first chip +
53 39-bit data for the second chip + …… + 39-bit data for the nth chip.
54
55 The first chip is the initial recipient of the data.
56 The data format for the chip is as follows:
57 1'b0 (Identifier Bit) +
58 12'bxxxxxxxxxxxx (Data for Output Port 1) +
59 1'b0 (Identifier Bit) +
60 12'bxxxxxxxxxxxx (Data for Output Port 2) +
61 1'b0 (Identifier Bit) +
62 12'bxxxxxxxxxxxx (Data for Output Port 3),
63 where 'x' represents either 1 or 0.
64f. Data is transmitted Most Significant Bit (MSB) first.
65g. The SDI input pin must be held at a low level during the idle state.
66h. During the transmission of a single data frame, the data must be sent continuously
67 without any interruptions, and the transmission frequency must not change.
68
69*/
70class c_OutputTLS3001 : public c_OutputPixel
71{
72public:
73 // These functions are inherited from c_OutputCommon
74 c_OutputTLS3001 (OM_OutputPortDefinition_t & OutputPortDefinition,
76
77 virtual ~c_OutputTLS3001 ();
78
79 // functions to be provided by the derived class
80 virtual void Begin () { c_OutputPixel::Begin (); }
81 virtual bool SetConfig (ArduinoJson::JsonObject& jsonConfig);
82 virtual void GetConfig (ArduinoJson::JsonObject& jsonConfig);
83 void GetDriverName (String& sDriverName) { sDriverName = CN_TLS3001; }
84 virtual void GetStatus (ArduinoJson::JsonObject & jsonStatus);
85 virtual void SetOutputBufferSize (uint32_t NumChannelsAvailable);
86 bool IRAM_ATTR FrameResetIsNeeded() {return NumFramesSinceLastReset >= NumFramesAllowedBetweenResets;}
87 void IRAM_ATTR ResetFrameCounter() {NumFramesSinceLastReset = 0;}
88 void IRAM_ATTR IncrementFrameCounter() {++NumFramesSinceLastReset;}
89 void ForceFrameReset() {NumFramesSinceLastReset = NumFramesAllowedBetweenResets + 1;}
90protected:
91
92#define TLS3001_PIXEL_DATA_RATE 1000000.0 // bits /sec
93#define TLS3001_PIXEL_NS_BIT ((1.0 / TLS3001_PIXEL_DATA_RATE) * NanoSecondsInASecond)
94#define TLS3001_MIN_IDLE_TIME_US 50
95
96private:
97#define TLS3001_DEFAULT_FRAMES_BETWEEN_RESETS 40
98 uint32_t NumFramesAllowedBetweenResets = TLS3001_DEFAULT_FRAMES_BETWEEN_RESETS;
99 uint32_t NumFramesSinceLastReset = uint32_t(-1); // Force a reset on power on.
100
101}; // c_OutputTLS3001
102
103#endif // def SUPPORT_OutputProtocol_TLS3001
const CN_PROGMEM char CN_TLS3001[]
Definition ConstNames.cpp:228
virtual void GetDriverName(String &sDriverName)=0
get the name for the instantiated driver
virtual void Begin()
set up the operating environment based on the current config (or defaults)
Definition OutputCommon.hpp:41
e_OutputProtocolType
Definition OutputMgr.hpp:78
Definition OutputPixel.hpp:28
virtual void SetOutputBufferSize(uint32_t NumChannelsAvailable)
Definition OutputPixel.cpp:113
virtual void GetStatus(ArduinoJson::JsonObject &jsonStatus)
Definition OutputPixel.cpp:77
virtual bool SetConfig(ArduinoJson::JsonObject &jsonConfig)
Set a new config in the driver.
Definition OutputPixel.cpp:178
virtual void GetConfig(ArduinoJson::JsonObject &jsonConfig)
Get the current config used by the driver.
Definition OutputPixel.cpp:50
Definition OutputMgrPortDefs.hpp:90