Skip to content

Commit

Permalink
Changed how timing is generated in the input sub system.
Browse files Browse the repository at this point in the history
Removed a lot of fiddely flags that made the code hard to follow.
  • Loading branch information
MartinMueller2003 committed Dec 31, 2024
1 parent 180d9aa commit 0972988
Show file tree
Hide file tree
Showing 39 changed files with 174 additions and 243 deletions.
2 changes: 1 addition & 1 deletion include/input/InputAlexa.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class c_InputAlexa : public c_InputCommon
bool SetConfig (JsonObject& jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process (bool StayDark);
void Process ();
void GetDriverName (String& sDriverName) { sDriverName = "Alexa"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);

Expand Down
4 changes: 2 additions & 2 deletions include/input/InputArtnet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ArtnetInput.h - Code to wrap ESPAsyncArtnet for input
*
* Project: ESPixelStick - An ESP8266 / ESP32 and Artnet based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* Copyright (c) 2021, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -79,6 +79,6 @@ class c_InputArtnet : public c_InputCommon
void SetBufferInfo (uint32_t BufferSize);
void NetworkStateChanged (bool IsConnected); // used by poorly designed rx functions
bool isShutDownRebootNeeded () { return HasBeenInitialized; }
virtual void Process (bool StayDark) {} ///< Call from loop(), renders Input data
virtual void Process () {} ///< Call from loop(), renders Input data

};
6 changes: 3 additions & 3 deletions include/input/InputCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* InputCommon.hpp - Input base class
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* Copyright (c) 2021, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -36,7 +36,7 @@ class c_InputCommon
virtual bool SetConfig (ArduinoJson::JsonObject & jsonConfig) = 0; ///< Set a new config in the driver
virtual void GetConfig (ArduinoJson::JsonObject & jsonConfig) = 0; ///< Get the current config used by the driver
virtual void GetStatus (JsonObject & jsonStatus) = 0;
virtual void Process (bool StayDark) = 0; ///< Call from loop(), renders Input data
virtual void Process (void) = 0; ///< Call from loop(), renders Input data
virtual void GetDriverName (String & sDriverName) = 0; ///< get the name for the instantiated driver
virtual void SetBufferInfo (uint32_t BufferSize) = 0;
virtual void SetOperationalState (bool ActiveFlag) { IsInputChannelActive = ActiveFlag; }
Expand All @@ -49,7 +49,7 @@ class c_InputCommon

