From 58df15702dd655853062359f09442fa9bcb86f51 Mon Sep 17 00:00:00 2001 From: Torrie Fischer Date: Mon, 11 Dec 2023 07:57:49 +0100 Subject: [PATCH] sequencer: implement commands to change scenes --- src/Sequencer.cpp | 29 +++++++++++++++++++++++++++++ src/Sequencer.h | 1 + 2 files changed, 30 insertions(+) diff --git a/src/Sequencer.cpp b/src/Sequencer.cpp index 2871297..cda0187 100644 --- a/src/Sequencer.cpp +++ b/src/Sequencer.cpp @@ -94,5 +94,34 @@ Sequencer::handleEvent(const InputEvent& evt) } } +void +doScenes(Args& args, Print& out) +{ + out.println("Available scenes: "); + for (auto scene : Static::instance()->scenes()) { + out.println(scene.name); + } +} + +static String s; + +void +doScene(Args& args, Print& out) +{ + s = args[1]; + MainLoop::instance()->dispatch(InputEvent{InputEvent::SetPattern, s.c_str()}); +} + +const std::vector _commands = { + {"scene", doScene}, + {"scenes", doScenes} +}; + +const std::vector& +Sequencer::commands() const +{ + return _commands; +} + STATIC_ALLOC(Sequencer); STATIC_TASK(Sequencer); diff --git a/src/Sequencer.h b/src/Sequencer.h index 52a9a27..885f7f5 100644 --- a/src/Sequencer.h +++ b/src/Sequencer.h @@ -23,6 +23,7 @@ public: const char* currentSceneName(); const std::vector scenes() const; + const std::vector& commands() const override; private: int m_idx;