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_OutputType_GRINCH
26
27class c_OutputGrinch : public c_OutputCommon
28{
29public:
30 // These functions are inherited from c_OutputCommon
31 c_OutputGrinch (c_OutputMgr::e_OutputChannelIds OutputChannelId,
32 gpio_num_t outputGpio,
33 uart_port_t uart,
34 c_OutputMgr::e_OutputType outputType);
35 virtual ~c_OutputGrinch ();
36
37 // functions to be provided by the derived class
38 virtual bool SetConfig (ArduinoJson::JsonObject & jsonConfig);
39 virtual void GetConfig (ArduinoJson::JsonObject & jsonConfig);
40 void GetDriverName (String & sDriverName) { sDriverName = F("Grinch"); }
41 virtual void GetStatus (ArduinoJson::JsonObject & jsonStatus);
42 virtual void SetOutputBufferSize (uint32_t NumChannelsAvailable);
43 uint32_t GetNumOutputBufferBytesNeeded () { return (NumberOfGrinchChannels); }
44 uint32_t GetNumOutputBufferChannelsServiced () { return (NumberOfGrinchChannels); }
45
46 void StartNewFrame();
47 inline bool IRAM_ATTR ISR_MoreDataToSend () {return SpiOutputDataByteIndex > 0;}
48 bool IRAM_ATTR ISR_GetNextIntensityToSend (uint32_t &DataToSend);
49
50protected:
51
52#define MAX_NUM_SUPPORTED_GRINCHES 4
53#define DATA_CHANNELS_PER_GRINCH 64
54
55private:
56 uint8_t NumberOfGrinchControllers = 1;
57 uint8_t NumberOfGrinchChannels = NumberOfGrinchControllers * DATA_CHANNELS_PER_GRINCH;
58 uint8_t NumberOfGrinchDataBytes = NumberOfGrinchChannels / 8;
59 uint8_t SpiOutputDataByteIndex = 0;
60
61 union GrinchData_s
62 {
63 struct GrinchLatchData
64 {
65 uint8_t LatchChan_01_08 = 0;
66 uint8_t LatchChan_09_16 = 0;
67 uint8_t LatchChan_17_24 = 0;
68 uint8_t LatchChan_25_32 = 0;
69 };
70 uint8_t Data[4];
71 };
72 GrinchData_s dataBuffer[MAX_NUM_SUPPORTED_GRINCHES];
73
74
75}; // c_OutputGrinch
76#endif // def SUPPORT_OutputType_GRINCH
Definition OutputCommon.hpp:31
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:94
virtual void GetConfig(ArduinoJson::JsonObject &jsonConfig)
Get the current config used by the driver.
Definition OutputCommon.cpp:111
virtual void SetOutputBufferSize(uint32_t NewOutputBufferSize)
Definition OutputCommon.hpp:59
e_OutputChannelIds
Definition OutputMgr.hpp:67
e_OutputType
Definition OutputMgr.hpp:126