6#include "../test/fakes/arduino_shim.h"
16 : action(std::move(action)), delayMs(delayMs)
31 startTime =
static_cast<uint32_t
>(millis());
36 if (millis() - startTime >= delayMs)
53 return (currentTime - startTime >= delayMs);
63 json[
"delayMs"] = delayMs;
64 JsonObject nestedAction = json.createNestedObject(
"action");
65 action->getJsonProperties(nestedAction);
66 nestedAction[
"type"] =
getTypeName(action->getType());
80 return "SendStringAction";
82 return "SendCharAction";
84 return "SendKeyAction";
86 return "SendMediaKeyAction";
88 return "SerialOutputAction";
90 return "DelayedAction";
92 return "UnknownAction";
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.
void execute() override
Executes the delayed action.
DelayedAction(std::unique_ptr< Action > action, uint32_t delayMs)
Constructs a DelayedAction that wraps an action with a time delay.
void getJsonProperties(JsonObject &json) const override
Serializes the delayed action to JSON.