ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputGrinch.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* OutputGrinch.h - Grinch driver code for ESPixelStick
4*
5* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
6* Copyright (c) 2015, 2024 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 "OutputCommon.hpp"
25#ifdef SUPPORT_OutputProtocol_GRINCH
26
27class c_OutputGrinch : public c_OutputCommon
28{
29public:
30 // These functions are inherited from c_OutputCommon
31 c_OutputGrinch (OM_OutputPortDefinition_t & OutputPortDefinition,
33 virtual ~c_OutputGrinch ();
34
35 // functions to be provided by the derived class
36 virtual bool SetConfig (ArduinoJson::JsonObject & jsonConfig);
37 virtual void GetConfig (ArduinoJson::JsonObject & jsonConfig);
38 void GetDriverName (String & sDriverName) { sDriverName = F("Grinch"); }
39 virtual void GetStatus (ArduinoJson::JsonObject & jsonStatus);
40 virtual void SetOutputBufferSize (uint32_t NumChannelsAvailable);
41 uint32_t GetNumOutputBufferBytesNeeded () { return (NumberOfGrinchChannels); }
42 uint32_t GetNumOutputBufferChannelsServiced () { return (NumberOfGrinchChannels); }
43
44 void StartNewFrame();
45 inline bool IRAM_ATTR ISR_MoreDataToSend () {return SpiOutputDataByteIndex > 0;}
46 bool IRAM_ATTR ISR_GetNextIntensityToSend (uint32_t &DataToSend);
47
48protected:
49
50#define MAX_NUM_SUPPORTED_GRINCHES 4
51#define DATA_CHANNELS_PER_GRINCH 64
52
53private:
54 uint8_t NumberOfGrinchControllers = 1;
55 uint8_t NumberOfGrinchChannels = NumberOfGrinchControllers * DATA_CHANNELS_PER_GRINCH;
56 uint8_t NumberOfGrinchDataBytes = NumberOfGrinchChannels / 8;
57 uint8_t SpiOutputDataByteIndex = 0;
58
59 union GrinchData_s
60 {
61 struct GrinchLatchData
62 {
63 uint8_t LatchChan_01_08 = 0;
64 uint8_t LatchChan_09_16 = 0;
65 uint8_t LatchChan_17_24 = 0;
66 uint8_t LatchChan_25_32 = 0;
67 };
68 uint8_t Data[4];
69 };
70 GrinchData_s dataBuffer[MAX_NUM_SUPPORTED_GRINCHES];
71
72
73}; // c_OutputGrinch
74#endif // def SUPPORT_OutputProtocol_GRINCH
Definition OutputCommon.hpp:32
virtual void GetDriverName(String &sDriverName)=0
get the name for the instantiated driver
virtual uint32_t GetNumOutputBufferChannelsServiced()=0
virtual void GetStatus(ArduinoJson::JsonObject &jsonStatus)=0
virtual uint32_t GetNumOutputBufferBytesNeeded()=0
virtual bool SetConfig(ArduinoJson::JsonObject &jsonConfig)
Set a new config in the driver.
Definition OutputCommon.cpp:78
virtual void GetConfig(ArduinoJson::JsonObject &jsonConfig)
Get the current config used by the driver.
Definition OutputCommon.cpp:95
virtual void SetOutputBufferSize(uint32_t NewOutputBufferSize)
Definition OutputCommon.hpp:57
e_OutputProtocolType
Definition OutputMgr.hpp:78
Definition OutputMgrPortDefs.hpp:90