50 static const uint8_t CAN_MAX_DATA_LENGTH = 8;
62 uint8_t data[CAN_MAX_DATA_LENGTH]
__attribute__((aligned(8)));
68 void setup()
override;
69 void dump_config()
override;
73 void send_data(uint32_t can_id,
bool use_extended_id,
bool remote_transmission_request,
74 const std::vector<uint8_t> &data);
75 void send_data(uint32_t can_id,
bool use_extended_id,
const std::vector<uint8_t> &data) {
77 this->send_data(can_id, use_extended_id,
false, data);
87 std::vector<CanbusTrigger *> triggers_{};
92 virtual bool setup_internal();
100 this->data_func_ = func;
101 this->static_ =
false;
104 this->data_static_ = data;
105 this->static_ =
true;
117 auto can_id = this->can_id_.has_value() ? *this->can_id_ : this->parent_->can_id_;
118 auto use_extended_id =
119 this->use_extended_id_.has_value() ? *this->use_extended_id_ : this->parent_->use_extended_id_;
121 this->parent_->send_data(can_id, use_extended_id, this->remote_transmission_request_, this->data_static_);
123 auto val = this->data_func_(
x...);
124 this->parent_->send_data(can_id, use_extended_id, this->remote_transmission_request_,
val);
131 bool remote_transmission_request_{
false};
133 std::function<std::vector<uint8_t>(Ts...)> data_func_{};
134 std::vector<uint8_t> data_static_{};
142 const bool use_extended_id)
143 : parent_(parent), can_id_(can_id), can_id_mask_(can_id_mask), use_extended_id_(use_extended_id){};
149 void setup()
override { this->parent_->add_trigger(
this); }
void send_data(uint32_t can_id, bool use_extended_id, const std::vector< uint8_t > &data)
void set_data_static(const std::vector< uint8_t > &data)
float get_setup_priority() const override
uint8_t can_data_length_code
void set_bitrate(CanSpeed bit_rate)
CanbusTrigger(Canbus *parent, const std::uint32_t can_id, const std::uint32_t can_id_mask, const bool use_extended_id)
void set_can_id(uint32_t can_id)
bool remote_transmission_request
void set_use_extended_id(bool use_extended_id)
void set_data_template(const std::function< std::vector< uint8_t >(Ts...)> func)
void set_remote_transmission_request(bool remote_transmission_request)
void set_use_extended_id(bool use_extended_id)
void play(Ts... x) override
uint8_t data [CAN_MAX_DATA_LENGTH] __attribute__((aligned(8)))
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
void set_can_id(uint32_t can_id)
Implementation of SPI Controller mode.
Helper class to easily give an object a parent of type T.
void set_remote_transmission_request(bool remote_transmission_request)