ESPixelStick Firmware
Firmware for the ESPixelStick
Loading...
Searching...
No Matches
InputMgr.hpp
Go to the documentation of this file.
1#pragma once
2/*
3* InputMgr.hpp - Input Management class
4*
5* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
6* Copyright (c) 2021, 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 factory class used to manage the input channels. It creates and deletes
20* the input channel functionality as needed to support any new configurations
21* that get sent from from the WebPage.
22*
23*/
24
25#include "ESPixelStick.h"
26#include "FileMgr.hpp"
27#include "output/OutputMgr.hpp"
28#include "externalInput.h"
29#include <TimeLib.h>
30#include <Ticker.h>
31
32class c_InputCommon;
33
35{
36public:
37 // handles to determine which input channel we are dealing with
38 // Channel 1 = primary / show input; Channel 2 = service input
48
49 c_InputMgr ();
50 virtual ~c_InputMgr ();
51
52 void Begin (uint32_t BufferSize);
53 void LoadConfig ();
55 void GetConfig (byte * Response, uint32_t maxlen);
56 void GetStatus (JsonObject & jsonStatus);
57 void SetConfig (const char * NewConfig);
58 void SetConfig (ArduinoJson::JsonDocument & NewConfig);
59 void Process ();
60 void SetBufferInfo (uint32_t BufferSize);
61 void SetOperationalState (bool Active);
64 bool GetNetworkState () { return IsConnected; }
65 void GetDriverName (String & Name) { Name = "InputMgr"; }
66 void RestartBlankTimer (e_InputChannelIds Selector) { BlankEndTime[int(Selector)].StartTimer(config.BlankDelay * 1000, false); }
67 bool BlankTimerHasExpired (e_InputChannelIds Selector) { return (BlankEndTime[int(Selector)].IsExpired()); }
69 bool RemotePlayEnabled (void);
70
87
88private:
89
90 void InstantiateNewInputChannel (e_InputChannelIds InputChannelId, e_InputType NewChannelType, bool StartDriver = true);
91 void CreateNewConfig ();
93 {
94 uint32_t DriverId = 0;
96 };
97
98 #define NO_CONFIG_NEEDED time_t(-1)
99 #define INPUTMGR_TASK_PRIORITY 5
100
103 bool HasBeenInitialized = false;
106 bool IsConnected = false;
107 bool configInProgress = false;
109 bool PauseProcessing = false;
110
111 // configuration parameter names for the channel manager within the config file
112# define IM_EffectsControlButtonName F ("ecb")
113
114 bool ProcessJsonConfig (JsonObject & jsonConfig);
115 void CreateJsonConfig (JsonObject & jsonConfig);
116 bool ProcessJsonChannelConfig (JsonObject & jsonConfig, uint32_t ChannelIndex);
118 bool FindJsonChannelConfig (JsonObject& jsonConfig, e_InputChannelIds ChanId, JsonObject& ChanConfig);
119
121 String InputRebootReason = emptyString;
122 bool RebootNeeded = false;
123
125
126# define FPP_TICKER_PERIOD_MS 25
127 Ticker MsTicker;
129
130}; // c_InputMgr
131
132extern c_InputMgr InputMgr;
RecordType type
Definition EFUpdate.h:0
c_FileMgr FileMgr
Definition FileMgr.cpp:2224
#define NO_CONFIG_NEEDED
Definition InputMgr.hpp:98
c_InputMgr InputMgr
Definition InputMgr.cpp:1088
Definition FastTimer.hpp:24
void StartTimer(uint32_t DurationMS, bool continuous)
< Start the module
Definition FastTimer.cpp:41
Definition externalInput.h:26
InputValue_t
Definition externalInput.h:32
void DeleteFlashFile(String FileName)
Definition FileMgr.cpp:587
Definition InputCommon.hpp:27
forward declaration to the pure virtual Input class that will be defined later.
Definition InputMgr.hpp:35
String ConfigFileName
Definition InputMgr.hpp:120
bool GetNetworkState()
Definition InputMgr.hpp:64
bool HasBeenInitialized
Definition InputMgr.hpp:103
void Begin(uint32_t BufferSize)
< Start the module
Definition InputMgr.cpp:164
time_t ConfigLoadNeeded
Definition InputMgr.hpp:108
void GetDriverName(String &Name)
Definition InputMgr.hpp:65
void Process()
< Called from loop(), renders Input data
Definition InputMgr.cpp:692
void CreateJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:204
bool InputTypeIsAllowedOnChannel(e_InputType type, e_InputChannelIds ChannelId)
Definition InputMgr.cpp:391
FastTimer BlankEndTime[InputChannelId_End]
Definition InputMgr.hpp:124
DriverInfo_t InputChannelDrivers[InputChannelId_End]
pointer(s) to the current active Input driver
Definition InputMgr.hpp:101
bool RebootNeeded
Definition InputMgr.hpp:122
bool ProcessJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:859
void GetStatus(JsonObject &jsonStatus)
Definition InputMgr.cpp:359
Ticker MsTicker
Definition InputMgr.hpp:127
void DeleteConfig()
Definition InputMgr.hpp:63
void ScheduleLoadConfig()
Definition InputMgr.hpp:54
String InputRebootReason
Definition InputMgr.hpp:121
bool RemotePlayEnabled(void)
Definition InputMgr.cpp:943
uint32_t InputDataBufferSize
Definition InputMgr.hpp:102
void SetBufferInfo(uint32_t BufferSize)
Definition InputMgr.cpp:1020
bool IsConnected
Definition InputMgr.hpp:106
virtual ~c_InputMgr()
< deallocate any resources and put the Input channels into a safe state
Definition InputMgr.cpp:133
void LoadConfig()
Definition InputMgr.cpp:656
void SetOperationalState(bool Active)
Definition InputMgr.cpp:1045
void ProcessButtonActions(c_ExternalInput::InputValue_t value)
Definition InputMgr.cpp:760
bool PauseProcessing
Definition InputMgr.hpp:109
void CreateNewConfig()
Definition InputMgr.cpp:289
void SetConfig(const char *NewConfig)
Definition InputMgr.cpp:973
bool ProcessJsonChannelConfig(JsonObject &jsonConfig, uint32_t ChannelIndex)
e_InputType
Definition InputMgr.hpp:72
@ InputType_Alexa
Definition InputMgr.hpp:76
@ InputType_MQTT
Definition InputMgr.hpp:75
@ InputType_E1_31
Definition InputMgr.hpp:73
@ InputType_Effects
Definition InputMgr.hpp:74
@ InputType_End
Definition InputMgr.hpp:83
@ InputType_Start
Definition InputMgr.hpp:84
@ InputType_DDP
Definition InputMgr.hpp:77
@ InputType_Artnet
Definition InputMgr.hpp:81
@ InputType_Default
Definition InputMgr.hpp:85
@ InputType_Disabled
Definition InputMgr.hpp:82
c_ExternalInput ExternalInput
Definition InputMgr.hpp:104
void RestartBlankTimer(e_InputChannelIds Selector)
Definition InputMgr.hpp:66
uint32_t LastTickerTimeStampMS
Definition InputMgr.hpp:128
bool EffectEngineIsConfiguredToRun[InputChannelId_End]
Definition InputMgr.hpp:105
void SetConfig(ArduinoJson::JsonDocument &NewConfig)
void GetConfig(byte *Response, uint32_t maxlen)
Definition InputMgr.cpp:348
c_InputMgr()
< Start up the driver and put it into a safe mode
Definition InputMgr.cpp:114
bool configInProgress
Definition InputMgr.hpp:107
bool FindJsonChannelConfig(JsonObject &jsonConfig, e_InputChannelIds ChanId, JsonObject &ChanConfig)
Definition InputMgr.cpp:778
void NetworkStateChanged(bool IsConnected)
Definition InputMgr.cpp:1068
e_InputChannelIds
Definition InputMgr.hpp:40
@ InputSecondaryChannelId
Definition InputMgr.hpp:42
@ EffectsChannel
Definition InputMgr.hpp:46
@ InputPrimaryChannelId
Definition InputMgr.hpp:41
@ InputChannelId_ALL
Definition InputMgr.hpp:45
@ InputChannelId_End
Definition InputMgr.hpp:43
@ InputChannelId_Start
Definition InputMgr.hpp:44
void InstantiateNewInputChannel(e_InputChannelIds InputChannelId, e_InputType NewChannelType, bool StartDriver=true)
Definition InputMgr.cpp:434
bool BlankTimerHasExpired(e_InputChannelIds Selector)
Definition InputMgr.hpp:67
config_t config
Definition main.cpp:94
Definition InputMgr.hpp:93
uint32_t DriverId
Definition InputMgr.hpp:94
c_InputCommon * pInputChannelDriver
pointer(s) to the current active Input driver
Definition InputMgr.hpp:95
uint32_t BlankDelay
Definition ESPixelStick.h:76