protected:
bool HasBeenInitialized = false;
uint32_t InputDataBufferSize = 0;
uint32_t InputDataBufferSize = 0;
bool IsInputChannelActive = true;
c_InputMgr::e_InputChannelIds InputChannelId = c_InputMgr::e_InputChannelIds::InputChannelId_ALL;
c_InputMgr::e_InputType ChannelType = c_InputMgr::e_InputType::InputType_Disabled;
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputDDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class c_InputDDP : public c_InputCommon
bool SetConfig (JsonObject& jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process (bool StayDark); ///< Call from loop(), renders Input data
void Process (); ///< Call from loop(), renders Input data
void GetDriverName (String& sDriverName) { sDriverName = "DDP"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);
bool isShutDownRebootNeeded () { return HasBeenInitialized; }
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputDisabled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class c_InputDisabled : public c_InputCommon
bool SetConfig (JsonObject & jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject & jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject & jsonStatus);
void Process (bool StayDark);
void Process ();
void GetDriverName (String& sDriverName) { sDriverName = "Disabled"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize) {}

Expand Down
2 changes: 1 addition & 1 deletion include/input/InputE131.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class c_InputE131 : public c_InputCommon
bool SetConfig (JsonObject & jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject & jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject & jsonStatus);
void Process (bool StayDark);
void Process ();
void GetDriverName (String & sDriverName) { sDriverName = "E1.31"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);
void NetworkStateChanged (bool IsConnected); // used by poorly designed rx functions
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputEffectEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class c_InputEffectEngine : public c_InputCommon
void GetMqttConfig (MQTTConfiguration_s& mqttConfig); ///< Get the current config used by the driver
void GetMqttEffectList (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process (bool StayDark);
void Process ();
void Poll (); ///< Call from loop(), renders Input data
void GetDriverName (String & sDriverName) { sDriverName = "Effects"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);
Expand Down
6 changes: 1 addition & 5 deletions include/input/InputFPPRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class c_InputFPPRemote : public c_InputCommon
bool SetConfig (JsonObject& jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process (bool StayDark);
void TaskProcess (); ///< Call from loop(), renders Input data
void Process ();
void GetDriverName (String& sDriverName) { sDriverName = "FPP Remote"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);
void ProcessButtonActions(c_ExternalInput::InputValue_t value);
Expand All @@ -53,9 +52,6 @@ class c_InputFPPRemote : public c_InputCommon
bool GetSendFppSync () { return SendFppSync; }

String StatusType;
bool StayDark = false;
bool Disabled = false;
bool DisableTask = false;

private:

Expand Down
2 changes: 1 addition & 1 deletion include/input/InputFPPRemotePlayEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class c_InputFPPRemotePlayEffect : public c_InputFPPRemotePlayItem
virtual void Start (String & FileName, float duration, uint32_t PlayCount);
virtual void Stop ();
virtual void Sync (String & FileName, float SecondsElapsed);
virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void GetStatus (JsonObject & jsonStatus);
virtual bool IsIdle () { return (pCurrentFsmState == &fsm_PlayEffect_state_Idle_imp); }

Expand Down
6 changes: 3 additions & 3 deletions include/input/InputFPPRemotePlayEffectFsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class fsm_PlayEffect_state
fsm_PlayEffect_state() {}
virtual ~fsm_PlayEffect_state() {}

virtual bool Poll (bool StayDark) = 0;
virtual bool Poll () = 0;
virtual void Init (c_InputFPPRemotePlayEffect * Parent) = 0;
virtual void GetStateName (String & sName) = 0;
virtual void Start (String & FileName, float SecondsElapsed) = 0;
Expand All @@ -56,7 +56,7 @@ class fsm_PlayEffect_state_Idle : public fsm_PlayEffect_state
fsm_PlayEffect_state_Idle() {}
virtual ~fsm_PlayEffect_state_Idle() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayEffect* Parent);
virtual void GetStateName (String & sName) { sName = CN_Idle; }
virtual void Start (String & FileName, float SecondsElapsed);
Expand All @@ -73,7 +73,7 @@ class fsm_PlayEffect_state_PlayingEffect : public fsm_PlayEffect_state
fsm_PlayEffect_state_PlayingEffect() {}
virtual ~fsm_PlayEffect_state_PlayingEffect() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayEffect* Parent);
virtual void GetStateName (String & sName) { sName = CN_Effect; }
virtual void Start (String & FileName, float SecondsElapsed);
Expand Down
4 changes: 2 additions & 2 deletions include/input/InputFPPRemotePlayFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class c_InputFPPRemotePlayFile : public c_InputFPPRemotePlayItem
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
virtual void Stop ();
virtual void Sync (String& FileName, float SecondsElapsed);
virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void GetStatus (JsonObject & jsonStatus);
virtual bool IsIdle () { return (pCurrentFsmState == &fsm_PlayFile_state_Idle_imp); }

Expand Down Expand Up @@ -105,7 +105,7 @@ class c_InputFPPRemotePlayFile : public c_InputFPPRemotePlayItem
void UpdateElapsedPlayTimeMS ();
uint32_t CalculateFrameId (uint32_t ElapsedMS, int32_t SyncOffsetMS);
bool ParseFseqFile ();
uint32_t ReadFile(uint32_t DestinationIntensityId, uint32_t NumBytesToRead, uint32_t FileOffset);
uint32_t ReadFile(uint32_t DestinationIntensityId, uint32_t NumBytesToRead, uint32_t FileOffset);

String LastFailedPlayStatusMsg;

Expand Down
12 changes: 6 additions & 6 deletions include/input/InputFPPRemotePlayFileFsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class fsm_PlayFile_state
fsm_PlayFile_state() {}
virtual ~fsm_PlayFile_state() {}

virtual bool Poll (bool StayDark) = 0;
virtual bool Poll () = 0;
virtual void Init (c_InputFPPRemotePlayFile * Parent) = 0;
virtual void GetStateName (String & sName) = 0;
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount) = 0;
Expand All @@ -57,7 +57,7 @@ class fsm_PlayFile_state_Idle : public fsm_PlayFile_state
fsm_PlayFile_state_Idle() {}
virtual ~fsm_PlayFile_state_Idle() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayFile* Parent);
virtual void GetStateName (String & sName) { sName = CN_Idle; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
Expand All @@ -74,7 +74,7 @@ class fsm_PlayFile_state_Starting : public fsm_PlayFile_state
fsm_PlayFile_state_Starting() {}
virtual ~fsm_PlayFile_state_Starting() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayFile* Parent);
virtual void GetStateName (String& sName) { sName = F ("Starting"); }
virtual void Start (String& FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
Expand All @@ -91,7 +91,7 @@ class fsm_PlayFile_state_PlayingFile : public fsm_PlayFile_state
fsm_PlayFile_state_PlayingFile() {}
virtual ~fsm_PlayFile_state_PlayingFile() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayFile* Parent);
virtual void GetStateName (String & sName) { sName = CN_File; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
Expand All @@ -116,7 +116,7 @@ class fsm_PlayFile_state_Stopping : public fsm_PlayFile_state
fsm_PlayFile_state_Stopping() {}
virtual ~fsm_PlayFile_state_Stopping() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayFile* Parent);
virtual void GetStateName (String& sName) { sName = F("Stopping"); }
virtual void Start (String& FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
Expand All @@ -138,7 +138,7 @@ class fsm_PlayFile_state_Error : public fsm_PlayFile_state
fsm_PlayFile_state_Error() {}
virtual ~fsm_PlayFile_state_Error() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayFile* Parent);
virtual void GetStateName (String& sName) { sName = F ("Error"); }
virtual void Start (String& FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputFPPRemotePlayItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class c_InputFPPRemotePlayItem
c_InputFPPRemotePlayItem (c_InputMgr::e_InputChannelIds InputChannelId);
virtual ~c_InputFPPRemotePlayItem ();

virtual bool Poll (bool StayDark) = 0;
virtual bool Poll () = 0;
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount) = 0;
virtual void Stop () = 0;
virtual void Sync (String & FileName, float SecondsElapsed) = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputFPPRemotePlayList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class c_InputFPPRemotePlayList : public c_InputFPPRemotePlayItem
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
virtual void Stop ();
virtual void Sync (String & FileName, float SecondsElapsed);
virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void GetStatus (JsonObject & jsonStatus);
virtual bool IsIdle () { return (pCurrentFsmState == &fsm_PlayList_state_Idle_imp); }

