diff --git a/src/inputs/BPM.cpp b/src/inputs/BPM.cpp index c92ed1c..e11d2c8 100644 --- a/src/inputs/BPM.cpp +++ b/src/inputs/BPM.cpp @@ -1,5 +1,22 @@ #include "./BPM.h" #include "../Static.h" +void +doBPM(Args& args, Print& out) +{ + uint8_t newBPM(atoi(args[1].c_str())); + Static::instance()->setBPM(newBPM); +} + +const std::vector _commands = { + {"bpm", doBPM} +}; + +const std::vector& +BPM::commands() const +{ + return _commands; +} + STATIC_ALLOC(BPM); STATIC_TASK(BPM); diff --git a/src/inputs/BPM.h b/src/inputs/BPM.h index 464d4ec..e15b1c0 100644 --- a/src/inputs/BPM.h +++ b/src/inputs/BPM.h @@ -18,6 +18,8 @@ public: ConfigTaskMixin::handleEvent(evt); } + const std::vector& commands() const override; + void loop() { InputSource::loop(); ConfigTaskMixin::loop(); @@ -29,6 +31,11 @@ public: Log.notice("bpm: idle BPM set to %d (requested %d)", (int)msToBPM(m_msPerBeat), (int)requestedBPM); } + void setBPM(double bpm) { + m_msPerBeat = 60000.0 / (double)bpm; + Log.notice("bpm: Command changed to %d (requested %d)", (int)msToBPM(m_msPerBeat), (int)bpm); + } + InputEvent read() override { if (m_msPerBeat > 0) { uint16_t now = millis();