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 #define InputDriverMemorySize 2476
90
91 void InstantiateNewInputChannel (e_InputChannelIds InputChannelId, e_InputType NewChannelType, bool StartDriver = true);
92 void CreateNewConfig ();
94 {
96 uint32_t DriverId = 0;
97 bool DriverInUse = false;
98 };
99
100 #define NO_CONFIG_NEEDED time_t(-1)
101 #define INPUTMGR_TASK_PRIORITY 5
102
105 bool HasBeenInitialized = false;
108 bool IsConnected = false;
109 bool configInProgress = false;
111 bool PauseProcessing = false;
112
113 // configuration parameter names for the channel manager within the config file
114# define IM_EffectsControlButtonName F ("ecb")
115
116 bool ProcessJsonConfig (JsonObject & jsonConfig);
117 void CreateJsonConfig (JsonObject & jsonConfig);
118 bool ProcessJsonChannelConfig (JsonObject & jsonConfig, uint32_t ChannelIndex);
120 bool FindJsonChannelConfig (JsonObject& jsonConfig, e_InputChannelIds ChanId, JsonObject& ChanConfig);
121
124 bool RebootNeeded = false;
125
127
128# define FPP_TICKER_PERIOD_MS 25
129 Ticker MsTicker;
131
132}; // c_InputMgr
133
134extern c_InputMgr InputMgr;
RecordType type
Definition EFUpdate.h:0
c_FileMgr FileMgr
Definition FileMgr.cpp:2241
#define NO_CONFIG_NEEDED
Definition InputMgr.hpp:100
c_InputMgr InputMgr
Definition InputMgr.cpp:1097
#define InputDriverMemorySize
Definition InputMgr.hpp:89
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
bool GetNetworkState()
Definition InputMgr.hpp:64
bool HasBeenInitialized
Definition InputMgr.hpp:105
void Begin(uint32_t BufferSize)
< Start the module
Definition InputMgr.cpp:177
time_t ConfigLoadNeeded
Definition InputMgr.hpp:110
void GetDriverName(String &Name)
Definition InputMgr.hpp:65
void Process()
< Called from loop(), renders Input data
Definition InputMgr.cpp:701
void CreateJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:217
bool InputTypeIsAllowedOnChannel(e_InputType type, e_InputChannelIds ChannelId)
Definition InputMgr.cpp:404
FastTimer BlankEndTime[InputChannelId_End]
Definition InputMgr.hpp:126
DriverInfo_t InputChannelDrivers[InputChannelId_End]
pointer(s) to the current active Input driver
Definition InputMgr.hpp:103
bool RebootNeeded
Definition InputMgr.hpp:124
bool ProcessJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:868
void GetStatus(JsonObject &jsonStatus)
Definition InputMgr.cpp:372
Ticker MsTicker
Definition InputMgr.hpp:129
void DeleteConfig()
Definition InputMgr.hpp:63
void ScheduleLoadConfig()
Definition InputMgr.hpp:54
String InputRebootReason
Definition InputMgr.hpp:123
char ConfigFileName[65]
Definition InputMgr.hpp:122
bool RemotePlayEnabled(void)
Definition InputMgr.cpp:952
uint32_t InputDataBufferSize
Definition InputMgr.hpp:104
void SetBufferInfo(uint32_t BufferSize)
Definition InputMgr.cpp:1029
bool IsConnected
Definition InputMgr.hpp:108
virtual ~c_InputMgr()
< deallocate any resources and put the Input channels into a safe state
Definition InputMgr.cpp:153
void LoadConfig()
Definition InputMgr.cpp:665
void SetOperationalState(bool Active)
Definition InputMgr.cpp:1054
void ProcessButtonActions(c_ExternalInput::InputValue_t value)
Definition InputMgr.cpp:769
bool PauseProcessing
Definition InputMgr.hpp:111
void CreateNewConfig()
Definition InputMgr.cpp:302
void SetConfig(const char *NewConfig)
Definition InputMgr.cpp:982
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:106
void RestartBlankTimer(e_InputChannelIds Selector)
Definition InputMgr.hpp:66
uint32_t LastTickerTimeStampMS
Definition InputMgr.hpp:130
bool EffectEngineIsConfiguredToRun[InputChannelId_End]
Definition InputMgr.hpp:107
void SetConfig(ArduinoJson::JsonDocument &NewConfig)
void GetConfig(byte *Response, uint32_t maxlen)
Definition InputMgr.cpp:361
c_InputMgr()
< Start up the driver and put it into a safe mode
Definition InputMgr.cpp:133
bool configInProgress
Definition InputMgr.hpp:109
bool FindJsonChannelConfig(JsonObject &jsonConfig, e_InputChannelIds ChanId, JsonObject &ChanConfig)
Definition InputMgr.cpp:787
void NetworkStateChanged(bool IsConnected)
Definition InputMgr.cpp:1077
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:447
bool BlankTimerHasExpired(e_InputChannelIds Selector)
Definition InputMgr.hpp:67
config_t config
Definition main.cpp:98
Definition InputMgr.hpp:94
bool DriverInUse
Definition InputMgr.hpp:97
uint32_t DriverId
Definition InputMgr.hpp:96
byte InputDriver[InputDriverMemorySize]
Definition InputMgr.hpp:95
uint32_t BlankDelay
Definition ESPixelStick.h:77