[cc1101] Use register_apply_action for begin_tx, begin_rx, reset and set_idle (#19661)

This commit is contained in:
J. Nick Koston
2026-09-25 14:56:06 -04:00
committed by GitHub
parent 288a7b376a
commit 1edc327835
2 changed files with 9 additions and 54 deletions
+9 -34
View File
@@ -351,10 +351,6 @@ async def to_code(config):
# Actions
BeginTxAction = ns.class_("BeginTxAction", automation.Action)
BeginRxAction = ns.class_("BeginRxAction", automation.Action)
ResetAction = ns.class_("ResetAction", automation.Action)
SetIdleAction = ns.class_("SetIdleAction", automation.Action)
SendPacketAction = ns.class_(
"SendPacketAction", automation.Action, cg.Parented.template(CC1101Component)
)
@@ -364,36 +360,15 @@ CC1101_ACTION_SCHEMA = cv.Schema(
)
automation.register_parented_action(
"cc1101.begin_tx",
BeginTxAction,
CC1101_ACTION_SCHEMA,
synchronous=True,
)
automation.register_parented_action(
"cc1101.begin_rx",
BeginRxAction,
CC1101_ACTION_SCHEMA,
synchronous=True,
)
automation.register_parented_action(
"cc1101.reset",
ResetAction,
CC1101_ACTION_SCHEMA,
synchronous=True,
)
automation.register_parented_action(
"cc1101.set_idle",
SetIdleAction,
CC1101_ACTION_SCHEMA,
synchronous=True,
)
for _name, _call in (
("cc1101.begin_tx", "begin_tx()"),
("cc1101.begin_rx", "begin_rx()"),
("cc1101.reset", "reset()"),
("cc1101.set_idle", "set_idle()"),
):
automation.register_apply_action(
_name, CC1101_ACTION_SCHEMA, automation.ApplyCall(_call)
)
def validate_raw_data(value):
-20
View File
@@ -130,26 +130,6 @@ class CC1101Component final : public Component,
};
// Action Wrappers
template<typename... Ts> class BeginTxAction final : public Action<Ts...>, public Parented<CC1101Component> {
public:
void play(const Ts &...x) override { this->parent_->begin_tx(); }
};
template<typename... Ts> class BeginRxAction final : public Action<Ts...>, public Parented<CC1101Component> {
public:
void play(const Ts &...x) override { this->parent_->begin_rx(); }
};
template<typename... Ts> class ResetAction final : public Action<Ts...>, public Parented<CC1101Component> {
public:
void play(const Ts &...x) override { this->parent_->reset(); }
};
template<typename... Ts> class SetIdleAction final : public Action<Ts...>, public Parented<CC1101Component> {
public:
void play(const Ts &...x) override { this->parent_->set_idle(); }
};
template<typename... Ts> class SendPacketAction final : public Action<Ts...>, public Parented<CC1101Component> {
public:
void set_data_template(std::function<std::vector<uint8_t>(Ts...)> func) { this->data_func_ = func; }