Expand Down
12 changes: 6 additions & 6 deletions include/input/InputFPPRemotePlayListFsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class fsm_PlayList_state
fsm_PlayList_state() {}
virtual ~fsm_PlayList_state() {}

virtual bool Poll (bool StayDark) = 0;
virtual bool Poll () = 0;
virtual void Init (c_InputFPPRemotePlayList * Parent) = 0;
virtual void GetStateName (String & sName) = 0;
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount) = 0;
Expand All @@ -56,7 +56,7 @@ class fsm_PlayList_state_WaitForStart : public fsm_PlayList_state
fsm_PlayList_state_WaitForStart() {}
virtual ~fsm_PlayList_state_WaitForStart() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayList* Parent);
virtual void GetStateName (String & sName) { sName = CN_Idle; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
Expand All @@ -72,7 +72,7 @@ class fsm_PlayList_state_Idle : public fsm_PlayList_state
fsm_PlayList_state_Idle() {}
virtual ~fsm_PlayList_state_Idle() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayList* Parent);
virtual void GetStateName (String & sName) { sName = CN_Idle; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
Expand All @@ -88,7 +88,7 @@ class fsm_PlayList_state_PlayingFile : public fsm_PlayList_state
fsm_PlayList_state_PlayingFile() {}
virtual ~fsm_PlayList_state_PlayingFile() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayList* Parent);
virtual void GetStateName (String & sName) { sName = CN_File; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
Expand All @@ -104,7 +104,7 @@ class fsm_PlayList_state_PlayingEffect : public fsm_PlayList_state
fsm_PlayList_state_PlayingEffect() {}
virtual ~fsm_PlayList_state_PlayingEffect() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayList* Parent);
virtual void GetStateName (String & sName) { sName = CN_Effect; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
Expand All @@ -120,7 +120,7 @@ class fsm_PlayList_state_Paused : public fsm_PlayList_state
fsm_PlayList_state_Paused() {}
virtual ~fsm_PlayList_state_Paused() {}

virtual bool Poll (bool StayDark);
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayList* Parent);
virtual void GetStateName (String & sName) { sName = CN_Paused; }
virtual void Start (String & FileName, float SecondsElapsed, uint32_t PlayCount);
Expand Down
2 changes: 1 addition & 1 deletion include/input/InputMQTT.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class c_InputMQTT : public c_InputCommon
bool SetConfig (JsonObject& jsonConfig); ///< Set a new config in the driver
void GetConfig (JsonObject& jsonConfig); ///< Get the current config used by the driver
void GetStatus (JsonObject& jsonStatus);
void Process (bool StayDark);
void Process ();
void GetDriverName (String& sDriverName) { sDriverName = "MQTT"; } ///< get the name for the instantiated driver
void SetBufferInfo (uint32_t BufferSize);
void NetworkStateChanged (bool IsConnected); // used by poorly designed rx functions
Expand Down
4 changes: 3 additions & 1 deletion include/input/InputMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* InputMgr.hpp - Input Management class
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* Copyright (c) 2021, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -94,6 +94,7 @@ class c_InputMgr
};

