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
86
87private:
88
89 void InstantiateNewInputChannel (e_InputChannelIds InputChannelId, e_InputType NewChannelType, bool StartDriver = true);
90 void CreateNewConfig ();
92 {
93 uint32_t DriverId = 0;
95 };
96
97 #define NO_CONFIG_NEEDED time_t(-1)
98 #define INPUTMGR_TASK_PRIORITY 5
99
102 bool HasBeenInitialized = false;
105 bool IsConnected = false;
106 bool configInProgress = false;
108 bool PauseProcessing = false;
109
110 // configuration parameter names for the channel manager within the config file
111# define IM_EffectsControlButtonName F ("ecb")
112
113 bool ProcessJsonConfig (JsonObject & jsonConfig);
114 void CreateJsonConfig (JsonObject & jsonConfig);
115 bool ProcessJsonChannelConfig (JsonObject & jsonConfig, uint32_t ChannelIndex);
117 bool FindJsonChannelConfig (JsonObject& jsonConfig, e_InputChannelIds ChanId, JsonObject& ChanConfig);
118
120 bool rebootNeeded = false;
121
123
124# define FPP_TICKER_PERIOD_MS 25
125 Ticker MsTicker;
127
128}; // c_InputMgr
129
130extern c_InputMgr InputMgr;
RecordType type
Definition EFUpdate.h:0
c_FileMgr FileMgr
Definition FileMgr.cpp:2192
#define NO_CONFIG_NEEDED
Definition InputMgr.hpp:97
c_InputMgr InputMgr
Definition InputMgr.cpp:1057
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(const String &FileName)
Definition FileMgr.cpp:560
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:119
bool GetNetworkState()
Definition InputMgr.hpp:64
bool HasBeenInitialized
Definition InputMgr.hpp:102
void Begin(uint32_t BufferSize)
< Start the module
Definition InputMgr.cpp:164
time_t ConfigLoadNeeded
Definition InputMgr.hpp:107
void GetDriverName(String &Name)
Definition InputMgr.hpp:65
void Process()
< Called from loop(), renders Input data
Definition InputMgr.cpp:690
void CreateJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:204
bool InputTypeIsAllowedOnChannel(e_InputType type, e_InputChannelIds ChannelId)
Definition InputMgr.cpp:390
FastTimer BlankEndTime[InputChannelId_End]
Definition InputMgr.hpp:122
DriverInfo_t InputChannelDrivers[InputChannelId_End]
pointer(s) to the current active Input driver
Definition InputMgr.hpp:100
bool ProcessJsonConfig(JsonObject &jsonConfig)
Definition InputMgr.cpp:857
void GetStatus(JsonObject &jsonStatus)
Definition InputMgr.cpp:358
Ticker MsTicker
Definition InputMgr.hpp:125
bool rebootNeeded
Definition InputMgr.hpp:120
void DeleteConfig()
Definition InputMgr.hpp:63
void ScheduleLoadConfig()
Definition InputMgr.hpp:54
uint32_t InputDataBufferSize
Definition InputMgr.hpp:101
void SetBufferInfo(uint32_t BufferSize)
Definition InputMgr.cpp:989
bool IsConnected
Definition InputMgr.hpp:105
virtual ~c_InputMgr()
< deallocate any resources and put the Input channels into a safe state
Definition InputMgr.cpp:133
void LoadConfig()
Definition InputMgr.cpp:654
void SetOperationalState(bool Active)
Definition InputMgr.cpp:1014
void ProcessButtonActions(c_ExternalInput::InputValue_t value)
Definition InputMgr.cpp:758
bool PauseProcessing
Definition InputMgr.hpp:108
void CreateNewConfig()
Definition InputMgr.cpp:289
void SetConfig(const char *NewConfig)
Definition InputMgr.cpp:942
bool ProcessJsonChannelConfig(JsonObject &jsonConfig, uint32_t ChannelIndex)
e_InputType
Definition InputMgr.hpp:71
@ InputType_Alexa
Definition InputMgr.hpp:75
@ InputType_MQTT
Definition InputMgr.hpp:74
@ InputType_E1_31
Definition InputMgr.hpp:72
@ InputType_Effects
Definition InputMgr.hpp:73
@ InputType_End
Definition InputMgr.hpp:82
@ InputType_Start
Definition InputMgr.hpp:83
@ InputType_DDP
Definition InputMgr.hpp:76
@ InputType_Artnet
Definition InputMgr.hpp:80
@ InputType_Default
Definition InputMgr.hpp:84
@ InputType_Disabled
Definition InputMgr.hpp:81
c_ExternalInput ExternalInput
Definition InputMgr.hpp:103
void RestartBlankTimer(e_InputChannelIds Selector)
Definition InputMgr.hpp:66
uint32_t LastTickerTimeStampMS
Definition InputMgr.hpp:126
bool EffectEngineIsConfiguredToRun[InputChannelId_End]
Definition InputMgr.hpp:104
void SetConfig(ArduinoJson::JsonDocument &NewConfig)
void GetConfig(byte *Response, uint32_t maxlen)
Definition InputMgr.cpp:347
c_InputMgr()
< Start up the driver and put it into a safe mode
Definition InputMgr.cpp:114
bool configInProgress
Definition InputMgr.hpp:106
bool FindJsonChannelConfig(JsonObject &jsonConfig, e_InputChannelIds ChanId, JsonObject &ChanConfig)
Definition InputMgr.cpp:776
void NetworkStateChanged(bool IsConnected)
Definition InputMgr.cpp:1037
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:433
bool BlankTimerHasExpired(e_InputChannelIds Selector)
Definition InputMgr.hpp:67
config_t config
Definition main.cpp:93
Definition InputMgr.hpp:92
uint32_t DriverId
Definition InputMgr.hpp:93
c_InputCommon * pInputChannelDriver
pointer(s) to the current active Input driver
Definition InputMgr.hpp:94
uint32_t BlankDelay
Definition ESPixelStick.h:72