Skip to content

Commit

Permalink
Merge pull request #639 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Fixed AP Reboot checkbox handling on UI
  • Loading branch information
forkineye authored Jun 29, 2023
2 parents 615e493 + 9443532 commit abf9f29
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 7,944 deletions.
1 change: 1 addition & 0 deletions ESPixelStick/src/ConstNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const CN_PROGMEM char CN_sca [] = "sca";
const CN_PROGMEM char CN_seconds_elapsed [] = "seconds_elapsed";
const CN_PROGMEM char CN_seconds_played [] = "seconds_played";
const CN_PROGMEM char CN_seconds_remaining [] = "seconds_remaining";
const CN_PROGMEM char CN_SendFppSync [] = "SendFppSync";
const CN_PROGMEM char CN_sequence_filename [] = "sequence_filename";
const CN_PROGMEM char CN_Serial [] = "Serial";
const CN_PROGMEM char CN_Servo_PCA9685 [] = "Servo PCA9685";
Expand Down
1 change: 1 addition & 0 deletions ESPixelStick/src/ConstNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ extern const CN_PROGMEM char CN_sca[];
extern const CN_PROGMEM char CN_seconds_elapsed[];
extern const CN_PROGMEM char CN_seconds_played[];
extern const CN_PROGMEM char CN_seconds_remaining[];
extern const CN_PROGMEM char CN_SendFppSync[];
extern const CN_PROGMEM char CN_sequence_filename[];
extern const CN_PROGMEM char CN_Serial[];
extern const CN_PROGMEM char CN_Servo_PCA9685[];
Expand Down
8 changes: 7 additions & 1 deletion ESPixelStick/src/input/InputFPPRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void c_InputFPPRemote::GetConfig (JsonObject& jsonConfig)
jsonConfig[JSON_NAME_FILE_TO_PLAY] = No_LocalFileToPlay;
}
jsonConfig[CN_SyncOffset] = SyncOffsetMS;
jsonConfig[CN_SendFppSync] = SendFppSync;

// DEBUG_END;

Expand Down Expand Up @@ -252,11 +253,14 @@ bool c_InputFPPRemote::SetConfig (JsonObject& jsonConfig)
// DEBUG_START;

String FileToPlay;
setFromJSON (FileToPlay, jsonConfig, JSON_NAME_FILE_TO_PLAY);
setFromJSON (FileToPlay, jsonConfig, JSON_NAME_FILE_TO_PLAY);
setFromJSON (SyncOffsetMS, jsonConfig, CN_SyncOffset);
setFromJSON (SendFppSync, jsonConfig, CN_SendFppSync);

if (pInputFPPRemotePlayItem)
{
pInputFPPRemotePlayItem->SetSyncOffsetMS (SyncOffsetMS);
pInputFPPRemotePlayItem->SetSendFppSync (SendFppSync);
}

// DEBUG_V ("Config Processing");
Expand Down Expand Up @@ -394,6 +398,7 @@ void c_InputFPPRemote::StartPlayingLocalFile (String& FileName)
// DEBUG_V (String ("FileName: '") + FileName + "'");
// DEBUG_V ("Start Playing");
pInputFPPRemotePlayItem->SetSyncOffsetMS (SyncOffsetMS);
pInputFPPRemotePlayItem->SetSendFppSync (SendFppSync);
pInputFPPRemotePlayItem->Start (FileName, 0, 1);
FileBeingPlayed = FileName;

Expand Down Expand Up @@ -421,6 +426,7 @@ void c_InputFPPRemote::StartPlayingRemoteFile (String& FileName)
// DEBUG_V ("Instantiate an FSEQ file player");
pInputFPPRemotePlayItem = new c_InputFPPRemotePlayFile (GetInputChannelId ());
pInputFPPRemotePlayItem->SetSyncOffsetMS (SyncOffsetMS);
pInputFPPRemotePlayItem->SetSendFppSync (SendFppSync);
StatusType = CN_File;
FileBeingPlayed = FileName;

Expand Down
4 changes: 3 additions & 1 deletion ESPixelStick/src/input/InputFPPRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class c_InputFPPRemote : public c_InputCommon

c_InputFPPRemotePlayItem * pInputFPPRemotePlayItem = nullptr;
int32_t GetSyncOffsetMS () { return SyncOffsetMS; }
bool GetSendFppSync () { return SendFppSync; }

String StatusType;
bool StayDark = false;
Expand All @@ -66,8 +67,9 @@ class c_InputFPPRemote : public c_InputCommon
void load (); ///< Load configuration from File System
void save (); ///< Save configuration to File System

