AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
delayed_action.h
Go to the documentation of this file.
1#pragma once
2#include "action.h"
3#include <ArduinoJson.h>
4#include <cstdint>
5#include <memory>
6
15class DelayedAction : public Action
16{
17public:
18 DelayedAction(std::unique_ptr<Action> action, uint32_t delayMs);
19
20 void execute() override;
21
22 uint32_t getDelay() const override { return delayMs; }
23 bool isSendAction() const override { return action->isSendAction(); }
24 bool isInProgress() const override { return started; }
25 Action::Type getType() const override { return Action::Type::Delayed; }
26
33 bool update(uint32_t currentTime) const;
34
35 bool isStarted() const { return started; }
36 const Action* getInnerAction() const { return action.get(); }
37
38 void getJsonProperties(JsonObject& json) const override;
39 static const char* getTypeName(Action::Type type);
40
41private:
42 std::unique_ptr<Action> action;
43 uint32_t delayMs;
44 uint32_t startTime = 0;
45 bool started = false;
46};
Base class for all pedal actions.
Definition action.h:12
Wraps an action and defers its execution by a configurable delay.
uint32_t getDelay() const override
const Action * getInnerAction() const
static const char * getTypeName(Action::Type type)
Converts an Action::Type enum to its string representation.
bool update(uint32_t currentTime) const
Polls whether the delay has elapsed.
bool isStarted() const
void execute() override
Executes the delayed action.
bool isSendAction() const override
bool isInProgress() const override
Returns true if the action is currently in progress (e.g.
void getJsonProperties(JsonObject &json) const override
Serializes the delayed action to JSON.
Action::Type getType() const override