Loading files
// ═══════════════════════════════════════════════════════════
// PatternFlow - the show player, as a feature
//
// The first thing ported onto the feature seam, and deliberately the
// hardest: sequences touch boot, the network, every frame, user input,
// pattern control and the overlay pass. If this fits, the hook set is
// real.
//
// Nothing of the player itself is here — core_show.h and its two
// companions are unchanged beside this file. All this does is say which
// of their functions answers which moment.
//
// License: MIT
// ═══════════════════════════════════════════════════════════
#pragma once
#include "../pf_feature.h"
#include "core_show.h"
#include "core_show_http.h"
#include "core_show_schedule.h"
#include "core_show_select.h"
#include "core_library_http.h"
namespace PFFeatureShow {
inline void setup() {
PatternflowShowSchedule::begin();
PatternflowShow::begin();
}
inline void onNetwork() {
PatternflowShowHttp::begin();
}
inline void loop(const PFFeatureFrame& frame) {
// Advance the running .pfs cue table (no-op when nothing is playing).
PatternflowShow::tick();
// Night/wake scheduler: may queue Black or start the wake sequence. It
// needs to know what is on the panel, which is what the frame carries.
if (!PatternflowPatternsHttp::isConsolePaused()) {
PatternflowShowSchedule::tick(frame.patternName, frame.running);
}
}
inline void onUserInput() {
PatternflowShowSchedule::noteInteraction();
}
// A running show owns the pattern: OSC, MQTT and HTTP pickers stand down
// rather than yanking it out from under a sequence.
inline bool claimsPattern() {
return PatternflowShow::isPlaying();
}
// Show playback must be able to load a module even if Home/Patterns left
// the console-pause flag set — /show is a player, not a library editor.
inline bool takePattern(int* idx) {
if (!PatternflowShow::consumePatternIdx(*idx)) return false;
PatternflowPatternsHttp::releaseConsolePause();
return true;
}
// Scheduler-owned clock face, drawn over Black only (dim night clock or
// the big snooze face).
inline void drawOverlay(const PFFeatureFrame& frame) {
if (frame.patternName && strcmp(frame.patternName, "Black") == 0) {
PatternflowShowSchedule::drawOwnedClock();
}
}
// Lean fields for /api/status (home card). Full show state stays on /api/show.
inline void appendStatus(String& json) {
json += ",\"sequenceMode\":";
json += PatternflowShow::isSequenceMode() ? "true" : "false";
json += ",\"showPlaying\":";
json += PatternflowShow::isPlaying() ? "true" : "false";
}
inline const PFFeature descriptor = {
"show", // name
"shows", // cap reported by /api/status
setup,
onNetwork,
loop,
nullptr, // observeFrame
nullptr, // fillInput
onUserInput,
claimsPattern,
takePattern,
nullptr, // onSleep
nullptr, // requestSleep
nullptr, // shortName - not listed in the device menu
nullptr, // isRuntimeEnabled
nullptr, // setRuntimeEnabled
appendStatus,
drawOverlay,
"/show", // navPath - the console header link
"Sequences", // navLabel
"Timed shows from .pfs tables — play one, chain a playlist, "
"schedule night and wake.",
nullptr, // composeFrame
PatternflowShowSelect::handleSelectInput,
PatternflowShowSelect::drawSelect,
PatternflowShowSelect::decorateSelect,
};
} // namespace PFFeatureShow
07e931b46This file is pinned to the selected release. Download the original to open it in your design tool.