String FileBeingPlayed;
int32_t SyncOffsetMS = 0;
bool SendFppSync = false;
String FileBeingPlayed;

# define JSON_NAME_FILE_TO_PLAY CN_fseqfilename

Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/input/InputFPPRemotePlayFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class c_InputFPPRemotePlayFile : public c_InputFPPRemotePlayItem

#ifdef ARDUINO_ARCH_ESP32
TaskHandle_t TimerPollTaskHandle = NULL;
# define TimerPollHandlerTaskStack 2000
# define TimerPollHandlerTaskStack 3000
// # define TimerPollHandlerTaskStack 6000
#endif // def ARDUINO_ARCH_ESP32

Expand Down
16 changes: 16 additions & 0 deletions ESPixelStick/src/input/InputFPPRemotePlayFileFsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "InputFPPRemotePlayFile.hpp"
#include "InputMgr.hpp"
#include "src/service/FPPDiscovery.h"

//-----------------------------------------------------------------------------
void fsm_PlayFile_state_Idle::Poll ()
Expand Down Expand Up @@ -129,6 +130,11 @@ void fsm_PlayFile_state_Starting::Init (c_InputFPPRemotePlayFile* Parent)
p_Parent = Parent;
Parent->pCurrentFsmState = &(Parent->fsm_PlayFile_state_Starting_imp);

if(p_Parent->SendFppSync)
{
FPPDiscovery.GenerateFppSyncMsg(SYNC_PKT_START, p_Parent->GetFileName(), 0, float(0.0));
}

// DEBUG_END;

} // fsm_PlayFile_state_Starting::Init
Expand Down Expand Up @@ -248,6 +254,11 @@ IRAM_ATTR void fsm_PlayFile_state_PlayingFile::TimerPoll ()

LastPlayedFrameId = CurrentFrame;

if(p_Parent->SendFppSync)
{
FPPDiscovery.GenerateFppSyncMsg(SYNC_PKT_SYNC, p_Parent->GetFileName(), CurrentFrame, float(p_Parent->FrameControl.ElapsedPlayTimeMS) / 1000.0);
}

for (auto& CurrentSparseRange : p_Parent->SparseRanges)
{
uint32_t ActualBytesToRead = min (MaxBytesToRead, CurrentSparseRange.ChannelCount);
Expand Down Expand Up @@ -481,6 +492,11 @@ void fsm_PlayFile_state_Stopping::Init (c_InputFPPRemotePlayFile* Parent)
p_Parent->SyncControl.LastRcvdElapsedSeconds = 0;
p_Parent->FrameControl.ElapsedPlayTimeMS = 0;

if(p_Parent->SendFppSync)
{
FPPDiscovery.GenerateFppSyncMsg(SYNC_PKT_STOP, emptyString, 0, float(0.0));
}

// DEBUG_END;

} // fsm_PlayFile_state_Stopping::Init
Expand Down
2 changes: 2 additions & 0 deletions ESPixelStick/src/input/InputFPPRemotePlayItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ class c_InputFPPRemotePlayItem
void GetDriverName (String& Name) { Name = "InputMgr"; }
int32_t GetSyncOffsetMS () { return SyncOffsetMS; }
void SetSyncOffsetMS (int32_t value) { SyncOffsetMS = value; }
void SetSendFppSync (bool value) { SendFppSync = value; }
c_InputMgr::e_InputChannelIds GetInputChannelId () { return InputChannelId; }
protected:
String PlayItemName;
uint32_t RemainingPlayCount = 0;
time_t PlayDurationSec = 0;
bool SendFppSync = false;

private:
int32_t SyncOffsetMS = 0;
Expand Down
45 changes: 43 additions & 2 deletions ESPixelStick/src/service/FPPDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ void c_FPPDiscovery::NetworkStateChanged (bool NewNetworkState)

// DEBUG_V ();

IPAddress address = IPAddress (239, 70, 80, 80);
bool fail = false;

// Try to listen to the broadcast port
Expand All @@ -90,7 +89,7 @@ void c_FPPDiscovery::NetworkStateChanged (bool NewNetworkState)
}
//logcon (String (F ("FPPDiscovery subscribed to broadcast")));