#define NO_CONFIG_NEEDED time_t(-1)
#define INPUTMGR_TASK_PRIORITY 6

DriverInfo_t InputChannelDrivers[InputChannelId_End]; ///< pointer(s) to the current active Input driver
uint32_t InputDataBufferSize = 0;
Expand All @@ -103,6 +104,7 @@ class c_InputMgr
bool IsConnected = false;
bool configInProgress = false;
time_t ConfigLoadNeeded = NO_CONFIG_NEEDED;
bool PauseProcessing = false;

// configuration parameter names for the channel manager within the config file
# define IM_EffectsControlButtonName F ("ecb")
Expand Down
2 changes: 1 addition & 1 deletion include/input/externalInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class c_ExternalInput final
};

void Init (uint32_t iInputId, uint32_t iPinId, Polarity_t Poliarity, String & sName);
void Poll (bool StayDark);
void Poll (void);
void GetConfig (JsonObject JsonData);
void GetStatistics (JsonObject JsonData);
void ProcessConfig (JsonObject JsonData);
Expand Down
4 changes: 2 additions & 2 deletions include/output/OutputMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* OutputMgr.hpp - Output Management class
*
* Project: ESPixelStick - An ESP8266 / ESP32 and E1.31 based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* Copyright (c) 2021, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -238,7 +238,7 @@ class c_OutputMgr
bool HasBeenInitialized = false;
time_t ConfigLoadNeeded = NO_CONFIG_NEEDED;
bool ConfigInProgress = false;
bool IsOutputPaused = false;
bool OutputIsPaused = false;
bool BuildingNewConfig = false;

bool ProcessJsonConfig (JsonDocument & jsonConfig);
Expand Down
1 change: 1 addition & 0 deletions include/service/FPPDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class c_FPPDiscovery
bool PlayingFile ();

bool inFileUpload = false;
bool writeFailed = false;
bool hasBeenInitialized = false;
bool IsEnabled = false;
bool BlankOnStop = false;
Expand Down
4 changes: 2 additions & 2 deletions src/input/InputAlexa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ void c_InputAlexa::GetStatus (JsonObject& /* jsonStatus */)
} // GetStatus

//-----------------------------------------------------------------------------
void c_InputAlexa::Process (bool StayDark)
void c_InputAlexa::Process ()
{
// DEBUG_START;
if (IsInputChannelActive)
{
pEffectsEngine->Process (StayDark);
pEffectsEngine->Process ();
}

// DEBUG_END;
Expand Down
7 changes: 4 additions & 3 deletions src/input/InputArtnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ArtnetInput.cpp - Code to wrap ESPAsyncArtnet for input
*
* Project: ESPixelStick - An ESP8266 / ESP32 and Artnet based pixel driver
* Copyright (c) 2021, 2022 Shelby Merrick
* Copyright (c) 2021, 2025 Shelby Merrick
* http://www.forkineye.com
*
* This program is provided free for you to use in any way that you wish,
Expand Down Expand Up @@ -120,8 +120,9 @@ void c_InputArtnet::onDmxFrame (uint16_t CurrentUniverseId,
IPAddress remoteIP)
{
// DEBUG_START;

if ((startUniverse <= CurrentUniverseId) && (LastUniverse >= CurrentUniverseId))
if(!IsInputChannelActive)
{}
else if ((startUniverse <= CurrentUniverseId) && (LastUniverse >= CurrentUniverseId))
{
// Universe offset and sequence tracking
Universe_t & CurrentUniverse = UniverseArray[CurrentUniverseId - startUniverse];
Expand Down
Loading

0 comments on commit 0972988

Please sign in to comment.