Skip to content

Commit dad3c4e

Browse files
Andrej ChrcekAndrej Chrcek
authored andcommitted
Updated UI, added loop function, improved FPP sync functionality
1 parent 0de772e commit dad3c4e

File tree

4 files changed

+334
-188
lines changed

4 files changed

+334
-188
lines changed

usermods/FSEQ/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ build_flags =
4343
To integrate the new FSEQ functionality into the WLED UI, add a new button to the navigation area in your `wled00/data/index.htm` file. For example:
4444

4545
<!-- New button for SD & FSEQ Manager -->
46-
<button onclick="window.location.href=getURL('/sd/ui');">
46+
<button onclick="window.location.href=getURL('/fsequi');">
4747
<i class="icons">&#xe0d2;</i>
4848
<p class="tab-label">Fseq</p>
4949
</button>

usermods/FSEQ/fseq_player.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,13 @@ void FSEQPlayer::processFrameData() {
9090
bool FSEQPlayer::stopBecauseAtTheEnd() {
9191
if (!recordingFile.available()) {
9292
if (recordingRepeats == RECORDING_REPEAT_LOOP) {
93+
// Reset file pointer and frame counter for continuous loop
9394
recordingFile.seek(0);
95+
frame = 0;
9496
} else if (recordingRepeats > 0) {
9597
recordingFile.seek(0);
9698
recordingRepeats--;
99+
frame = 0;
97100
DEBUG_PRINTF("Repeat recording again for: %d\n", recordingRepeats);
98101
} else {
99102
DEBUG_PRINTLN("Finished playing recording, disabling realtime mode");
@@ -187,7 +190,12 @@ void FSEQPlayer::loadRecording(const char* filepath, uint16_t startLed, uint16_t
187190
if (frame >= file_header.frame_count) {
188191
frame = file_header.frame_count - 1;
189192
}
190-
recordingRepeats = RECORDING_REPEAT_DEFAULT;
193+
// Set loop mode if secondsElapsed is exactly 1.0f
194+
if (secondsElapsed == 1.0f) {
195+
recordingRepeats = RECORDING_REPEAT_LOOP;
196+
} else {
197+
recordingRepeats = RECORDING_REPEAT_DEFAULT;
198+
}
191199
playNextRecordingFrame();
192200
}
193201

@@ -198,29 +206,28 @@ void FSEQPlayer::clearLastPlayback() {
198206
frame = 0;
199207
}
200208

209+
bool FSEQPlayer::isPlaying() {
210+
return recordingFile && recordingFile.available();
211+
}
201212

202-
bool FSEQPlayer::isPlaying() {
203-
return recordingFile && recordingFile.available();
213+
void FSEQPlayer::syncPlayback(float secondsElapsed) {
214+
if (!isPlaying()) {
215+
DEBUG_PRINTLN("[FSEQ] Sync: Playback not active, cannot sync.");
216+
return;
204217
}
205218

206-
void FSEQPlayer::syncPlayback(float secondsElapsed) {
207-
if (!isPlaying()) {
208-
DEBUG_PRINTLN("[FSEQ] Sync: Playback not active, cannot sync.");
209-
return;
210-
}
211-
212-
uint32_t expectedFrame = (uint32_t)((secondsElapsed * 1000.0f) / file_header.step_time);
213-
int32_t diff = (int32_t)expectedFrame - (int32_t)frame;
214-
215-
if (abs(diff) > 2) {
216-
frame = expectedFrame;
217-
uint32_t offset = file_header.channel_data_offset + file_header.channel_count * frame;
218-
if (recordingFile.seek(offset)) {
219-
DEBUG_PRINTF("[FSEQ] Sync: Adjusted frame to %lu (diff=%ld)\n", expectedFrame, diff);
220-
} else {
221-
DEBUG_PRINTLN("[FSEQ] Sync: Failed to seek to new frame");
222-
}
219+
uint32_t expectedFrame = (uint32_t)((secondsElapsed * 1000.0f) / file_header.step_time);
220+
int32_t diff = (int32_t)expectedFrame - (int32_t)frame;
221+
222+
if (abs(diff) > 2) {
223+
frame = expectedFrame;
224+
uint32_t offset = file_header.channel_data_offset + file_header.channel_count * frame;
225+
if (recordingFile.seek(offset)) {
226+
DEBUG_PRINTF("[FSEQ] Sync: Adjusted frame to %lu (diff=%ld)\n", expectedFrame, diff);
223227
} else {
224-
DEBUG_PRINTF("[FSEQ] Sync: No adjustment needed (current frame: %lu, expected: %lu)\n", frame, expectedFrame);
228+
DEBUG_PRINTLN("[FSEQ] Sync: Failed to seek to new frame");
225229
}
226-
}
230+
} else {
231+
DEBUG_PRINTF("[FSEQ] Sync: No adjustment needed (current frame: %lu, expected: %lu)\n", frame, expectedFrame);
232+
}
233+
}

usermods/FSEQ/usermod_fseq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class UsermodFseq : public Usermod {
9292
JsonArray arr = user.createNestedArray("Usermod FSEQ UI");
9393

9494
String ip = WiFi.localIP().toString();
95-
arr.add("http://" + ip + "/sd/ui"); // value
95+
arr.add("http://" + ip + "/fsequi"); // value
9696
}
9797

9898
// Save your SPI pins to WLED config JSON

0 commit comments

Comments
 (0)