if (!udp.listenMulticast (address, FPP_DISCOVERY_PORT))
if (!udp.listenMulticast (MulticastAddress, FPP_DISCOVERY_PORT))
{
logcon (String (F ("FAILED to subscribed to multicast messages")));
fail = true;
Expand Down Expand Up @@ -1086,4 +1085,46 @@ bool c_FPPDiscovery::AllowedToRemotePlayFiles()
return (FileMgr.SdCardIsInstalled() && IsEnabled);
} // AllowedToRemotePlayFiles

//-----------------------------------------------------------------------------
void c_FPPDiscovery::GenerateFppSyncMsg(uint8_t Action, const String & FileName, uint32_t CurrentFrame, const float & ElpsedTime)
{
// DEBUG_START;

do // once
{
if((Action == SYNC_PKT_SYNC) && (CurrentFrame & 0x7))
{
// only send sync every 8th frame
break;
}

FPPMultiSyncPacket SyncPacket;

SyncPacket.header[0] = 'F';
SyncPacket.header[1] = 'P';
SyncPacket.header[2] = 'P';
SyncPacket.header[3] = 'D';
SyncPacket.packet_type = CTRL_PKT_SYNC;
write16 ((uint8_t*)&SyncPacket.data_len, sizeof(SyncPacket));

SyncPacket.sync_action = Action;
SyncPacket.sync_type = SYNC_FILE_SEQ;
write32((uint8_t*)&SyncPacket.frame_number, CurrentFrame);
SyncPacket.seconds_elapsed = ElpsedTime;

// copy the file name and make sure a truncated file name has a proper line termination.
strncpy(SyncPacket.filename, FileName.c_str(), size_t(sizeof(SyncPacket.filename)-1));
SyncPacket.filename[sizeof(SyncPacket.filename)-1] = 0x00;

if(NetworkMgr.IsConnected())
{
udp.writeTo (SyncPacket.raw, sizeof (SyncPacket), IPAddress(255,255,255,255), FPP_DISCOVERY_PORT);
udp.writeTo (SyncPacket.raw, sizeof (SyncPacket), MulticastAddress, FPP_DISCOVERY_PORT);
}
} while(false);


// DEBUG_END;
} // GenerateFppSyncMsg

c_FPPDiscovery FPPDiscovery;
12 changes: 7 additions & 5 deletions ESPixelStick/src/service/FPPDiscovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class c_FPPDiscovery
String UploadFileName;
IPAddress FppRemoteIp = IPAddress (uint32_t(0));
c_InputFPPRemotePlayFile * InputFPPRemotePlayFile = nullptr;
const IPAddress MulticastAddress = IPAddress (239, 70, 80, 80);

void GetSysInfoJSON (JsonObject& jsonResponse);
void BuildFseqResponse (String fname, c_FileMgr::FileId fseq, String & resp);
Expand Down Expand Up @@ -86,11 +87,6 @@ class c_FPPDiscovery
};
MultiSyncStats_t MultiSyncStats;

# define SYNC_PKT_START 0
# define SYNC_PKT_STOP 1
# define SYNC_PKT_SYNC 2
# define SYNC_PKT_OPEN 3

# define SYNC_FILE_SEQ 0
# define SYNC_FILE_MEDIA 1

Expand Down Expand Up @@ -123,6 +119,12 @@ class c_FPPDiscovery

void SetInputFPPRemotePlayFile (c_InputFPPRemotePlayFile * value) { InputFPPRemotePlayFile = value; }
void ForgetInputFPPRemotePlayFile () { InputFPPRemotePlayFile = nullptr; }
void GenerateFppSyncMsg (uint8_t Action, const String & FileName, uint32_t CurrentFrame, const float & ElpsedTime);

# define SYNC_PKT_START 0
# define SYNC_PKT_STOP 1
# define SYNC_PKT_SYNC 2
# define SYNC_PKT_OPEN 3

};

Expand Down
16 changes: 16 additions & 0 deletions ESPixelStick/src/service/fseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,32 @@ inline uint32_t read32 (uint8_t* buf, int idx) {
r |= (int)(buf[idx]);
return r;
}

inline void write32 (uint8_t* pData, uint32_t value)
{
pData[0] = (value >> 0) & 0xff;
pData[1] = (value >> 8) & 0xff;
pData[2] = (value >> 16) & 0xff;
pData[3] = (value >> 24) & 0xff;
} // write16

//-----------------------------------------------------------------------------
inline uint32_t read24 (uint8_t* pData)
{
return ((uint32_t)(pData[0]) |
(uint32_t)(pData[1]) << 8 |
(uint32_t)(pData[2]) << 16);
} // read24

