mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
updates for canbus triggers
This commit is contained in:
parent
dd31f92c00
commit
9996124c54
@ -1,16 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/core/component.h"
|
|
||||||
#include "esphome/core/automation.h"
|
|
||||||
#include "esphome/components/canbus/canbus.h"
|
#include "esphome/components/canbus/canbus.h"
|
||||||
|
#include "esphome/core/automation.h"
|
||||||
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace canbus {
|
namespace canbus {
|
||||||
|
|
||||||
template<typename... Ts> class CanbusSendAction : public Action<Ts...>, public Parented<Canbus> {
|
template <typename... Ts>
|
||||||
public:
|
class CanbusSendAction : public Action<Ts...>, public Parented<Canbus> {
|
||||||
void set_data_template(const std::function<std::vector<uint8_t>(Ts...)> func) {
|
public:
|
||||||
|
void
|
||||||
|
set_data_template(const std::function<std::vector<uint8_t>(Ts...)> func) {
|
||||||
this->data_func_ = func;
|
this->data_func_ = func;
|
||||||
this->static_ = false;
|
this->static_ = false;
|
||||||
}
|
}
|
||||||
@ -30,12 +32,24 @@ template<typename... Ts> class CanbusSendAction : public Action<Ts...>, public P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t can_id_;
|
uint32_t can_id_;
|
||||||
bool static_{false};
|
bool static_{false};
|
||||||
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
std::function<std::vector<uint8_t>(Ts...)> data_func_{};
|
||||||
std::vector<uint8_t> data_static_{};
|
std::vector<uint8_t> data_static_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace canbus
|
class CanbusTrigger : public Trigger<std::uint32_t>, public Component {
|
||||||
} // namespace esphome
|
public:
|
||||||
|
explicit CanbusTrigger(const std::uint32_t &can_id);
|
||||||
|
|
||||||
|
void setup() override;
|
||||||
|
void dump_config() override;
|
||||||
|
float get_setup_priority() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint32_t can_id_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace canbus
|
||||||
|
} // namespace esphome
|
||||||
|
@ -74,17 +74,5 @@ class Canbus : public Component {
|
|||||||
virtual ERROR send_message_(const struct can_frame *frame);
|
virtual ERROR send_message_(const struct can_frame *frame);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CanbusTrigger : public Trigger<std::uint32_t>, public Component {
|
|
||||||
public:
|
|
||||||
explicit CanbusTrigger(const std::uint32_t &can_id);
|
|
||||||
|
|
||||||
void setup() override;
|
|
||||||
void dump_config() override;
|
|
||||||
float get_setup_priority() const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint32_t can_id_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace canbus
|
} // namespace canbus
|
||||||
} // namespace esphome
|
} // namespace esphome
|
Loading…
x
Reference in New Issue
Block a user