ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
OutputRelay.hpp
Go to the documentation of this file.
1#pragma once
2/******************************************************************
3*
4* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel (And Serial!) driver
5* Orginal ESPixelStickproject by 2015 Shelby Merrick
6*
7* Brought to you by:
8* Bill Porter
9* www.billporter.info
10*
11* See Readme for other info and version history
12*
13*
14*This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19<http://www.gnu.org/licenses/>
20*
21*This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
22*To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or
23*send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
24******************************************************************
25*
26* This is a derived class that converts data in the output buffer into
27* Relay States and then outputs on a GPIO
28*
29*/
30#include "ESPixelStick.h"
31
32#ifdef SUPPORT_OutputType_Relay
33
34#include "OutputCommon.hpp"
35
36class c_OutputRelay : public c_OutputCommon
37{
38public:
39 struct RelayChannel_t
40 {
41 bool Enabled;
42 bool InvertOutput;
43 bool Pwm;
44 uint8_t OnOffTriggerLevel;
45 gpio_num_t GpioId;
46 uint8_t OnValue;
47 uint8_t OffValue;
48 uint8_t previousValue;
49#if defined(ARDUINO_ARCH_ESP32)
50 uint16_t PwmFrequency;
51#endif // defined(ARDUINO_ARCH_ESP32)
52
53 };
54
55 // These functions are inherited from c_OutputCommon
56 c_OutputRelay (c_OutputMgr::e_OutputChannelIds OutputChannelId,
57 gpio_num_t outputGpio,
58 uart_port_t uart,
59 c_OutputMgr::e_OutputType outputType);
60 virtual ~c_OutputRelay ();
61
62 // functions to be provided by the derived class
63 void Begin ();
64 bool SetConfig (ArduinoJson::JsonObject & jsonConfig);
65 void GetConfig (ArduinoJson::JsonObject & jsonConfig);
66 uint32_t Poll ();
67#if defined(ARDUINO_ARCH_ESP32)
68 bool RmtPoll () {return false;}
69#endif // defined(ARDUINO_ARCH_ESP32)
70 void GetDriverName (String& sDriverName);
71 void GetStatus (ArduinoJson::JsonObject & jsonStatus);
72 uint32_t GetNumOutputBufferBytesNeeded () { return Num_Channels; }
73 uint32_t GetNumOutputBufferChannelsServiced () { return Num_Channels; }
74 bool ValidateGpio (gpio_num_t ConsoleTxGpio, gpio_num_t ConsoleRxGpio);
75
76private:
77# define OM_RELAY_CHANNEL_LIMIT 8
78# define OM_RELAY_UPDATE_INTERVAL_NAME CN_updateinterval
79# define OM_RELAY_CHANNEL_ENABLED_NAME CN_en
80# define OM_RELAY_CHANNEL_INVERT_NAME CN_inv
81# define OM_RELAY_CHANNEL_PWM_NAME CN_pwm
82
83 bool validate ();
84
85 // config data
86 RelayChannel_t OutputList[OM_RELAY_CHANNEL_LIMIT];
87 uint16_t UpdateInterval = 0;
88
89 // non config data
90 String OutputName;
91 uint16_t Num_Channels = OM_RELAY_CHANNEL_LIMIT;
92
93}; // c_OutputRelay
94
95#endif // def SUPPORT_OutputType_Relay
Definition OutputCommon.hpp:31
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:43
virtual bool ValidateGpio(gpio_num_t ConsoleTxGpio, gpio_num_t ConsoleRxGpio)
Definition OutputCommon.cpp:150
virtual uint32_t GetNumOutputBufferChannelsServiced()=0
virtual void GetStatus(ArduinoJson::JsonObject &jsonStatus)=0
virtual uint32_t Poll()=0
Call from loop(), renders output data.
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
e_OutputChannelIds
Definition OutputMgr.hpp:67
e_OutputType
Definition OutputMgr.hpp:126