//-----------------------------------------------------------------------------
inline uint16_t read16 (uint8_t* pData)
{
return ((uint16_t)(pData[0]) |
(uint16_t)(pData[1]) << 8);
} // read16

inline void write16 (uint8_t* pData, uint16_t value)
{
pData[0] = value & 0xff;
pData[1] = (value >> 8) & 0xff;
} // write16
80 changes: 80 additions & 0 deletions gulpme.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@echo off

rem set the directory to the same value as tht used to strt the bat file
setlocal enabledelayedexpansion
@setlocal enableextensions
@cd /d "%~dp0"
set NODE_MODULES_PATH=%~dp0%node_modules

set NULL_VAL=null
set NODE_VER=%NULL_VAL%
set NODE_EXEC=node-v10.15.3-x86.msi

node -v >.tmp_nodever
set /p NODE_VER=<.tmp_nodever
del .tmp_nodever

set GULP_PATH=%NULL_VAL%
where gulp > .tempGulpPath
set /p GULP_PATH=<.tempGulpPath
del .tempGulpPath

IF "%NODE_VER%"=="%NULL_VAL%" (
NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo This setup needs admin permissions. Please run this file as admin.
pause
exit
)

echo.
echo Node.js is not installed! Please press a key to download and install it from the website that will open.
PAUSE
start "" http://nodejs.org/dist/v10.15.3/%NODE_EXEC%
echo.
echo.
echo After you have installed Node.js, press a key to shut down this process. Please restart it again afterwards.
call npm install
PAUSE
EXIT
) ELSE (
echo A version of Node.js ^(%NODE_VER%^) is installed. Proceeding...
)

set InstallGulp=0

if "%GULP_PATH%"=="%NULL_VAL%" (
set InstallGulp=1
echo no gulp path
)

if NOT exist %NODE_MODULES_PATH% (
set InstallGulp=1
echo no modules dir
)

rem echo NODE_MODULES_PATH = %NODE_MODULES_PATH%
rem echo GULP_PATH = %GULP_PATH%
rem echo InstallGulp = !InstallGulp!
rem pause

IF !InstallGulp! == 1 (
NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo This setup needs admin permissions. Please run this file as admin.
pause
exit
)
echo.
echo Install gulp

call npm install
call npm install --global
call npm audit fix
) ELSE (
echo gulp is installed. Proceeding...
)

echo execute gulp
gulp
pause
4 changes: 4 additions & 0 deletions html/fpp_remote.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
<div class="col-sm-4">
<input type="number" class="form-control is-valid" id="SyncOffset" step="1" min="-10000" max="10000" value="0" required title="Offset between Sync Message and Frame to play.">
</div>
<label class="control-label col-sm-2" for="SendFppSync">Send FPP Sync</label>
<div class="col-sm-4">
<input type="checkbox" id="SendFppSync" title="Send FPP Sync.">
</div>
</div>
</fieldset>
8 changes: 5 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,13 @@
<div id="fg_input_mode"></div>

<div class="hidden" id="ecb">
<legend class="esps-legend" for="ecb_title">Advance Effect/File via Button/Channel</legend>
<legend class="esps-legend" for="ecb_title">Advance Effect/File via Button</legend>
<div class="form-group col-sm-offset-2" id="ecb_title">

<label class="control-label col-sm-offset-1" for="ecb_enable">Enable:</label>
<input type="checkbox" id="ecb_enable" title="Trigger Effects using a button or channel.">
<label class="control-label col-sm-2" for="ecb_enable">Enable</label>
<div class="col-sm-4">
<input type="checkbox" id="ecb_enable" title="Send FPP Sync.">
</div>

<label class="control-label AdvancedMode" for="ecb_gpioid">GPIO</label>
<input type="number" class="is-valid AdvancedMode" id="ecb_gpioid" step="1" min="0" max="40" value="0" title="GPIO to monitor for effects trigger">
Expand Down
2 changes: 1 addition & 1 deletion html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ function ExtractNetworkWiFiConfigFromHtmlPage() {
wifi.ap_fallback = $('#network #wifi #ap_fallback').prop('checked');
wifi.ap_reboot = $('#network #wifi #ap_reboot').prop('checked');
wifi.ap_timeout = $('#network #wifi #ap_timeout').val();
wifi.StayInApMode = $('#network #wifi #StayInApMode').val();
wifi.StayInApMode = $('#network #wifi #StayInApMode').prop('checked');

} // ExtractNetworkWiFiConfigFromHtmlPage

Expand Down
Loading

0 comments on commit abf9f29

Please sign in to comment.